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::SetFilePathsToFileUploadControl( | |
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) || | |
1095 !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.
| |
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"); | |
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 std::string path; | |
1112 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.
| |
1113 AutomationJSONReply(this, reply_message) | |
1114 .SendError("path missing or invalid"); | |
1115 return; | |
1116 } | |
1117 | |
1118 drop_data.filenames.push_back(UTF8ToUTF16(path)); | |
1119 } | |
1120 | |
1121 const gfx::Point client(x, y); | |
1122 // 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
| |
1123 // TODO(hnoda): Calculate the screen coordinate using WindowGetViewBounds(). | |
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(drop_data, client, screen, | |
1133 (WebKit::WebDragOperationsMask)operations); | |
kkania
2011/05/23 18:43:49
don't use c-style casting
nodchip
2011/05/26 01:14:53
Done.
| |
1134 host->DragTargetDrop(client, screen); | |
1135 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.
| |
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["SetFilePathToFileUploadControl"] = | |
2277 &TestingAutomationProvider::SetFilePathsToFileUploadControl; | |
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 3661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5892 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); | 5949 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); |
5893 | 5950 |
5894 Send(reply_message_); | 5951 Send(reply_message_); |
5895 redirect_query_ = 0; | 5952 redirect_query_ = 0; |
5896 reply_message_ = NULL; | 5953 reply_message_ = NULL; |
5897 } | 5954 } |
5898 | 5955 |
5899 void TestingAutomationProvider::OnRemoveProvider() { | 5956 void TestingAutomationProvider::OnRemoveProvider() { |
5900 AutomationProviderList::GetInstance()->RemoveProvider(this); | 5957 AutomationProviderList::GetInstance()->RemoveProvider(this); |
5901 } | 5958 } |
OLD | NEW |