| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 handler_map["GetViews"] = | 1691 handler_map["GetViews"] = |
| 1692 &TestingAutomationProvider::GetViews; | 1692 &TestingAutomationProvider::GetViews; |
| 1693 handler_map["IsTabIdValid"] = | 1693 handler_map["IsTabIdValid"] = |
| 1694 &TestingAutomationProvider::IsTabIdValid; | 1694 &TestingAutomationProvider::IsTabIdValid; |
| 1695 handler_map["DoesAutomationObjectExist"] = | 1695 handler_map["DoesAutomationObjectExist"] = |
| 1696 &TestingAutomationProvider::DoesAutomationObjectExist; | 1696 &TestingAutomationProvider::DoesAutomationObjectExist; |
| 1697 handler_map["CloseTab"] = | 1697 handler_map["CloseTab"] = |
| 1698 &TestingAutomationProvider::CloseTabJSON; | 1698 &TestingAutomationProvider::CloseTabJSON; |
| 1699 handler_map["SetViewBounds"] = | 1699 handler_map["SetViewBounds"] = |
| 1700 &TestingAutomationProvider::SetViewBounds; | 1700 &TestingAutomationProvider::SetViewBounds; |
| 1701 handler_map["MaximizeView"] = |
| 1702 &TestingAutomationProvider::MaximizeView; |
| 1701 handler_map["WebkitMouseMove"] = | 1703 handler_map["WebkitMouseMove"] = |
| 1702 &TestingAutomationProvider::WebkitMouseMove; | 1704 &TestingAutomationProvider::WebkitMouseMove; |
| 1703 handler_map["WebkitMouseClick"] = | 1705 handler_map["WebkitMouseClick"] = |
| 1704 &TestingAutomationProvider::WebkitMouseClick; | 1706 &TestingAutomationProvider::WebkitMouseClick; |
| 1705 handler_map["WebkitMouseDrag"] = | 1707 handler_map["WebkitMouseDrag"] = |
| 1706 &TestingAutomationProvider::WebkitMouseDrag; | 1708 &TestingAutomationProvider::WebkitMouseDrag; |
| 1707 handler_map["WebkitMouseButtonUp"] = | 1709 handler_map["WebkitMouseButtonUp"] = |
| 1708 &TestingAutomationProvider::WebkitMouseButtonUp; | 1710 &TestingAutomationProvider::WebkitMouseButtonUp; |
| 1709 handler_map["WebkitMouseButtonDown"] = | 1711 handler_map["WebkitMouseButtonDown"] = |
| 1710 &TestingAutomationProvider::WebkitMouseButtonDown; | 1712 &TestingAutomationProvider::WebkitMouseButtonDown; |
| (...skipping 4767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6478 !args->GetInteger("bounds.height", &height)) { | 6480 !args->GetInteger("bounds.height", &height)) { |
| 6479 reply.SendError("Missing or invalid 'bounds'"); | 6481 reply.SendError("Missing or invalid 'bounds'"); |
| 6480 return; | 6482 return; |
| 6481 } | 6483 } |
| 6482 Browser* browser; | 6484 Browser* browser; |
| 6483 std::string error; | 6485 std::string error; |
| 6484 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { | 6486 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 6485 reply.SendError(Error(automation::kInvalidId, error)); | 6487 reply.SendError(Error(automation::kInvalidId, error)); |
| 6486 return; | 6488 return; |
| 6487 } | 6489 } |
| 6488 browser->window()->SetBounds(gfx::Rect(x, y, width, height)); | 6490 BrowserWindow* browser_window = browser->window(); |
| 6491 if (browser_window->IsMaximized()) { |
| 6492 browser_window->Restore(); |
| 6493 } |
| 6494 browser_window->SetBounds(gfx::Rect(x, y, width, height)); |
| 6489 reply.SendSuccess(NULL); | 6495 reply.SendSuccess(NULL); |
| 6490 } | 6496 } |
| 6491 | 6497 |
| 6498 void TestingAutomationProvider::MaximizeView( |
| 6499 base::DictionaryValue* args, |
| 6500 IPC::Message* reply_message) { |
| 6501 Browser* browser; |
| 6502 std::string error; |
| 6503 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 6504 AutomationJSONReply(this, reply_message) |
| 6505 .SendError(Error(automation::kInvalidId, error)); |
| 6506 return; |
| 6507 } |
| 6508 new WindowMaximizedObserver(this, reply_message); |
| 6509 browser->window()->Maximize(); |
| 6510 } |
| 6511 |
| 6492 void TestingAutomationProvider::ActivateTabJSON( | 6512 void TestingAutomationProvider::ActivateTabJSON( |
| 6493 DictionaryValue* args, | 6513 DictionaryValue* args, |
| 6494 IPC::Message* reply_message) { | 6514 IPC::Message* reply_message) { |
| 6495 if (SendErrorIfModalDialogActive(this, reply_message)) | 6515 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 6496 return; | 6516 return; |
| 6497 | 6517 |
| 6498 AutomationJSONReply reply(this, reply_message); | 6518 AutomationJSONReply reply(this, reply_message); |
| 6499 Browser* browser; | 6519 Browser* browser; |
| 6500 WebContents* web_contents; | 6520 WebContents* web_contents; |
| 6501 std::string error; | 6521 std::string error; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6642 } | 6662 } |
| 6643 | 6663 |
| 6644 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6664 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
| 6645 WebContents* tab) { | 6665 WebContents* tab) { |
| 6646 if (browser->GetSelectedWebContents() != tab || | 6666 if (browser->GetSelectedWebContents() != tab || |
| 6647 browser != BrowserList::GetLastActive()) { | 6667 browser != BrowserList::GetLastActive()) { |
| 6648 browser->ActivateTabAt(browser->GetIndexOfController(&tab->GetController()), | 6668 browser->ActivateTabAt(browser->GetIndexOfController(&tab->GetController()), |
| 6649 true /* user_gesture */); | 6669 true /* user_gesture */); |
| 6650 } | 6670 } |
| 6651 } | 6671 } |
| OLD | NEW |