Index: chrome/browser/automation/testing_automation_provider.cc |
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc |
index 8d1a45bc2da2d36441d7680be8dff4670f94328b..f92087fac05ce9da33f69d25f098c8c4971dc3b5 100644 |
--- a/chrome/browser/automation/testing_automation_provider.cc |
+++ b/chrome/browser/automation/testing_automation_provider.cc |
@@ -109,6 +109,8 @@ |
#include "chrome/browser/ui/omnibox/omnibox_view.h" |
#include "chrome/browser/ui/search_engines/keyword_editor_controller.h" |
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
+#include "chrome/common/automation_constants.h" |
+#include "chrome/common/automation_events.h" |
#include "chrome/common/automation_id.h" |
#include "chrome/common/automation_messages.h" |
#include "chrome/common/chrome_constants.h" |
@@ -5910,15 +5912,44 @@ void TestingAutomationProvider::SendOSLevelKeyEventToTab( |
} |
} |
+namespace { |
+ |
+bool ReadScriptEvaluationRequestList( |
+ base::Value* value, |
+ std::vector<ScriptEvaluationRequest>* list, |
+ std::string* error_msg) { |
+ ListValue* request_list; |
+ if (!value->GetAsList(&request_list)) { |
+ return false; |
+ } |
dennis_jeffrey
2012/05/08 19:18:49
no need for curly braces
kkania
2012/05/09 18:19:59
Done.
|
+ for (size_t i = 0; i < request_list->GetSize(); ++i) { |
+ DictionaryValue* request_dict; |
+ if (!request_list->GetDictionary(i, &request_dict)) { |
+ *error_msg = "Script evaluation request was not a dictionary"; |
+ return false; |
+ } |
+ ScriptEvaluationRequest request; |
+ if (!request_dict->GetString("script", &request.script) || |
+ !request_dict->GetString("frame_xpath", &request.frame_xpath)) { |
+ *error_msg = "Script evaluation request was invalid"; |
+ return false; |
+ } |
+ list->push_back(request); |
+ } |
+ return true; |
+} |
+ |
+} // namespace |
+ |
void TestingAutomationProvider::ProcessWebMouseEvent( |
DictionaryValue* args, |
IPC::Message* reply_message) { |
if (SendErrorIfModalDialogActive(this, reply_message)) |
return; |
- RenderViewHost* view; |
+ content::WebContents* web_contents; |
std::string error; |
- if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
+ if (!GetTabFromJSONArgs(args, &web_contents, &error)) { |
AutomationJSONReply(this, reply_message).SendError(error); |
return; |
} |
@@ -5977,9 +6008,28 @@ void TestingAutomationProvider::ProcessWebMouseEvent( |
if (modifiers & automation::kMetaKeyMask) |
event.modifiers |= WebKit::WebInputEvent::MetaKey; |
- view->ForwardMouseEvent(event); |
- new InputEventAckNotificationObserver(this, reply_message, event.type, |
- 1); |
+ TabContentsWrapper* tab_contents = |
+ TabContentsWrapper::GetCurrentWrapperForContents(web_contents); |
+ if (!tab_contents) { |
dennis_jeffrey
2012/05/08 19:18:49
Could you add a comment to explain the difference
kkania
2012/05/09 18:19:59
Got rid of this hack. I didn't actually need it an
|
+ web_contents->GetRenderViewHost()->ForwardMouseEvent(event); |
+ new InputEventAckNotificationObserver(this, reply_message, event.type, 1); |
+ return; |
+ } |
+ |
+ AutomationMouseEvent automation_event; |
+ automation_event.mouse_event = event; |
+ Value* location_script_chain_value; |
+ if (args->Get("location_script_chain", &location_script_chain_value)) { |
+ if (!ReadScriptEvaluationRequestList( |
+ location_script_chain_value, |
+ &automation_event.location_script_chain, |
+ &error)) { |
+ AutomationJSONReply(this, reply_message).SendError(error); |
+ return; |
+ } |
+ } |
+ tab_contents->automation_tab_helper()->ProcessMouseEvent(automation_event); |
+ new MouseEventProcessedObserver(this, reply_message, tab_contents); |
} |
namespace { |