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 afc251a4d660590022094a732d548c3ad5f630a6..c67110add500a5bda23cec69c1ef4c25ba959d36 100644 |
--- a/chrome/browser/automation/testing_automation_provider.cc |
+++ b/chrome/browser/automation/testing_automation_provider.cc |
@@ -2316,6 +2316,16 @@ void TestingAutomationProvider::SendJSONRequest(int handle, |
handler_map["SetPrefs"] = &TestingAutomationProvider::SetPrefs; |
handler_map["ExecuteJavascript"] = |
&TestingAutomationProvider::ExecuteJavascriptJSON; |
+ handler_map["AddRaisedEventObserver"] = |
+ &TestingAutomationProvider::AddRaisedEventObserver; |
+ handler_map["GetEvent"] = |
+ &TestingAutomationProvider::GetEvent; |
+ handler_map["RemoveEventObserver"] = |
+ &TestingAutomationProvider::RemoveEventObserver; |
+ handler_map["ClearEvents"] = |
+ &TestingAutomationProvider::ClearEvents; |
+ handler_map["ClearEventObservers"] = |
+ &TestingAutomationProvider::ClearEventObservers; |
handler_map["ExecuteJavascriptInRenderView"] = |
&TestingAutomationProvider::ExecuteJavascriptInRenderView; |
handler_map["GoForward"] = |
@@ -6443,6 +6453,72 @@ void TestingAutomationProvider::ExecuteJavascriptInRenderView( |
rvh); |
} |
+void TestingAutomationProvider::AddRaisedEventObserver( |
+ DictionaryValue* args, |
+ IPC::Message* reply_message) { |
+ if (SendErrorIfModalDialogActive(this, reply_message)) |
+ return; |
+ |
+ std::string event_name; |
+ if (!args->GetString("event_name", &event_name)) { |
+ AutomationJSONReply(this, reply_message) |
+ .SendError("'event_name' missing or invalid"); |
+ return; |
+ } |
+ |
+ RaisedEventObserver* jsobserver = |
Nirnimesh
2012/02/24 23:18:09
if the user fails to call RemoveEventObserver, doe
craigdh
2012/02/27 22:43:38
All un-removed observers are freed when the Testin
|
+ new RaisedEventObserver(automation_event_queue_, event_name); |
+ scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
+ return_value->SetInteger("observer_id", jsobserver->GetId()); |
+ AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
+} |
+ |
+void TestingAutomationProvider::RemoveEventObserver( |
Nirnimesh
2012/02/24 23:18:09
this method name does not have 'Raised'.
craigdh
2012/02/27 22:43:38
It's not intended to, this method can remove any t
|
+ DictionaryValue* args, |
+ IPC::Message* reply_message) { |
+ int observer_id; |
+ if (!args->GetInteger("observer_id", &observer_id)) { |
+ AutomationJSONReply(this, reply_message) |
+ .SendError("'observer_id' missing or invalid"); |
+ return; |
+ } |
+ automation_event_queue_.RemoveObserver(observer_id); |
Nirnimesh
2012/02/24 23:18:09
what if observer_id is invalid?
craigdh
2012/02/27 22:43:38
Then it does not remove anything. Do you think tha
Nirnimesh
2012/02/28 09:13:09
Yes, an error message would be nice.
|
+ AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
+} |
+ |
+void TestingAutomationProvider::ClearEvents( |
Nirnimesh
2012/02/24 23:18:09
Shouldn't this imply ClearEventObservers as well?
craigdh
2012/02/27 22:43:38
I was imagining cases where it may be desirable to
Nirnimesh
2012/02/28 09:13:09
Unless you call ClearEventObservers as well, you c
|
+ DictionaryValue* args, |
+ IPC::Message* reply_message) { |
+ automation_event_queue_.Clear(); |
+ AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
+} |
+ |
+void TestingAutomationProvider::ClearEventObservers( |
+ DictionaryValue* args, |
+ IPC::Message* reply_message) { |
+ automation_event_queue_.ClearObservers(); |
+ AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
+} |
+ |
+void TestingAutomationProvider::GetEvent( |
+ DictionaryValue* args, |
+ IPC::Message* reply_message) { |
+ int observer_id; |
+ bool blocking; |
+ if (!args->GetInteger("observer_id", &observer_id)) { |
+ AutomationJSONReply(this, reply_message) |
+ .SendError("'observer_id' missing or invalid"); |
+ return; |
+ } |
+ if (!args->GetBoolean("blocking", &blocking)) { |
+ AutomationJSONReply(this, reply_message) |
+ .SendError("'blocking' missing or invalid"); |
+ return; |
+ } |
+ |
+ automation_event_queue_.GetEvent(this, reply_message, observer_id, blocking); |
+} |
+ |
void TestingAutomationProvider::GoForward( |
DictionaryValue* args, |
IPC::Message* reply_message) { |