| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 #include "chrome/common/chrome_switches.h" | 111 #include "chrome/common/chrome_switches.h" |
| 112 #include "chrome/common/chrome_view_type.h" | 112 #include "chrome/common/chrome_view_type.h" |
| 113 #include "chrome/common/extensions/extension.h" | 113 #include "chrome/common/extensions/extension.h" |
| 114 #include "chrome/common/extensions/extension_action.h" | 114 #include "chrome/common/extensions/extension_action.h" |
| 115 #include "chrome/common/extensions/url_pattern.h" | 115 #include "chrome/common/extensions/url_pattern.h" |
| 116 #include "chrome/common/extensions/url_pattern_set.h" | 116 #include "chrome/common/extensions/url_pattern_set.h" |
| 117 #include "chrome/common/pref_names.h" | 117 #include "chrome/common/pref_names.h" |
| 118 #include "chrome/common/render_messages.h" | 118 #include "chrome/common/render_messages.h" |
| 119 #include "chrome/common/url_constants.h" | 119 #include "chrome/common/url_constants.h" |
| 120 #include "content/browser/renderer_host/render_view_host.h" | 120 #include "content/browser/renderer_host/render_view_host.h" |
| 121 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 121 #include "content/browser/tab_contents/interstitial_page.h" | 122 #include "content/browser/tab_contents/interstitial_page.h" |
| 122 #include "content/public/browser/browser_child_process_host_iterator.h" | 123 #include "content/public/browser/browser_child_process_host_iterator.h" |
| 123 #include "content/public/browser/child_process_data.h" | 124 #include "content/public/browser/child_process_data.h" |
| 124 #include "content/public/browser/favicon_status.h" | 125 #include "content/public/browser/favicon_status.h" |
| 125 #include "content/public/browser/navigation_entry.h" | 126 #include "content/public/browser/navigation_entry.h" |
| 126 #include "content/public/browser/notification_service.h" | 127 #include "content/public/browser/notification_service.h" |
| 127 #include "content/public/browser/plugin_service.h" | 128 #include "content/public/browser/plugin_service.h" |
| 128 #include "content/public/browser/render_process_host.h" | 129 #include "content/public/browser/render_process_host.h" |
| 129 #include "content/public/browser/ssl_status.h" | 130 #include "content/public/browser/ssl_status.h" |
| 130 #include "content/public/browser/web_contents.h" | 131 #include "content/public/browser/web_contents.h" |
| (...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 handler_map["GetTabIds"] = | 2333 handler_map["GetTabIds"] = |
| 2333 &TestingAutomationProvider::GetTabIds; | 2334 &TestingAutomationProvider::GetTabIds; |
| 2334 handler_map["GetViews"] = | 2335 handler_map["GetViews"] = |
| 2335 &TestingAutomationProvider::GetViews; | 2336 &TestingAutomationProvider::GetViews; |
| 2336 handler_map["IsTabIdValid"] = | 2337 handler_map["IsTabIdValid"] = |
| 2337 &TestingAutomationProvider::IsTabIdValid; | 2338 &TestingAutomationProvider::IsTabIdValid; |
| 2338 handler_map["DoesAutomationObjectExist"] = | 2339 handler_map["DoesAutomationObjectExist"] = |
| 2339 &TestingAutomationProvider::DoesAutomationObjectExist; | 2340 &TestingAutomationProvider::DoesAutomationObjectExist; |
| 2340 handler_map["CloseTab"] = | 2341 handler_map["CloseTab"] = |
| 2341 &TestingAutomationProvider::CloseTabJSON; | 2342 &TestingAutomationProvider::CloseTabJSON; |
| 2343 handler_map["SetViewBounds"] = |
| 2344 &TestingAutomationProvider::SetViewBounds; |
| 2342 handler_map["WebkitMouseMove"] = | 2345 handler_map["WebkitMouseMove"] = |
| 2343 &TestingAutomationProvider::WebkitMouseMove; | 2346 &TestingAutomationProvider::WebkitMouseMove; |
| 2344 handler_map["WebkitMouseClick"] = | 2347 handler_map["WebkitMouseClick"] = |
| 2345 &TestingAutomationProvider::WebkitMouseClick; | 2348 &TestingAutomationProvider::WebkitMouseClick; |
| 2346 handler_map["WebkitMouseDrag"] = | 2349 handler_map["WebkitMouseDrag"] = |
| 2347 &TestingAutomationProvider::WebkitMouseDrag; | 2350 &TestingAutomationProvider::WebkitMouseDrag; |
| 2348 handler_map["WebkitMouseButtonUp"] = | 2351 handler_map["WebkitMouseButtonUp"] = |
| 2349 &TestingAutomationProvider::WebkitMouseButtonUp; | 2352 &TestingAutomationProvider::WebkitMouseButtonUp; |
| 2350 handler_map["WebkitMouseButtonDown"] = | 2353 handler_map["WebkitMouseButtonDown"] = |
| 2351 &TestingAutomationProvider::WebkitMouseButtonDown; | 2354 &TestingAutomationProvider::WebkitMouseButtonDown; |
| (...skipping 3932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6284 void TestingAutomationProvider::ExecuteJavascriptJSON( | 6287 void TestingAutomationProvider::ExecuteJavascriptJSON( |
| 6285 DictionaryValue* args, | 6288 DictionaryValue* args, |
| 6286 IPC::Message* reply_message) { | 6289 IPC::Message* reply_message) { |
| 6287 if (SendErrorIfModalDialogActive(this, reply_message)) | 6290 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 6288 return; | 6291 return; |
| 6289 | 6292 |
| 6290 string16 frame_xpath, javascript; | 6293 string16 frame_xpath, javascript; |
| 6291 std::string error; | 6294 std::string error; |
| 6292 RenderViewHost* render_view; | 6295 RenderViewHost* render_view; |
| 6293 if (!GetRenderViewFromJSONArgs(args, profile(), &render_view, &error)) { | 6296 if (!GetRenderViewFromJSONArgs(args, profile(), &render_view, &error)) { |
| 6294 AutomationJSONReply(this, reply_message).SendError(error); | 6297 AutomationJSONReply(this, reply_message).SendError( |
| 6298 Error(automation::kInvalidId, error)); |
| 6295 return; | 6299 return; |
| 6296 } | 6300 } |
| 6297 if (!args->GetString("frame_xpath", &frame_xpath)) { | 6301 if (!args->GetString("frame_xpath", &frame_xpath)) { |
| 6298 AutomationJSONReply(this, reply_message) | 6302 AutomationJSONReply(this, reply_message) |
| 6299 .SendError("'frame_xpath' missing or invalid"); | 6303 .SendError("'frame_xpath' missing or invalid"); |
| 6300 return; | 6304 return; |
| 6301 } | 6305 } |
| 6302 if (!args->GetString("javascript", &javascript)) { | 6306 if (!args->GetString("javascript", &javascript)) { |
| 6303 AutomationJSONReply(this, reply_message) | 6307 AutomationJSONReply(this, reply_message) |
| 6304 .SendError("'javascript' missing or invalid"); | 6308 .SendError("'javascript' missing or invalid"); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6574 // Close other types of views asynchronously. | 6578 // Close other types of views asynchronously. |
| 6575 RenderViewHost* view; | 6579 RenderViewHost* view; |
| 6576 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { | 6580 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
| 6577 reply.SendError(error); | 6581 reply.SendError(error); |
| 6578 return; | 6582 return; |
| 6579 } | 6583 } |
| 6580 view->ClosePage(); | 6584 view->ClosePage(); |
| 6581 reply.SendSuccess(NULL); | 6585 reply.SendSuccess(NULL); |
| 6582 } | 6586 } |
| 6583 | 6587 |
| 6588 void TestingAutomationProvider::SetViewBounds( |
| 6589 base::DictionaryValue* args, |
| 6590 IPC::Message* reply_message) { |
| 6591 AutomationJSONReply reply(this, reply_message); |
| 6592 int x, y, width, height; |
| 6593 if (!args->GetInteger("bounds.x", &x) || |
| 6594 !args->GetInteger("bounds.y", &y) || |
| 6595 !args->GetInteger("bounds.width", &width) || |
| 6596 !args->GetInteger("bounds.height", &height)) { |
| 6597 reply.SendError("Missing or invalid 'bounds'"); |
| 6598 return; |
| 6599 } |
| 6600 Browser* browser; |
| 6601 std::string error; |
| 6602 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 6603 reply.SendError(Error(automation::kInvalidId, error)); |
| 6604 return; |
| 6605 } |
| 6606 browser->window()->SetBounds(gfx::Rect(x, y, width, height)); |
| 6607 reply.SendSuccess(NULL); |
| 6608 } |
| 6609 |
| 6584 void TestingAutomationProvider::ActivateTabJSON( | 6610 void TestingAutomationProvider::ActivateTabJSON( |
| 6585 DictionaryValue* args, | 6611 DictionaryValue* args, |
| 6586 IPC::Message* reply_message) { | 6612 IPC::Message* reply_message) { |
| 6587 if (SendErrorIfModalDialogActive(this, reply_message)) | 6613 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 6588 return; | 6614 return; |
| 6589 | 6615 |
| 6590 AutomationJSONReply reply(this, reply_message); | 6616 AutomationJSONReply reply(this, reply_message); |
| 6591 Browser* browser; | 6617 Browser* browser; |
| 6592 WebContents* web_contents; | 6618 WebContents* web_contents; |
| 6593 std::string error; | 6619 std::string error; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6858 | 6884 |
| 6859 Send(reply_message_); | 6885 Send(reply_message_); |
| 6860 redirect_query_ = 0; | 6886 redirect_query_ = 0; |
| 6861 reply_message_ = NULL; | 6887 reply_message_ = NULL; |
| 6862 } | 6888 } |
| 6863 | 6889 |
| 6864 void TestingAutomationProvider::OnRemoveProvider() { | 6890 void TestingAutomationProvider::OnRemoveProvider() { |
| 6865 if (g_browser_process) | 6891 if (g_browser_process) |
| 6866 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6892 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6867 } | 6893 } |
| OLD | NEW |