| 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["MaximizeWindow"] = |
| 1702 &TestingAutomationProvider::MaximizeWindow; |
| 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 4780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6491 !args->GetInteger("bounds.height", &height)) { | 6493 !args->GetInteger("bounds.height", &height)) { |
| 6492 reply.SendError("Missing or invalid 'bounds'"); | 6494 reply.SendError("Missing or invalid 'bounds'"); |
| 6493 return; | 6495 return; |
| 6494 } | 6496 } |
| 6495 Browser* browser; | 6497 Browser* browser; |
| 6496 std::string error; | 6498 std::string error; |
| 6497 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { | 6499 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 6498 reply.SendError(Error(automation::kInvalidId, error)); | 6500 reply.SendError(Error(automation::kInvalidId, error)); |
| 6499 return; | 6501 return; |
| 6500 } | 6502 } |
| 6501 browser->window()->SetBounds(gfx::Rect(x, y, width, height)); | 6503 BrowserWindow* browser_window = browser->window(); |
| 6504 if (browser_window->IsMaximized()) { |
| 6505 browser_window->Restore(); |
| 6506 } |
| 6507 browser_window->SetBounds(gfx::Rect(x, y, width, height)); |
| 6502 reply.SendSuccess(NULL); | 6508 reply.SendSuccess(NULL); |
| 6503 } | 6509 } |
| 6504 | 6510 |
| 6511 void TestingAutomationProvider::MaximizeWindow( |
| 6512 base::DictionaryValue* args, |
| 6513 IPC::Message* reply_message) { |
| 6514 AutomationJSONReply reply(this, reply_message); |
| 6515 Browser* browser; |
| 6516 std::string error; |
| 6517 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 6518 reply.SendError(Error(automation::kInvalidId, error)); |
| 6519 return; |
| 6520 } |
| 6521 browser->window()->Maximize(); |
| 6522 reply.SendSuccess(NULL); |
| 6523 } |
| 6524 |
| 6505 void TestingAutomationProvider::ActivateTabJSON( | 6525 void TestingAutomationProvider::ActivateTabJSON( |
| 6506 DictionaryValue* args, | 6526 DictionaryValue* args, |
| 6507 IPC::Message* reply_message) { | 6527 IPC::Message* reply_message) { |
| 6508 if (SendErrorIfModalDialogActive(this, reply_message)) | 6528 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 6509 return; | 6529 return; |
| 6510 | 6530 |
| 6511 AutomationJSONReply reply(this, reply_message); | 6531 AutomationJSONReply reply(this, reply_message); |
| 6512 Browser* browser; | 6532 Browser* browser; |
| 6513 WebContents* web_contents; | 6533 WebContents* web_contents; |
| 6514 std::string error; | 6534 std::string error; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6646 | 6666 |
| 6647 void TestingAutomationProvider::WaitForProcessLauncherThreadToGoIdle( | 6667 void TestingAutomationProvider::WaitForProcessLauncherThreadToGoIdle( |
| 6648 IPC::Message* reply_message) { | 6668 IPC::Message* reply_message) { |
| 6649 new WaitForProcessLauncherThreadToGoIdleObserver(this, reply_message); | 6669 new WaitForProcessLauncherThreadToGoIdleObserver(this, reply_message); |
| 6650 } | 6670 } |
| 6651 | 6671 |
| 6652 void TestingAutomationProvider::OnRemoveProvider() { | 6672 void TestingAutomationProvider::OnRemoveProvider() { |
| 6653 if (g_browser_process) | 6673 if (g_browser_process) |
| 6654 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6674 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6655 } | 6675 } |
| OLD | NEW |