Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 7055004: File upload API in chromedriver (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed a compile error. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 #include "content/browser/renderer_host/render_process_host.h" 99 #include "content/browser/renderer_host/render_process_host.h"
100 #include "content/browser/renderer_host/render_view_host.h" 100 #include "content/browser/renderer_host/render_view_host.h"
101 #include "content/browser/tab_contents/interstitial_page.h" 101 #include "content/browser/tab_contents/interstitial_page.h"
102 #include "content/common/common_param_traits.h" 102 #include "content/common/common_param_traits.h"
103 #include "content/common/notification_service.h" 103 #include "content/common/notification_service.h"
104 #include "net/base/cookie_store.h" 104 #include "net/base/cookie_store.h"
105 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 105 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
106 #include "ui/base/events.h" 106 #include "ui/base/events.h"
107 #include "ui/base/keycodes/keyboard_codes.h" 107 #include "ui/base/keycodes/keyboard_codes.h"
108 #include "ui/base/message_box_flags.h" 108 #include "ui/base/message_box_flags.h"
109 #include "webkit/glue/webdropdata.h"
109 #include "webkit/plugins/npapi/plugin_list.h" 110 #include "webkit/plugins/npapi/plugin_list.h"
110 111
111 namespace { 112 namespace {
112 113
113 void SendMouseClick(int flags) { 114 void SendMouseClick(int flags) {
114 ui_controls::MouseButton button = ui_controls::LEFT; 115 ui_controls::MouseButton button = ui_controls::LEFT;
115 if ((flags & ui::EF_LEFT_BUTTON_DOWN) == 116 if ((flags & ui::EF_LEFT_BUTTON_DOWN) ==
116 ui::EF_LEFT_BUTTON_DOWN) { 117 ui::EF_LEFT_BUTTON_DOWN) {
117 button = ui_controls::LEFT; 118 button = ui_controls::LEFT;
118 } else if ((flags & ui::EF_RIGHT_BUTTON_DOWN) == 119 } else if ((flags & ui::EF_RIGHT_BUTTON_DOWN) ==
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); 1064 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event);
1064 1065
1065 mouse_event.type = WebKit::WebInputEvent::MouseDown; 1066 mouse_event.type = WebKit::WebInputEvent::MouseDown;
1066 mouse_event.clickCount = 2; 1067 mouse_event.clickCount = 2;
1067 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); 1068 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event);
1068 1069
1069 mouse_event.type = WebKit::WebInputEvent::MouseUp; 1070 mouse_event.type = WebKit::WebInputEvent::MouseUp;
1070 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); 1071 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event);
1071 } 1072 }
1072 1073
1074 void TestingAutomationProvider::DragAndDropFilePaths(
1075 DictionaryValue* args, IPC::Message* reply_message) {
1076 TabContents* tab_contents;
1077 std::string error;
1078 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) {
1079 AutomationJSONReply(this, reply_message).SendError(error);
1080 return;
1081 }
1082
1083 int x, y;
1084 if (!args->GetInteger("x", &x) || !args->GetInteger("y", &y)) {
1085 AutomationJSONReply(this, reply_message)
1086 .SendError("(X,Y) coordinates missing or invalid");
1087 return;
1088 }
1089
1090 ListValue* paths = NULL;
1091 if (!args->GetList("paths", &paths)) {
1092 AutomationJSONReply(this, reply_message)
1093 .SendError("'paths' missing or invalid");
1094 return;
1095 }
1096
1097 // Emulate drag and drop to set the file paths to the file upload control.
1098 WebDropData drop_data;
1099 for (size_t path_index = 0; path_index < paths->GetSize(); ++path_index) {
1100 string16 path;
1101 if (!paths->GetString(path_index, &path)) {
1102 AutomationJSONReply(this, reply_message)
1103 .SendError("'paths' contains a non-string type");
1104 return;
1105 }
1106
1107 drop_data.filenames.push_back(path);
1108 }
1109
1110 const gfx::Point client(x, y);
1111 // We don't set any values in screen variable because DragTarget*** ignore the
1112 // screen argument.
1113 const gfx::Point screen;
1114
1115 int operations = 0;
1116 operations |= WebKit::WebDragOperationCopy;
1117 operations |= WebKit::WebDragOperationLink;
1118 operations |= WebKit::WebDragOperationMove;
1119
1120 RenderViewHost* host = tab_contents->render_view_host();
1121 host->DragTargetDragEnter(
1122 drop_data, client, screen,
1123 static_cast<WebKit::WebDragOperationsMask>(operations));
1124 new DragTargetDropAckNotificationObserver(this, reply_message);
1125 host->DragTargetDrop(client, screen);
1126 }
1127
1073 void TestingAutomationProvider::GetTabCount(int handle, int* tab_count) { 1128 void TestingAutomationProvider::GetTabCount(int handle, int* tab_count) {
1074 *tab_count = -1; // -1 is the error code 1129 *tab_count = -1; // -1 is the error code
1075 1130
1076 if (browser_tracker_->ContainsHandle(handle)) { 1131 if (browser_tracker_->ContainsHandle(handle)) {
1077 Browser* browser = browser_tracker_->GetResource(handle); 1132 Browser* browser = browser_tracker_->GetResource(handle);
1078 *tab_count = browser->tab_count(); 1133 *tab_count = browser->tab_count();
1079 } 1134 }
1080 } 1135 }
1081 1136
1082 void TestingAutomationProvider::GetType(int handle, int* type_as_int) { 1137 void TestingAutomationProvider::GetType(int handle, int* type_as_int) {
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
2107 handler_map["WebkitMouseClick"] = 2162 handler_map["WebkitMouseClick"] =
2108 &TestingAutomationProvider::WebkitMouseClick; 2163 &TestingAutomationProvider::WebkitMouseClick;
2109 handler_map["WebkitMouseDrag"] = 2164 handler_map["WebkitMouseDrag"] =
2110 &TestingAutomationProvider::WebkitMouseDrag; 2165 &TestingAutomationProvider::WebkitMouseDrag;
2111 handler_map["WebkitMouseButtonUp"] = 2166 handler_map["WebkitMouseButtonUp"] =
2112 &TestingAutomationProvider::WebkitMouseButtonUp; 2167 &TestingAutomationProvider::WebkitMouseButtonUp;
2113 handler_map["WebkitMouseButtonDown"] = 2168 handler_map["WebkitMouseButtonDown"] =
2114 &TestingAutomationProvider::WebkitMouseButtonDown; 2169 &TestingAutomationProvider::WebkitMouseButtonDown;
2115 handler_map["WebkitMouseDoubleClick"] = 2170 handler_map["WebkitMouseDoubleClick"] =
2116 &TestingAutomationProvider::WebkitMouseDoubleClick; 2171 &TestingAutomationProvider::WebkitMouseDoubleClick;
2172 handler_map["DragAndDropFilePaths"] =
2173 &TestingAutomationProvider::DragAndDropFilePaths;
2117 handler_map["SendWebkitKeyEvent"] = 2174 handler_map["SendWebkitKeyEvent"] =
2118 &TestingAutomationProvider::SendWebkitKeyEvent; 2175 &TestingAutomationProvider::SendWebkitKeyEvent;
2119 handler_map["SendOSLevelKeyEventToTab"] = 2176 handler_map["SendOSLevelKeyEventToTab"] =
2120 &TestingAutomationProvider::SendOSLevelKeyEventToTab; 2177 &TestingAutomationProvider::SendOSLevelKeyEventToTab;
2121 handler_map["ActivateTab"] = 2178 handler_map["ActivateTab"] =
2122 &TestingAutomationProvider::ActivateTabJSON; 2179 &TestingAutomationProvider::ActivateTabJSON;
2123 handler_map["GetAppModalDialogMessage"] = 2180 handler_map["GetAppModalDialogMessage"] =
2124 &TestingAutomationProvider::GetAppModalDialogMessage; 2181 &TestingAutomationProvider::GetAppModalDialogMessage;
2125 handler_map["AcceptOrDismissAppModalDialog"] = 2182 handler_map["AcceptOrDismissAppModalDialog"] =
2126 &TestingAutomationProvider::AcceptOrDismissAppModalDialog; 2183 &TestingAutomationProvider::AcceptOrDismissAppModalDialog;
(...skipping 3762 matching lines...) Expand 10 before | Expand all | Expand 10 after
5889 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); 5946 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl);
5890 5947
5891 Send(reply_message_); 5948 Send(reply_message_);
5892 redirect_query_ = 0; 5949 redirect_query_ = 0;
5893 reply_message_ = NULL; 5950 reply_message_ = NULL;
5894 } 5951 }
5895 5952
5896 void TestingAutomationProvider::OnRemoveProvider() { 5953 void TestingAutomationProvider::OnRemoveProvider() {
5897 AutomationProviderList::GetInstance()->RemoveProvider(this); 5954 AutomationProviderList::GetInstance()->RemoveProvider(this);
5898 } 5955 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698