Chromium Code Reviews| 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 2d80022f1fdb929db4aa1e9fc574a1317e720851..5d01e58d0a449f500fb06c5d449c8877471903c3 100644 |
| --- a/chrome/browser/automation/testing_automation_provider.cc |
| +++ b/chrome/browser/automation/testing_automation_provider.cc |
| @@ -104,6 +104,7 @@ |
| #include "ui/base/events.h" |
| #include "ui/base/keycodes/keyboard_codes.h" |
| #include "ui/base/message_box_flags.h" |
| +#include "webkit/glue/webdropdata.h" |
| #include "webkit/plugins/npapi/plugin_list.h" |
| namespace { |
| @@ -1080,6 +1081,60 @@ void TestingAutomationProvider::WebkitMouseDoubleClick( |
| tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
| } |
| +void TestingAutomationProvider::SetFilePathsToFileUploadControl( |
| + DictionaryValue* args, IPC::Message* reply_message) { |
| + TabContents* tab_contents; |
| + std::string error; |
| + if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
| + AutomationJSONReply(this, reply_message).SendError(error); |
| + return; |
| + } |
| + |
| + int x, y; |
| + if (!args->GetInteger("x", &x) || |
| + !args->GetInteger("y", &y)) { |
|
kkania
2011/05/23 18:43:49
put this on the line before
nodchip
2011/05/26 01:14:53
Done.
|
| + AutomationJSONReply(this, reply_message) |
| + .SendError("(X,Y) coordinates missing or invalid"); |
| + return; |
| + } |
| + |
| + ListValue* paths = NULL; |
| + if (!args->GetList("paths", &paths)) { |
| + AutomationJSONReply(this, reply_message) |
| + .SendError("paths missing or invalid"); |
| + return; |
| + } |
| + |
| + // Emulate drag and drop to set the file paths to the file upload control. |
| + WebDropData drop_data; |
| + for (size_t path_index = 0; path_index < paths->GetSize(); ++path_index) { |
| + std::string path; |
| + if (!paths->GetString(path_index, &path)) { |
|
kkania
2011/05/23 18:43:49
make path a string16 and GetString will do the UTF
nodchip
2011/05/26 01:14:53
Done.
|
| + AutomationJSONReply(this, reply_message) |
| + .SendError("path missing or invalid"); |
| + return; |
| + } |
| + |
| + drop_data.filenames.push_back(UTF8ToUTF16(path)); |
| + } |
| + |
| + const gfx::Point client(x, y); |
| + // Currently DragTarget*** ignore the screen argument. |
|
kkania
2011/05/23 18:43:49
do you think it will always remain like that? do t
nodchip
2011/05/26 01:14:53
I think it will always remain because it does not
|
| + // TODO(hnoda): Calculate the screen coordinate using WindowGetViewBounds(). |
| + const gfx::Point screen; |
| + |
| + int operations = 0; |
| + operations |= WebKit::WebDragOperationCopy; |
| + operations |= WebKit::WebDragOperationLink; |
| + operations |= WebKit::WebDragOperationMove; |
| + |
| + RenderViewHost* host = tab_contents->render_view_host(); |
| + host->DragTargetDragEnter(drop_data, client, screen, |
| + (WebKit::WebDragOperationsMask)operations); |
|
kkania
2011/05/23 18:43:49
don't use c-style casting
nodchip
2011/05/26 01:14:53
Done.
|
| + host->DragTargetDrop(client, screen); |
| + AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
|
kkania
2011/05/23 18:43:49
we should wait till the renderer processes the dra
nodchip
2011/05/26 01:14:53
Done. But we have to add additional IPC Message.
|
| +} |
| + |
| void TestingAutomationProvider::GetTabCount(int handle, int* tab_count) { |
| *tab_count = -1; // -1 is the error code |
| @@ -2218,6 +2273,8 @@ void TestingAutomationProvider::SendJSONRequest(int handle, |
| &TestingAutomationProvider::WebkitMouseButtonDown; |
| handler_map["WebkitMouseDoubleClick"] = |
| &TestingAutomationProvider::WebkitMouseDoubleClick; |
| + handler_map["SetFilePathToFileUploadControl"] = |
| + &TestingAutomationProvider::SetFilePathsToFileUploadControl; |
| handler_map["SendWebkitKeyEvent"] = |
| &TestingAutomationProvider::SendWebkitKeyEvent; |
| handler_map["SendOSLevelKeyEventToTab"] = |