Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 #include "content/browser/renderer_host/render_process_host.h" | 97 #include "content/browser/renderer_host/render_process_host.h" |
| 98 #include "content/browser/renderer_host/render_view_host.h" | 98 #include "content/browser/renderer_host/render_view_host.h" |
| 99 #include "content/browser/tab_contents/interstitial_page.h" | 99 #include "content/browser/tab_contents/interstitial_page.h" |
| 100 #include "content/common/common_param_traits.h" | 100 #include "content/common/common_param_traits.h" |
| 101 #include "content/common/notification_service.h" | 101 #include "content/common/notification_service.h" |
| 102 #include "net/base/cookie_store.h" | 102 #include "net/base/cookie_store.h" |
| 103 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 103 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 104 #include "ui/base/events.h" | 104 #include "ui/base/events.h" |
| 105 #include "ui/base/keycodes/keyboard_codes.h" | 105 #include "ui/base/keycodes/keyboard_codes.h" |
| 106 #include "ui/base/message_box_flags.h" | 106 #include "ui/base/message_box_flags.h" |
| 107 #include "webkit/glue/webdropdata.h" | |
| 107 #include "webkit/plugins/npapi/plugin_list.h" | 108 #include "webkit/plugins/npapi/plugin_list.h" |
| 108 | 109 |
| 109 namespace { | 110 namespace { |
| 110 | 111 |
| 111 void SendMouseClick(int flags) { | 112 void SendMouseClick(int flags) { |
| 112 ui_controls::MouseButton button = ui_controls::LEFT; | 113 ui_controls::MouseButton button = ui_controls::LEFT; |
| 113 if ((flags & ui::EF_LEFT_BUTTON_DOWN) == | 114 if ((flags & ui::EF_LEFT_BUTTON_DOWN) == |
| 114 ui::EF_LEFT_BUTTON_DOWN) { | 115 ui::EF_LEFT_BUTTON_DOWN) { |
| 115 button = ui_controls::LEFT; | 116 button = ui_controls::LEFT; |
| 116 } else if ((flags & ui::EF_RIGHT_BUTTON_DOWN) == | 117 } else if ((flags & ui::EF_RIGHT_BUTTON_DOWN) == |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1073 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1074 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
| 1074 | 1075 |
| 1075 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 1076 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
| 1076 mouse_event.clickCount = 2; | 1077 mouse_event.clickCount = 2; |
| 1077 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1078 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
| 1078 | 1079 |
| 1079 mouse_event.type = WebKit::WebInputEvent::MouseUp; | 1080 mouse_event.type = WebKit::WebInputEvent::MouseUp; |
| 1080 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1081 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); |
| 1081 } | 1082 } |
| 1082 | 1083 |
| 1084 void TestingAutomationProvider::DragAndDropFilePaths( | |
| 1085 DictionaryValue* args, IPC::Message* reply_message) { | |
| 1086 TabContents* tab_contents; | |
| 1087 std::string error; | |
| 1088 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | |
| 1089 AutomationJSONReply(this, reply_message).SendError(error); | |
| 1090 return; | |
| 1091 } | |
| 1092 | |
| 1093 int x, y; | |
| 1094 if (!args->GetInteger("x", &x) || !args->GetInteger("y", &y)) { | |
| 1095 AutomationJSONReply(this, reply_message) | |
| 1096 .SendError("(X,Y) coordinates missing or invalid"); | |
| 1097 return; | |
| 1098 } | |
| 1099 | |
| 1100 ListValue* paths = NULL; | |
| 1101 if (!args->GetList("paths", &paths)) { | |
| 1102 AutomationJSONReply(this, reply_message) | |
| 1103 .SendError("paths missing or invalid"); | |
| 1104 return; | |
| 1105 } | |
| 1106 | |
| 1107 // Emulate drag and drop to set the file paths to the file upload control. | |
| 1108 WebDropData drop_data; | |
| 1109 for (size_t path_index = 0; path_index < paths->GetSize(); ++path_index) { | |
| 1110 string16 path; | |
| 1111 if (!paths->GetString(path_index, &path)) { | |
| 1112 AutomationJSONReply(this, reply_message) | |
| 1113 .SendError("path missing or invalid"); | |
|
kkania
2011/05/27 20:48:47
error is a bit off here. How about:
"'paths' conta
nodchip
2011/05/30 04:51:45
Done.
| |
| 1114 return; | |
| 1115 } | |
| 1116 | |
| 1117 drop_data.filenames.push_back(path); | |
| 1118 } | |
| 1119 | |
| 1120 const gfx::Point client(x, y); | |
| 1121 // We don't set any values in screen variable because DragTarget*** ignore the | |
| 1122 // screen argument. | |
| 1123 const gfx::Point screen; | |
| 1124 | |
| 1125 int operations = 0; | |
| 1126 operations |= WebKit::WebDragOperationCopy; | |
| 1127 operations |= WebKit::WebDragOperationLink; | |
| 1128 operations |= WebKit::WebDragOperationMove; | |
| 1129 | |
| 1130 RenderViewHost* host = tab_contents->render_view_host(); | |
| 1131 host->DragTargetDragEnter( | |
| 1132 drop_data, client, screen, | |
| 1133 static_cast<WebKit::WebDragOperationsMask>(operations)); | |
| 1134 new DragTargetDropAckNotificationObserver(this, reply_message); | |
| 1135 host->DragTargetDrop(client, screen); | |
| 1136 } | |
| 1137 | |
| 1083 void TestingAutomationProvider::GetTabCount(int handle, int* tab_count) { | 1138 void TestingAutomationProvider::GetTabCount(int handle, int* tab_count) { |
| 1084 *tab_count = -1; // -1 is the error code | 1139 *tab_count = -1; // -1 is the error code |
| 1085 | 1140 |
| 1086 if (browser_tracker_->ContainsHandle(handle)) { | 1141 if (browser_tracker_->ContainsHandle(handle)) { |
| 1087 Browser* browser = browser_tracker_->GetResource(handle); | 1142 Browser* browser = browser_tracker_->GetResource(handle); |
| 1088 *tab_count = browser->tab_count(); | 1143 *tab_count = browser->tab_count(); |
| 1089 } | 1144 } |
| 1090 } | 1145 } |
| 1091 | 1146 |
| 1092 void TestingAutomationProvider::GetType(int handle, int* type_as_int) { | 1147 void TestingAutomationProvider::GetType(int handle, int* type_as_int) { |
| (...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2211 handler_map["WebkitMouseClick"] = | 2266 handler_map["WebkitMouseClick"] = |
| 2212 &TestingAutomationProvider::WebkitMouseClick; | 2267 &TestingAutomationProvider::WebkitMouseClick; |
| 2213 handler_map["WebkitMouseDrag"] = | 2268 handler_map["WebkitMouseDrag"] = |
| 2214 &TestingAutomationProvider::WebkitMouseDrag; | 2269 &TestingAutomationProvider::WebkitMouseDrag; |
| 2215 handler_map["WebkitMouseButtonUp"] = | 2270 handler_map["WebkitMouseButtonUp"] = |
| 2216 &TestingAutomationProvider::WebkitMouseButtonUp; | 2271 &TestingAutomationProvider::WebkitMouseButtonUp; |
| 2217 handler_map["WebkitMouseButtonDown"] = | 2272 handler_map["WebkitMouseButtonDown"] = |
| 2218 &TestingAutomationProvider::WebkitMouseButtonDown; | 2273 &TestingAutomationProvider::WebkitMouseButtonDown; |
| 2219 handler_map["WebkitMouseDoubleClick"] = | 2274 handler_map["WebkitMouseDoubleClick"] = |
| 2220 &TestingAutomationProvider::WebkitMouseDoubleClick; | 2275 &TestingAutomationProvider::WebkitMouseDoubleClick; |
| 2276 handler_map["DragAndDropFilePaths"] = | |
| 2277 &TestingAutomationProvider::DragAndDropFilePaths; | |
| 2221 handler_map["SendWebkitKeyEvent"] = | 2278 handler_map["SendWebkitKeyEvent"] = |
| 2222 &TestingAutomationProvider::SendWebkitKeyEvent; | 2279 &TestingAutomationProvider::SendWebkitKeyEvent; |
| 2223 handler_map["SendOSLevelKeyEventToTab"] = | 2280 handler_map["SendOSLevelKeyEventToTab"] = |
| 2224 &TestingAutomationProvider::SendOSLevelKeyEventToTab; | 2281 &TestingAutomationProvider::SendOSLevelKeyEventToTab; |
| 2225 handler_map["ActivateTab"] = | 2282 handler_map["ActivateTab"] = |
| 2226 &TestingAutomationProvider::ActivateTabJSON; | 2283 &TestingAutomationProvider::ActivateTabJSON; |
| 2227 handler_map["GetAppModalDialogMessage"] = | 2284 handler_map["GetAppModalDialogMessage"] = |
| 2228 &TestingAutomationProvider::GetAppModalDialogMessage; | 2285 &TestingAutomationProvider::GetAppModalDialogMessage; |
| 2229 handler_map["AcceptOrDismissAppModalDialog"] = | 2286 handler_map["AcceptOrDismissAppModalDialog"] = |
| 2230 &TestingAutomationProvider::AcceptOrDismissAppModalDialog; | 2287 &TestingAutomationProvider::AcceptOrDismissAppModalDialog; |
| (...skipping 3718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5949 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); | 6006 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); |
| 5950 | 6007 |
| 5951 Send(reply_message_); | 6008 Send(reply_message_); |
| 5952 redirect_query_ = 0; | 6009 redirect_query_ = 0; |
| 5953 reply_message_ = NULL; | 6010 reply_message_ = NULL; |
| 5954 } | 6011 } |
| 5955 | 6012 |
| 5956 void TestingAutomationProvider::OnRemoveProvider() { | 6013 void TestingAutomationProvider::OnRemoveProvider() { |
| 5957 AutomationProviderList::GetInstance()->RemoveProvider(this); | 6014 AutomationProviderList::GetInstance()->RemoveProvider(this); |
| 5958 } | 6015 } |
| OLD | NEW |