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 0b4ff3501297bfa51781c9f348d314447f7c897c..67e963278a99c6b3260c7e7fef1bc53e08f664ff 100644 |
--- a/chrome/browser/automation/testing_automation_provider.cc |
+++ b/chrome/browser/automation/testing_automation_provider.cc |
@@ -934,9 +934,9 @@ void TestingAutomationProvider::WebkitMouseClick(DictionaryValue* args, |
if (SendErrorIfModalDialogActive(this, reply_message)) |
return; |
- TabContents* tab_contents; |
+ RenderViewHost* view; |
std::string error; |
- if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
+ if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
AutomationJSONReply(this, reply_message).SendError(error); |
return; |
} |
@@ -970,12 +970,12 @@ void TestingAutomationProvider::WebkitMouseClick(DictionaryValue* args, |
mouse_event.type = WebKit::WebInputEvent::MouseDown; |
mouse_event.clickCount = 1; |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
mouse_event.type = WebKit::WebInputEvent::MouseUp; |
new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
1); |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
} |
void TestingAutomationProvider::WebkitMouseMove( |
@@ -983,9 +983,9 @@ void TestingAutomationProvider::WebkitMouseMove( |
if (SendErrorIfModalDialogActive(this, reply_message)) |
return; |
- TabContents* tab_contents; |
+ RenderViewHost* view; |
std::string error; |
- if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
+ if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
AutomationJSONReply(this, reply_message).SendError(error); |
return; |
} |
@@ -1001,7 +1001,7 @@ void TestingAutomationProvider::WebkitMouseMove( |
mouse_event.type = WebKit::WebInputEvent::MouseMove; |
new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
1); |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
} |
void TestingAutomationProvider::WebkitMouseDrag(DictionaryValue* args, |
@@ -1009,9 +1009,9 @@ void TestingAutomationProvider::WebkitMouseDrag(DictionaryValue* args, |
if (SendErrorIfModalDialogActive(this, reply_message)) |
return; |
- TabContents* tab_contents; |
+ RenderViewHost* view; |
std::string error; |
- if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
+ if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
AutomationJSONReply(this, reply_message).SendError(error); |
return; |
} |
@@ -1031,29 +1031,27 @@ void TestingAutomationProvider::WebkitMouseDrag(DictionaryValue* args, |
// Step 1- Move the mouse to the start position. |
mouse_event.x = start_x; |
mouse_event.y = start_y; |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
// Step 2- Left click mouse down, the mouse button is fixed. |
mouse_event.type = WebKit::WebInputEvent::MouseDown; |
mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
mouse_event.clickCount = 1; |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
// Step 3 - Move the mouse to the end position. |
- // TODO(JMikhail): See if we should simulate the by not making such |
- // a drastic jump by placing incrmental stops along the way. |
mouse_event.type = WebKit::WebInputEvent::MouseMove; |
mouse_event.x = end_x; |
mouse_event.y = end_y; |
mouse_event.clickCount = 0; |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
// Step 4 - Release the left mouse button. |
mouse_event.type = WebKit::WebInputEvent::MouseUp; |
mouse_event.clickCount = 1; |
new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
1); |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
} |
void TestingAutomationProvider::WebkitMouseButtonDown( |
@@ -1061,9 +1059,9 @@ void TestingAutomationProvider::WebkitMouseButtonDown( |
if (SendErrorIfModalDialogActive(this, reply_message)) |
return; |
- TabContents* tab_contents; |
+ RenderViewHost* view; |
std::string error; |
- if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
+ if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
AutomationJSONReply(this, reply_message).SendError(error); |
return; |
} |
@@ -1081,7 +1079,7 @@ void TestingAutomationProvider::WebkitMouseButtonDown( |
mouse_event.clickCount = 1; |
new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
1); |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
} |
void TestingAutomationProvider::WebkitMouseButtonUp( |
@@ -1089,9 +1087,9 @@ void TestingAutomationProvider::WebkitMouseButtonUp( |
if (SendErrorIfModalDialogActive(this, reply_message)) |
return; |
- TabContents* tab_contents; |
+ RenderViewHost* view; |
std::string error; |
- if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
+ if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
AutomationJSONReply(this, reply_message).SendError(error); |
return; |
} |
@@ -1109,7 +1107,7 @@ void TestingAutomationProvider::WebkitMouseButtonUp( |
mouse_event.clickCount = 1; |
new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
1); |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
} |
void TestingAutomationProvider::WebkitMouseDoubleClick( |
@@ -1117,9 +1115,9 @@ void TestingAutomationProvider::WebkitMouseDoubleClick( |
if (SendErrorIfModalDialogActive(this, reply_message)) |
return; |
- TabContents* tab_contents; |
+ RenderViewHost* view; |
std::string error; |
- if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
+ if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
AutomationJSONReply(this, reply_message).SendError(error); |
return; |
} |
@@ -1135,19 +1133,19 @@ void TestingAutomationProvider::WebkitMouseDoubleClick( |
mouse_event.type = WebKit::WebInputEvent::MouseDown; |
mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
mouse_event.clickCount = 1; |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
mouse_event.type = WebKit::WebInputEvent::MouseUp; |
new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
2); |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
mouse_event.type = WebKit::WebInputEvent::MouseDown; |
mouse_event.clickCount = 2; |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
mouse_event.type = WebKit::WebInputEvent::MouseUp; |
- tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
+ view->ForwardMouseEvent(mouse_event); |
} |
void TestingAutomationProvider::DragAndDropFilePaths( |
@@ -1155,9 +1153,9 @@ void TestingAutomationProvider::DragAndDropFilePaths( |
if (SendErrorIfModalDialogActive(this, reply_message)) |
return; |
- TabContents* tab_contents; |
+ RenderViewHost* view; |
std::string error; |
- if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
+ if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
AutomationJSONReply(this, reply_message).SendError(error); |
return; |
} |
@@ -1199,12 +1197,11 @@ void TestingAutomationProvider::DragAndDropFilePaths( |
operations |= WebKit::WebDragOperationLink; |
operations |= WebKit::WebDragOperationMove; |
- RenderViewHost* host = tab_contents->render_view_host(); |
- host->DragTargetDragEnter( |
+ view->DragTargetDragEnter( |
drop_data, client, screen, |
static_cast<WebKit::WebDragOperationsMask>(operations)); |
new DragTargetDropAckNotificationObserver(this, reply_message); |
- host->DragTargetDrop(client, screen); |
+ view->DragTargetDrop(client, screen); |
} |
void TestingAutomationProvider::GetTabCount(int handle, int* tab_count) { |
@@ -2265,10 +2262,6 @@ void TestingAutomationProvider::SendJSONRequest(int handle, |
&TestingAutomationProvider::GoBack; |
handler_map["Reload"] = |
&TestingAutomationProvider::ReloadJSON; |
- handler_map["GetTabURL"] = |
- &TestingAutomationProvider::GetTabURLJSON; |
- handler_map["GetTabTitle"] = |
- &TestingAutomationProvider::GetTabTitleJSON; |
handler_map["CaptureEntirePage"] = |
&TestingAutomationProvider::CaptureEntirePageJSON; |
handler_map["GetCookies"] = |
@@ -2279,8 +2272,12 @@ void TestingAutomationProvider::SendJSONRequest(int handle, |
&TestingAutomationProvider::SetCookieJSON; |
handler_map["GetTabIds"] = |
&TestingAutomationProvider::GetTabIds; |
+ handler_map["GetViews"] = |
+ &TestingAutomationProvider::GetViews; |
handler_map["IsTabIdValid"] = |
&TestingAutomationProvider::IsTabIdValid; |
+ handler_map["DoesViewExist"] = |
+ &TestingAutomationProvider::DoesViewExist; |
handler_map["CloseTab"] = |
&TestingAutomationProvider::CloseTabJSON; |
handler_map["WebkitMouseMove"] = |
@@ -5509,13 +5506,13 @@ void TestingAutomationProvider::SendWebkitKeyEvent( |
return; |
} |
- TabContents* tab_contents; |
- if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
+ RenderViewHost* view; |
+ if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
AutomationJSONReply(this, reply_message).SendError(error); |
return; |
} |
new InputEventAckNotificationObserver(this, reply_message, event.type, 1); |
- tab_contents->render_view_host()->ForwardKeyboardEvent(event); |
+ view->ForwardKeyboardEvent(event); |
} |
void TestingAutomationProvider::SendOSLevelKeyEventToTab( |
@@ -5933,8 +5930,8 @@ void TestingAutomationProvider::ExecuteJavascriptJSON( |
string16 frame_xpath, javascript; |
std::string error; |
- TabContents* tab_contents; |
- if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
+ RenderViewHost* render_view; |
+ if (!GetRenderViewFromJSONArgs(args, profile(), &render_view, &error)) { |
AutomationJSONReply(this, reply_message).SendError(error); |
return; |
} |
@@ -5951,7 +5948,7 @@ void TestingAutomationProvider::ExecuteJavascriptJSON( |
new DomOperationMessageSender(this, reply_message, true); |
ExecuteJavascriptInRenderViewFrame(frame_xpath, javascript, reply_message, |
- tab_contents->render_view_host()); |
+ render_view); |
} |
void TestingAutomationProvider::ExecuteJavascriptInRenderView( |
@@ -6060,36 +6057,6 @@ void TestingAutomationProvider::ReloadJSON( |
controller.Reload(false); |
} |
-void TestingAutomationProvider::GetTabURLJSON( |
- DictionaryValue* args, |
- IPC::Message* reply_message) { |
- AutomationJSONReply reply(this, reply_message); |
- TabContents* tab_contents; |
- std::string error; |
- if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
- reply.SendError(error); |
- return; |
- } |
- DictionaryValue dict; |
- dict.SetString("url", tab_contents->GetURL().possibly_invalid_spec()); |
- reply.SendSuccess(&dict); |
-} |
- |
-void TestingAutomationProvider::GetTabTitleJSON( |
- DictionaryValue* args, |
- IPC::Message* reply_message) { |
- AutomationJSONReply reply(this, reply_message); |
- TabContents* tab_contents; |
- std::string error; |
- if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
- reply.SendError(error); |
- return; |
- } |
- DictionaryValue dict; |
- dict.SetString("title", tab_contents->GetTitle()); |
- reply.SendSuccess(&dict); |
-} |
- |
void TestingAutomationProvider::CaptureEntirePageJSON( |
DictionaryValue* args, |
IPC::Message* reply_message) { |
@@ -6157,6 +6124,41 @@ void TestingAutomationProvider::GetTabIds( |
AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
} |
+void TestingAutomationProvider::GetViews( |
+ DictionaryValue* args, IPC::Message* reply_message) { |
+ ListValue* view_list = new ListValue(); |
+ BrowserList::const_iterator browser_iter = BrowserList::begin(); |
+ for (; browser_iter != BrowserList::end(); ++browser_iter) { |
+ Browser* browser = *browser_iter; |
+ for (int i = 0; i < browser->tab_count(); ++i) { |
+ DictionaryValue* dict = new DictionaryValue(); |
+ AutomationId id = automation_util::GetIdForTab( |
+ browser->GetTabContentsWrapperAt(i)); |
+ dict->Set("view_id", id.ToValue()); |
+ view_list->Append(dict); |
+ } |
+ } |
+ |
+ ExtensionProcessManager* extension_mgr = |
+ profile()->GetExtensionProcessManager(); |
+ ExtensionProcessManager::const_iterator iter; |
+ for (iter = extension_mgr->begin(); iter != extension_mgr->end(); |
+ ++iter) { |
+ ExtensionHost* host = *iter; |
+ if (host->extension_host_type() != chrome::VIEW_TYPE_EXTENSION_POPUP) |
+ continue; |
+ DictionaryValue* dict = new DictionaryValue(); |
+ AutomationId id = automation_util::GetIdForExtensionPopup( |
+ host->extension()); |
+ dict->Set("view_id", id.ToValue()); |
+ dict->SetString("extension_id", host->extension()->id()); |
+ view_list->Append(dict); |
+ } |
+ DictionaryValue dict; |
+ dict.Set("views", view_list); |
+ AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
+} |
+ |
void TestingAutomationProvider::IsTabIdValid( |
DictionaryValue* args, IPC::Message* reply_message) { |
AutomationJSONReply reply(this, reply_message); |
@@ -6182,6 +6184,22 @@ void TestingAutomationProvider::IsTabIdValid( |
reply.SendSuccess(&dict); |
} |
+void TestingAutomationProvider::DoesViewExist( |
+ DictionaryValue* args, IPC::Message* reply_message) { |
+ AutomationJSONReply reply(this, reply_message); |
+ AutomationId id; |
+ std::string error_msg; |
+ if (!GetAutomationIdFromJSONArgs(args, &id, &error_msg)) { |
+ reply.SendError(error_msg); |
+ return; |
+ } |
+ DictionaryValue dict; |
+ dict.SetBoolean( |
+ "does_exist", |
+ automation_util::DoesObjectWithIdExist(id, profile())); |
+ reply.SendSuccess(&dict); |
+} |
+ |
void TestingAutomationProvider::CloseTabJSON( |
DictionaryValue* args, IPC::Message* reply_message) { |
AutomationJSONReply reply(this, reply_message); |