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