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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" | 94 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" |
95 #include "chrome/browser/ui/browser_init.h" | 95 #include "chrome/browser/ui/browser_init.h" |
96 #include "chrome/browser/ui/browser_window.h" | 96 #include "chrome/browser/ui/browser_window.h" |
97 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 97 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
98 #include "chrome/browser/ui/find_bar/find_bar.h" | 98 #include "chrome/browser/ui/find_bar/find_bar.h" |
99 #include "chrome/browser/ui/login/login_prompt.h" | 99 #include "chrome/browser/ui/login/login_prompt.h" |
100 #include "chrome/browser/ui/omnibox/location_bar.h" | 100 #include "chrome/browser/ui/omnibox/location_bar.h" |
101 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 101 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
102 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" | 102 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" |
103 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 103 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 104 #include "chrome/common/automation_id.h" |
104 #include "chrome/common/automation_messages.h" | 105 #include "chrome/common/automation_messages.h" |
105 #include "chrome/common/chrome_constants.h" | 106 #include "chrome/common/chrome_constants.h" |
106 #include "chrome/common/chrome_notification_types.h" | 107 #include "chrome/common/chrome_notification_types.h" |
107 #include "chrome/common/chrome_paths.h" | 108 #include "chrome/common/chrome_paths.h" |
108 #include "chrome/common/chrome_switches.h" | 109 #include "chrome/common/chrome_switches.h" |
109 #include "chrome/common/chrome_view_type.h" | 110 #include "chrome/common/chrome_view_type.h" |
110 #include "chrome/common/extensions/extension.h" | 111 #include "chrome/common/extensions/extension.h" |
111 #include "chrome/common/extensions/extension_action.h" | 112 #include "chrome/common/extensions/extension_action.h" |
112 #include "chrome/common/extensions/url_pattern.h" | 113 #include "chrome/common/extensions/url_pattern.h" |
113 #include "chrome/common/extensions/url_pattern_set.h" | 114 #include "chrome/common/extensions/url_pattern_set.h" |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 ui::EF_ALT_DOWN), | 926 ui::EF_ALT_DOWN), |
926 ((flags & ui::EF_COMMAND_DOWN) == | 927 ((flags & ui::EF_COMMAND_DOWN) == |
927 ui::EF_COMMAND_DOWN)); | 928 ui::EF_COMMAND_DOWN)); |
928 } | 929 } |
929 | 930 |
930 void TestingAutomationProvider::WebkitMouseClick(DictionaryValue* args, | 931 void TestingAutomationProvider::WebkitMouseClick(DictionaryValue* args, |
931 IPC::Message* reply_message) { | 932 IPC::Message* reply_message) { |
932 if (SendErrorIfModalDialogActive(this, reply_message)) | 933 if (SendErrorIfModalDialogActive(this, reply_message)) |
933 return; | 934 return; |
934 | 935 |
935 TabContents* tab_contents; | 936 RenderViewHost* view; |
936 std::string error; | 937 std::string error; |
937 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 938 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
938 AutomationJSONReply(this, reply_message).SendError(error); | 939 AutomationJSONReply(this, reply_message).SendError(error); |
939 return; | 940 return; |
940 } | 941 } |
941 | 942 |
942 WebKit::WebMouseEvent mouse_event; | 943 WebKit::WebMouseEvent mouse_event; |
943 if (!args->GetInteger("x", &mouse_event.x) || | 944 if (!args->GetInteger("x", &mouse_event.x) || |
944 !args->GetInteger("y", &mouse_event.y)) { | 945 !args->GetInteger("y", &mouse_event.y)) { |
945 AutomationJSONReply(this, reply_message) | 946 AutomationJSONReply(this, reply_message) |
946 .SendError("(X,Y) coordinates missing or invalid"); | 947 .SendError("(X,Y) coordinates missing or invalid"); |
947 return; | 948 return; |
(...skipping 13 matching lines...) Expand all Loading... |
961 mouse_event.button = WebKit::WebMouseEvent::ButtonMiddle; | 962 mouse_event.button = WebKit::WebMouseEvent::ButtonMiddle; |
962 } else { | 963 } else { |
963 AutomationJSONReply(this, reply_message) | 964 AutomationJSONReply(this, reply_message) |
964 .SendError("Invalid button press requested"); | 965 .SendError("Invalid button press requested"); |
965 return; | 966 return; |
966 } | 967 } |
967 | 968 |
968 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 969 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
969 mouse_event.clickCount = 1; | 970 mouse_event.clickCount = 1; |
970 | 971 |
971 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 972 view->ForwardMouseEvent(mouse_event); |
972 | 973 |
973 mouse_event.type = WebKit::WebInputEvent::MouseUp; | 974 mouse_event.type = WebKit::WebInputEvent::MouseUp; |
974 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, | 975 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
975 1); | 976 1); |
976 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 977 view->ForwardMouseEvent(mouse_event); |
977 } | 978 } |
978 | 979 |
979 void TestingAutomationProvider::WebkitMouseMove( | 980 void TestingAutomationProvider::WebkitMouseMove( |
980 DictionaryValue* args, IPC::Message* reply_message) { | 981 DictionaryValue* args, IPC::Message* reply_message) { |
981 if (SendErrorIfModalDialogActive(this, reply_message)) | 982 if (SendErrorIfModalDialogActive(this, reply_message)) |
982 return; | 983 return; |
983 | 984 |
984 TabContents* tab_contents; | 985 RenderViewHost* view; |
985 std::string error; | 986 std::string error; |
986 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 987 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
987 AutomationJSONReply(this, reply_message).SendError(error); | 988 AutomationJSONReply(this, reply_message).SendError(error); |
988 return; | 989 return; |
989 } | 990 } |
990 | 991 |
991 WebKit::WebMouseEvent mouse_event; | 992 WebKit::WebMouseEvent mouse_event; |
992 if (!args->GetInteger("x", &mouse_event.x) || | 993 if (!args->GetInteger("x", &mouse_event.x) || |
993 !args->GetInteger("y", &mouse_event.y)) { | 994 !args->GetInteger("y", &mouse_event.y)) { |
994 AutomationJSONReply(this, reply_message) | 995 AutomationJSONReply(this, reply_message) |
995 .SendError("(X,Y) coordinates missing or invalid"); | 996 .SendError("(X,Y) coordinates missing or invalid"); |
996 return; | 997 return; |
997 } | 998 } |
998 | 999 |
999 mouse_event.type = WebKit::WebInputEvent::MouseMove; | 1000 mouse_event.type = WebKit::WebInputEvent::MouseMove; |
1000 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, | 1001 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
1001 1); | 1002 1); |
1002 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1003 view->ForwardMouseEvent(mouse_event); |
1003 } | 1004 } |
1004 | 1005 |
1005 void TestingAutomationProvider::WebkitMouseDrag(DictionaryValue* args, | 1006 void TestingAutomationProvider::WebkitMouseDrag(DictionaryValue* args, |
1006 IPC::Message* reply_message) { | 1007 IPC::Message* reply_message) { |
1007 if (SendErrorIfModalDialogActive(this, reply_message)) | 1008 if (SendErrorIfModalDialogActive(this, reply_message)) |
1008 return; | 1009 return; |
1009 | 1010 |
1010 TabContents* tab_contents; | 1011 RenderViewHost* view; |
1011 std::string error; | 1012 std::string error; |
1012 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 1013 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
1013 AutomationJSONReply(this, reply_message).SendError(error); | 1014 AutomationJSONReply(this, reply_message).SendError(error); |
1014 return; | 1015 return; |
1015 } | 1016 } |
1016 | 1017 |
1017 WebKit::WebMouseEvent mouse_event; | 1018 WebKit::WebMouseEvent mouse_event; |
1018 int start_x, start_y, end_x, end_y; | 1019 int start_x, start_y, end_x, end_y; |
1019 if (!args->GetInteger("start_x", &start_x) || | 1020 if (!args->GetInteger("start_x", &start_x) || |
1020 !args->GetInteger("start_y", &start_y) || | 1021 !args->GetInteger("start_y", &start_y) || |
1021 !args->GetInteger("end_x", &end_x) || | 1022 !args->GetInteger("end_x", &end_x) || |
1022 !args->GetInteger("end_y", &end_y)) { | 1023 !args->GetInteger("end_y", &end_y)) { |
1023 AutomationJSONReply(this, reply_message) | 1024 AutomationJSONReply(this, reply_message) |
1024 .SendError("Invalid start/end positions"); | 1025 .SendError("Invalid start/end positions"); |
1025 return; | 1026 return; |
1026 } | 1027 } |
1027 | 1028 |
1028 mouse_event.type = WebKit::WebInputEvent::MouseMove; | 1029 mouse_event.type = WebKit::WebInputEvent::MouseMove; |
1029 // Step 1- Move the mouse to the start position. | 1030 // Step 1- Move the mouse to the start position. |
1030 mouse_event.x = start_x; | 1031 mouse_event.x = start_x; |
1031 mouse_event.y = start_y; | 1032 mouse_event.y = start_y; |
1032 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1033 view->ForwardMouseEvent(mouse_event); |
1033 | 1034 |
1034 // Step 2- Left click mouse down, the mouse button is fixed. | 1035 // Step 2- Left click mouse down, the mouse button is fixed. |
1035 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 1036 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
1036 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; | 1037 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
1037 mouse_event.clickCount = 1; | 1038 mouse_event.clickCount = 1; |
1038 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1039 view->ForwardMouseEvent(mouse_event); |
1039 | 1040 |
1040 // Step 3 - Move the mouse to the end position. | 1041 // Step 3 - Move the mouse to the end position. |
1041 // TODO(JMikhail): See if we should simulate the by not making such | |
1042 // a drastic jump by placing incrmental stops along the way. | |
1043 mouse_event.type = WebKit::WebInputEvent::MouseMove; | 1042 mouse_event.type = WebKit::WebInputEvent::MouseMove; |
1044 mouse_event.x = end_x; | 1043 mouse_event.x = end_x; |
1045 mouse_event.y = end_y; | 1044 mouse_event.y = end_y; |
1046 mouse_event.clickCount = 0; | 1045 mouse_event.clickCount = 0; |
1047 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1046 view->ForwardMouseEvent(mouse_event); |
1048 | 1047 |
1049 // Step 4 - Release the left mouse button. | 1048 // Step 4 - Release the left mouse button. |
1050 mouse_event.type = WebKit::WebInputEvent::MouseUp; | 1049 mouse_event.type = WebKit::WebInputEvent::MouseUp; |
1051 mouse_event.clickCount = 1; | 1050 mouse_event.clickCount = 1; |
1052 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, | 1051 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
1053 1); | 1052 1); |
1054 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1053 view->ForwardMouseEvent(mouse_event); |
1055 } | 1054 } |
1056 | 1055 |
1057 void TestingAutomationProvider::WebkitMouseButtonDown( | 1056 void TestingAutomationProvider::WebkitMouseButtonDown( |
1058 DictionaryValue* args, IPC::Message* reply_message) { | 1057 DictionaryValue* args, IPC::Message* reply_message) { |
1059 if (SendErrorIfModalDialogActive(this, reply_message)) | 1058 if (SendErrorIfModalDialogActive(this, reply_message)) |
1060 return; | 1059 return; |
1061 | 1060 |
1062 TabContents* tab_contents; | 1061 RenderViewHost* view; |
1063 std::string error; | 1062 std::string error; |
1064 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 1063 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
1065 AutomationJSONReply(this, reply_message).SendError(error); | 1064 AutomationJSONReply(this, reply_message).SendError(error); |
1066 return; | 1065 return; |
1067 } | 1066 } |
1068 | 1067 |
1069 WebKit::WebMouseEvent mouse_event; | 1068 WebKit::WebMouseEvent mouse_event; |
1070 if (!args->GetInteger("x", &mouse_event.x) || | 1069 if (!args->GetInteger("x", &mouse_event.x) || |
1071 !args->GetInteger("y", &mouse_event.y)) { | 1070 !args->GetInteger("y", &mouse_event.y)) { |
1072 AutomationJSONReply(this, reply_message) | 1071 AutomationJSONReply(this, reply_message) |
1073 .SendError("(X,Y) coordinates missing or invalid"); | 1072 .SendError("(X,Y) coordinates missing or invalid"); |
1074 return; | 1073 return; |
1075 } | 1074 } |
1076 | 1075 |
1077 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 1076 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
1078 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; | 1077 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
1079 mouse_event.clickCount = 1; | 1078 mouse_event.clickCount = 1; |
1080 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, | 1079 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
1081 1); | 1080 1); |
1082 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1081 view->ForwardMouseEvent(mouse_event); |
1083 } | 1082 } |
1084 | 1083 |
1085 void TestingAutomationProvider::WebkitMouseButtonUp( | 1084 void TestingAutomationProvider::WebkitMouseButtonUp( |
1086 DictionaryValue* args, IPC::Message* reply_message) { | 1085 DictionaryValue* args, IPC::Message* reply_message) { |
1087 if (SendErrorIfModalDialogActive(this, reply_message)) | 1086 if (SendErrorIfModalDialogActive(this, reply_message)) |
1088 return; | 1087 return; |
1089 | 1088 |
1090 TabContents* tab_contents; | 1089 RenderViewHost* view; |
1091 std::string error; | 1090 std::string error; |
1092 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 1091 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
1093 AutomationJSONReply(this, reply_message).SendError(error); | 1092 AutomationJSONReply(this, reply_message).SendError(error); |
1094 return; | 1093 return; |
1095 } | 1094 } |
1096 | 1095 |
1097 WebKit::WebMouseEvent mouse_event; | 1096 WebKit::WebMouseEvent mouse_event; |
1098 if (!args->GetInteger("x", &mouse_event.x) || | 1097 if (!args->GetInteger("x", &mouse_event.x) || |
1099 !args->GetInteger("y", &mouse_event.y)) { | 1098 !args->GetInteger("y", &mouse_event.y)) { |
1100 AutomationJSONReply(this, reply_message) | 1099 AutomationJSONReply(this, reply_message) |
1101 .SendError("(X,Y) coordinates missing or invalid"); | 1100 .SendError("(X,Y) coordinates missing or invalid"); |
1102 return; | 1101 return; |
1103 } | 1102 } |
1104 | 1103 |
1105 mouse_event.type = WebKit::WebInputEvent::MouseUp; | 1104 mouse_event.type = WebKit::WebInputEvent::MouseUp; |
1106 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; | 1105 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
1107 mouse_event.clickCount = 1; | 1106 mouse_event.clickCount = 1; |
1108 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, | 1107 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
1109 1); | 1108 1); |
1110 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1109 view->ForwardMouseEvent(mouse_event); |
1111 } | 1110 } |
1112 | 1111 |
1113 void TestingAutomationProvider::WebkitMouseDoubleClick( | 1112 void TestingAutomationProvider::WebkitMouseDoubleClick( |
1114 DictionaryValue* args, IPC::Message* reply_message) { | 1113 DictionaryValue* args, IPC::Message* reply_message) { |
1115 if (SendErrorIfModalDialogActive(this, reply_message)) | 1114 if (SendErrorIfModalDialogActive(this, reply_message)) |
1116 return; | 1115 return; |
1117 | 1116 |
1118 TabContents* tab_contents; | 1117 RenderViewHost* view; |
1119 std::string error; | 1118 std::string error; |
1120 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 1119 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
1121 AutomationJSONReply(this, reply_message).SendError(error); | 1120 AutomationJSONReply(this, reply_message).SendError(error); |
1122 return; | 1121 return; |
1123 } | 1122 } |
1124 | 1123 |
1125 WebKit::WebMouseEvent mouse_event; | 1124 WebKit::WebMouseEvent mouse_event; |
1126 if (!args->GetInteger("x", &mouse_event.x) || | 1125 if (!args->GetInteger("x", &mouse_event.x) || |
1127 !args->GetInteger("y", &mouse_event.y)) { | 1126 !args->GetInteger("y", &mouse_event.y)) { |
1128 AutomationJSONReply(this, reply_message) | 1127 AutomationJSONReply(this, reply_message) |
1129 .SendError("(X,Y) coordinates missing or invalid"); | 1128 .SendError("(X,Y) coordinates missing or invalid"); |
1130 return; | 1129 return; |
1131 } | 1130 } |
1132 | 1131 |
1133 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 1132 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
1134 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; | 1133 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
1135 mouse_event.clickCount = 1; | 1134 mouse_event.clickCount = 1; |
1136 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1135 view->ForwardMouseEvent(mouse_event); |
1137 | 1136 |
1138 mouse_event.type = WebKit::WebInputEvent::MouseUp; | 1137 mouse_event.type = WebKit::WebInputEvent::MouseUp; |
1139 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, | 1138 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
1140 2); | 1139 2); |
1141 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1140 view->ForwardMouseEvent(mouse_event); |
1142 | 1141 |
1143 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 1142 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
1144 mouse_event.clickCount = 2; | 1143 mouse_event.clickCount = 2; |
1145 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1144 view->ForwardMouseEvent(mouse_event); |
1146 | 1145 |
1147 mouse_event.type = WebKit::WebInputEvent::MouseUp; | 1146 mouse_event.type = WebKit::WebInputEvent::MouseUp; |
1148 tab_contents->render_view_host()->ForwardMouseEvent(mouse_event); | 1147 view->ForwardMouseEvent(mouse_event); |
1149 } | 1148 } |
1150 | 1149 |
1151 void TestingAutomationProvider::DragAndDropFilePaths( | 1150 void TestingAutomationProvider::DragAndDropFilePaths( |
1152 DictionaryValue* args, IPC::Message* reply_message) { | 1151 DictionaryValue* args, IPC::Message* reply_message) { |
1153 if (SendErrorIfModalDialogActive(this, reply_message)) | 1152 if (SendErrorIfModalDialogActive(this, reply_message)) |
1154 return; | 1153 return; |
1155 | 1154 |
1156 TabContents* tab_contents; | 1155 RenderViewHost* view; |
1157 std::string error; | 1156 std::string error; |
1158 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 1157 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
1159 AutomationJSONReply(this, reply_message).SendError(error); | 1158 AutomationJSONReply(this, reply_message).SendError(error); |
1160 return; | 1159 return; |
1161 } | 1160 } |
1162 | 1161 |
1163 int x, y; | 1162 int x, y; |
1164 if (!args->GetInteger("x", &x) || !args->GetInteger("y", &y)) { | 1163 if (!args->GetInteger("x", &x) || !args->GetInteger("y", &y)) { |
1165 AutomationJSONReply(this, reply_message) | 1164 AutomationJSONReply(this, reply_message) |
1166 .SendError("(X,Y) coordinates missing or invalid"); | 1165 .SendError("(X,Y) coordinates missing or invalid"); |
1167 return; | 1166 return; |
1168 } | 1167 } |
(...skipping 21 matching lines...) Expand all Loading... |
1190 const gfx::Point client(x, y); | 1189 const gfx::Point client(x, y); |
1191 // We don't set any values in screen variable because DragTarget*** ignore the | 1190 // We don't set any values in screen variable because DragTarget*** ignore the |
1192 // screen argument. | 1191 // screen argument. |
1193 const gfx::Point screen; | 1192 const gfx::Point screen; |
1194 | 1193 |
1195 int operations = 0; | 1194 int operations = 0; |
1196 operations |= WebKit::WebDragOperationCopy; | 1195 operations |= WebKit::WebDragOperationCopy; |
1197 operations |= WebKit::WebDragOperationLink; | 1196 operations |= WebKit::WebDragOperationLink; |
1198 operations |= WebKit::WebDragOperationMove; | 1197 operations |= WebKit::WebDragOperationMove; |
1199 | 1198 |
1200 RenderViewHost* host = tab_contents->render_view_host(); | 1199 view->DragTargetDragEnter( |
1201 host->DragTargetDragEnter( | |
1202 drop_data, client, screen, | 1200 drop_data, client, screen, |
1203 static_cast<WebKit::WebDragOperationsMask>(operations)); | 1201 static_cast<WebKit::WebDragOperationsMask>(operations)); |
1204 new DragTargetDropAckNotificationObserver(this, reply_message); | 1202 new DragTargetDropAckNotificationObserver(this, reply_message); |
1205 host->DragTargetDrop(client, screen); | 1203 view->DragTargetDrop(client, screen); |
1206 } | 1204 } |
1207 | 1205 |
1208 void TestingAutomationProvider::GetTabCount(int handle, int* tab_count) { | 1206 void TestingAutomationProvider::GetTabCount(int handle, int* tab_count) { |
1209 *tab_count = -1; // -1 is the error code | 1207 *tab_count = -1; // -1 is the error code |
1210 | 1208 |
1211 if (browser_tracker_->ContainsHandle(handle)) { | 1209 if (browser_tracker_->ContainsHandle(handle)) { |
1212 Browser* browser = browser_tracker_->GetResource(handle); | 1210 Browser* browser = browser_tracker_->GetResource(handle); |
1213 *tab_count = browser->tab_count(); | 1211 *tab_count = browser->tab_count(); |
1214 } | 1212 } |
1215 } | 1213 } |
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2256 handler_map["ExecuteJavascript"] = | 2254 handler_map["ExecuteJavascript"] = |
2257 &TestingAutomationProvider::ExecuteJavascriptJSON; | 2255 &TestingAutomationProvider::ExecuteJavascriptJSON; |
2258 handler_map["ExecuteJavascriptInRenderView"] = | 2256 handler_map["ExecuteJavascriptInRenderView"] = |
2259 &TestingAutomationProvider::ExecuteJavascriptInRenderView; | 2257 &TestingAutomationProvider::ExecuteJavascriptInRenderView; |
2260 handler_map["GoForward"] = | 2258 handler_map["GoForward"] = |
2261 &TestingAutomationProvider::GoForward; | 2259 &TestingAutomationProvider::GoForward; |
2262 handler_map["GoBack"] = | 2260 handler_map["GoBack"] = |
2263 &TestingAutomationProvider::GoBack; | 2261 &TestingAutomationProvider::GoBack; |
2264 handler_map["Reload"] = | 2262 handler_map["Reload"] = |
2265 &TestingAutomationProvider::ReloadJSON; | 2263 &TestingAutomationProvider::ReloadJSON; |
2266 handler_map["GetTabURL"] = | |
2267 &TestingAutomationProvider::GetTabURLJSON; | |
2268 handler_map["GetTabTitle"] = | |
2269 &TestingAutomationProvider::GetTabTitleJSON; | |
2270 handler_map["CaptureEntirePage"] = | 2264 handler_map["CaptureEntirePage"] = |
2271 &TestingAutomationProvider::CaptureEntirePageJSON; | 2265 &TestingAutomationProvider::CaptureEntirePageJSON; |
2272 handler_map["GetCookies"] = | 2266 handler_map["GetCookies"] = |
2273 &TestingAutomationProvider::GetCookiesJSON; | 2267 &TestingAutomationProvider::GetCookiesJSON; |
2274 handler_map["DeleteCookie"] = | 2268 handler_map["DeleteCookie"] = |
2275 &TestingAutomationProvider::DeleteCookieJSON; | 2269 &TestingAutomationProvider::DeleteCookieJSON; |
2276 handler_map["SetCookie"] = | 2270 handler_map["SetCookie"] = |
2277 &TestingAutomationProvider::SetCookieJSON; | 2271 &TestingAutomationProvider::SetCookieJSON; |
2278 handler_map["GetTabIds"] = | 2272 handler_map["GetTabIds"] = |
2279 &TestingAutomationProvider::GetTabIds; | 2273 &TestingAutomationProvider::GetTabIds; |
| 2274 handler_map["GetViews"] = |
| 2275 &TestingAutomationProvider::GetViews; |
2280 handler_map["IsTabIdValid"] = | 2276 handler_map["IsTabIdValid"] = |
2281 &TestingAutomationProvider::IsTabIdValid; | 2277 &TestingAutomationProvider::IsTabIdValid; |
| 2278 handler_map["DoesAutomationObjectExist"] = |
| 2279 &TestingAutomationProvider::DoesAutomationObjectExist; |
2282 handler_map["CloseTab"] = | 2280 handler_map["CloseTab"] = |
2283 &TestingAutomationProvider::CloseTabJSON; | 2281 &TestingAutomationProvider::CloseTabJSON; |
2284 handler_map["WebkitMouseMove"] = | 2282 handler_map["WebkitMouseMove"] = |
2285 &TestingAutomationProvider::WebkitMouseMove; | 2283 &TestingAutomationProvider::WebkitMouseMove; |
2286 handler_map["WebkitMouseClick"] = | 2284 handler_map["WebkitMouseClick"] = |
2287 &TestingAutomationProvider::WebkitMouseClick; | 2285 &TestingAutomationProvider::WebkitMouseClick; |
2288 handler_map["WebkitMouseDrag"] = | 2286 handler_map["WebkitMouseDrag"] = |
2289 &TestingAutomationProvider::WebkitMouseDrag; | 2287 &TestingAutomationProvider::WebkitMouseDrag; |
2290 handler_map["WebkitMouseButtonUp"] = | 2288 handler_map["WebkitMouseButtonUp"] = |
2291 &TestingAutomationProvider::WebkitMouseButtonUp; | 2289 &TestingAutomationProvider::WebkitMouseButtonUp; |
(...skipping 28 matching lines...) Expand all Loading... |
2320 handler_map["GetProcessInfo"] = | 2318 handler_map["GetProcessInfo"] = |
2321 &TestingAutomationProvider::GetProcessInfo; | 2319 &TestingAutomationProvider::GetProcessInfo; |
2322 handler_map["SetPolicies"] = | 2320 handler_map["SetPolicies"] = |
2323 &TestingAutomationProvider::SetPolicies; | 2321 &TestingAutomationProvider::SetPolicies; |
2324 handler_map["GetPolicyDefinitionList"] = | 2322 handler_map["GetPolicyDefinitionList"] = |
2325 &TestingAutomationProvider::GetPolicyDefinitionList; | 2323 &TestingAutomationProvider::GetPolicyDefinitionList; |
2326 handler_map["InstallExtension"] = | 2324 handler_map["InstallExtension"] = |
2327 &TestingAutomationProvider::InstallExtension; | 2325 &TestingAutomationProvider::InstallExtension; |
2328 handler_map["GetExtensionsInfo"] = | 2326 handler_map["GetExtensionsInfo"] = |
2329 &TestingAutomationProvider::GetExtensionsInfo; | 2327 &TestingAutomationProvider::GetExtensionsInfo; |
| 2328 handler_map["UninstallExtensionById"] = |
| 2329 &TestingAutomationProvider::UninstallExtensionById; |
| 2330 handler_map["SetExtensionStateById"] = |
| 2331 &TestingAutomationProvider::SetExtensionStateById; |
2330 handler_map["RefreshPolicies"] = | 2332 handler_map["RefreshPolicies"] = |
2331 &TestingAutomationProvider::RefreshPolicies; | 2333 &TestingAutomationProvider::RefreshPolicies; |
2332 handler_map["TriggerPageActionById"] = | 2334 handler_map["TriggerPageActionById"] = |
2333 &TestingAutomationProvider::TriggerPageActionById; | 2335 &TestingAutomationProvider::TriggerPageActionById; |
2334 handler_map["TriggerBrowserActionById"] = | 2336 handler_map["TriggerBrowserActionById"] = |
2335 &TestingAutomationProvider::TriggerBrowserActionById; | 2337 &TestingAutomationProvider::TriggerBrowserActionById; |
2336 #if defined(OS_CHROMEOS) | 2338 #if defined(OS_CHROMEOS) |
2337 handler_map["GetLoginInfo"] = &TestingAutomationProvider::GetLoginInfo; | 2339 handler_map["GetLoginInfo"] = &TestingAutomationProvider::GetLoginInfo; |
2338 handler_map["ShowCreateAccountUI"] = | 2340 handler_map["ShowCreateAccountUI"] = |
2339 &TestingAutomationProvider::ShowCreateAccountUI; | 2341 &TestingAutomationProvider::ShowCreateAccountUI; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2468 | 2470 |
2469 browser_handler_map["GetBlockedPopupsInfo"] = | 2471 browser_handler_map["GetBlockedPopupsInfo"] = |
2470 &TestingAutomationProvider::GetBlockedPopupsInfo; | 2472 &TestingAutomationProvider::GetBlockedPopupsInfo; |
2471 browser_handler_map["UnblockAndLaunchBlockedPopup"] = | 2473 browser_handler_map["UnblockAndLaunchBlockedPopup"] = |
2472 &TestingAutomationProvider::UnblockAndLaunchBlockedPopup; | 2474 &TestingAutomationProvider::UnblockAndLaunchBlockedPopup; |
2473 | 2475 |
2474 // SetTheme() implemented using InstallExtension(). | 2476 // SetTheme() implemented using InstallExtension(). |
2475 browser_handler_map["GetThemeInfo"] = | 2477 browser_handler_map["GetThemeInfo"] = |
2476 &TestingAutomationProvider::GetThemeInfo; | 2478 &TestingAutomationProvider::GetThemeInfo; |
2477 | 2479 |
2478 browser_handler_map["UninstallExtensionById"] = | |
2479 &TestingAutomationProvider::UninstallExtensionById; | |
2480 browser_handler_map["SetExtensionStateById"] = | |
2481 &TestingAutomationProvider::SetExtensionStateById; | |
2482 | |
2483 browser_handler_map["FindInPage"] = &TestingAutomationProvider::FindInPage; | 2480 browser_handler_map["FindInPage"] = &TestingAutomationProvider::FindInPage; |
2484 | 2481 |
2485 browser_handler_map["SelectTranslateOption"] = | 2482 browser_handler_map["SelectTranslateOption"] = |
2486 &TestingAutomationProvider::SelectTranslateOption; | 2483 &TestingAutomationProvider::SelectTranslateOption; |
2487 browser_handler_map["GetTranslateInfo"] = | 2484 browser_handler_map["GetTranslateInfo"] = |
2488 &TestingAutomationProvider::GetTranslateInfo; | 2485 &TestingAutomationProvider::GetTranslateInfo; |
2489 | 2486 |
2490 browser_handler_map["GetAutofillProfile"] = | 2487 browser_handler_map["GetAutofillProfile"] = |
2491 &TestingAutomationProvider::GetAutofillProfile; | 2488 &TestingAutomationProvider::GetAutofillProfile; |
2492 browser_handler_map["FillAutofillProfile"] = | 2489 browser_handler_map["FillAutofillProfile"] = |
(...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4403 extension_value->SetString("description", extension->description()); | 4400 extension_value->SetString("description", extension->description()); |
4404 extension_value->SetString("background_url", | 4401 extension_value->SetString("background_url", |
4405 extension->background_url().spec()); | 4402 extension->background_url().spec()); |
4406 extension_value->SetString("options_url", | 4403 extension_value->SetString("options_url", |
4407 extension->options_url().spec()); | 4404 extension->options_url().spec()); |
4408 extension_value->Set("host_permissions", | 4405 extension_value->Set("host_permissions", |
4409 GetHostPermissions(extension, false)); | 4406 GetHostPermissions(extension, false)); |
4410 extension_value->Set("effective_host_permissions", | 4407 extension_value->Set("effective_host_permissions", |
4411 GetHostPermissions(extension, true)); | 4408 GetHostPermissions(extension, true)); |
4412 extension_value->Set("api_permissions", GetAPIPermissions(extension)); | 4409 extension_value->Set("api_permissions", GetAPIPermissions(extension)); |
| 4410 Extension::Location location = extension->location(); |
4413 extension_value->SetBoolean("is_component", | 4411 extension_value->SetBoolean("is_component", |
4414 extension->location() == Extension::COMPONENT); | 4412 location == Extension::COMPONENT); |
4415 extension_value->SetBoolean("is_internal", | 4413 extension_value->SetBoolean("is_internal", location == Extension::INTERNAL); |
4416 extension->location() == Extension::INTERNAL); | 4414 extension_value->SetBoolean("is_user_installed", |
| 4415 location == Extension::INTERNAL || location == Extension::LOAD); |
4417 extension_value->SetBoolean("is_enabled", service->IsExtensionEnabled(id)); | 4416 extension_value->SetBoolean("is_enabled", service->IsExtensionEnabled(id)); |
4418 extension_value->SetBoolean("allowed_in_incognito", | 4417 extension_value->SetBoolean("allowed_in_incognito", |
4419 service->IsIncognitoEnabled(id)); | 4418 service->IsIncognitoEnabled(id)); |
4420 extensions_values->Append(extension_value); | 4419 extensions_values->Append(extension_value); |
4421 } | 4420 } |
4422 return_value->Set("extensions", extensions_values); | 4421 return_value->Set("extensions", extensions_values); |
4423 reply.SendSuccess(return_value.get()); | 4422 reply.SendSuccess(return_value.get()); |
4424 } | 4423 } |
4425 | 4424 |
4426 // See UninstallExtensionById() in chrome/test/pyautolib/pyauto.py for sample | 4425 // See UninstallExtensionById() in chrome/test/pyautolib/pyauto.py for sample |
4427 // json input. | 4426 // json input. |
4428 // Sample json output: {} | 4427 // Sample json output: {} |
4429 void TestingAutomationProvider::UninstallExtensionById( | 4428 void TestingAutomationProvider::UninstallExtensionById( |
4430 Browser* browser, | |
4431 DictionaryValue* args, | 4429 DictionaryValue* args, |
4432 IPC::Message* reply_message) { | 4430 IPC::Message* reply_message) { |
4433 std::string id; | 4431 std::string id; |
4434 if (!args->GetString("id", &id)) { | 4432 if (!args->GetString("id", &id)) { |
4435 AutomationJSONReply(this, reply_message).SendError( | 4433 AutomationJSONReply(this, reply_message).SendError( |
4436 "Must include string id."); | 4434 "Must include string id."); |
4437 return; | 4435 return; |
4438 } | 4436 } |
4439 ExtensionService* service = profile()->GetExtensionService(); | 4437 ExtensionService* service = profile()->GetExtensionService(); |
4440 if (!service) { | 4438 if (!service) { |
(...skipping 13 matching lines...) Expand all Loading... |
4454 | 4452 |
4455 // Wait for a notification indicating that the extension with the given ID | 4453 // Wait for a notification indicating that the extension with the given ID |
4456 // has been uninstalled. This observer will delete itself. | 4454 // has been uninstalled. This observer will delete itself. |
4457 new ExtensionUninstallObserver(this, reply_message, id); | 4455 new ExtensionUninstallObserver(this, reply_message, id); |
4458 service->UninstallExtension(id, false, NULL); | 4456 service->UninstallExtension(id, false, NULL); |
4459 } | 4457 } |
4460 | 4458 |
4461 // See SetExtensionStateById() in chrome/test/pyautolib/pyauto.py | 4459 // See SetExtensionStateById() in chrome/test/pyautolib/pyauto.py |
4462 // for sample json input. | 4460 // for sample json input. |
4463 void TestingAutomationProvider::SetExtensionStateById( | 4461 void TestingAutomationProvider::SetExtensionStateById( |
4464 Browser* browser, | |
4465 DictionaryValue* args, | 4462 DictionaryValue* args, |
4466 IPC::Message* reply_message) { | 4463 IPC::Message* reply_message) { |
4467 AutomationJSONReply reply(this, reply_message); | |
4468 std::string id; | 4464 std::string id; |
4469 if (!args->GetString("id", &id)) { | 4465 if (!args->GetString("id", &id)) { |
4470 reply.SendError("Missing or invalid key: id"); | 4466 AutomationJSONReply(this, reply_message) |
| 4467 .SendError("Missing or invalid key: id"); |
4471 return; | 4468 return; |
4472 } | 4469 } |
4473 | 4470 |
4474 bool enable; | 4471 bool enable; |
4475 if (!args->GetBoolean("enable", &enable)) { | 4472 if (!args->GetBoolean("enable", &enable)) { |
4476 reply.SendError("Missing or invalid key: enable"); | 4473 AutomationJSONReply(this, reply_message) |
| 4474 .SendError("Missing or invalid key: enable"); |
4477 return; | 4475 return; |
4478 } | 4476 } |
4479 | 4477 |
4480 bool allow_in_incognito; | 4478 bool allow_in_incognito; |
4481 if (!args->GetBoolean("allow_in_incognito", &allow_in_incognito)) { | 4479 if (!args->GetBoolean("allow_in_incognito", &allow_in_incognito)) { |
4482 reply.SendError("Missing or invalid key: allow_in_incognito"); | 4480 AutomationJSONReply(this, reply_message) |
| 4481 .SendError("Missing or invalid key: allow_in_incognito"); |
4483 return; | 4482 return; |
4484 } | 4483 } |
4485 | 4484 |
4486 if (allow_in_incognito && !enable) { | 4485 if (allow_in_incognito && !enable) { |
4487 reply.SendError("Invalid state: Disabled extension " | 4486 AutomationJSONReply(this, reply_message) |
| 4487 .SendError("Invalid state: Disabled extension " |
4488 "cannot be allowed in incognito mode."); | 4488 "cannot be allowed in incognito mode."); |
4489 return; | 4489 return; |
4490 } | 4490 } |
4491 | 4491 |
4492 ExtensionService* service = profile()->GetExtensionService(); | 4492 ExtensionService* service = profile()->GetExtensionService(); |
| 4493 ExtensionProcessManager* manager = profile()->GetExtensionProcessManager(); |
4493 if (!service) { | 4494 if (!service) { |
4494 reply.SendError("No extensions service."); | 4495 AutomationJSONReply(this, reply_message) |
| 4496 .SendError("No extensions service or process manager."); |
4495 return; | 4497 return; |
4496 } | 4498 } |
4497 | 4499 |
4498 if (!service->GetExtensionById(id, true) && | 4500 if (!service->GetExtensionById(id, true) && |
4499 !service->GetTerminatedExtension(id)) { | 4501 !service->GetTerminatedExtension(id)) { |
4500 // The extension ID does not correspond to any extension, whether crashed | 4502 // The extension ID does not correspond to any extension, whether crashed |
4501 // or not. | 4503 // or not. |
4502 reply.SendError(base::StringPrintf("Extension does not exist: %s.", | 4504 AutomationJSONReply(this, reply_message).SendError( |
4503 id.c_str())); | 4505 base::StringPrintf("Extension does not exist: %s.", id.c_str())); |
4504 return; | 4506 return; |
4505 } | 4507 } |
4506 | 4508 |
4507 if (enable) | 4509 service->SetIsIncognitoEnabled(id, allow_in_incognito); |
4508 service->EnableExtension(id); | 4510 |
4509 else | 4511 if (enable) { |
| 4512 if (!service->IsExtensionEnabled(id)) { |
| 4513 new ExtensionReadyNotificationObserver( |
| 4514 manager, |
| 4515 service, |
| 4516 this, |
| 4517 reply_message); |
| 4518 service->EnableExtension(id); |
| 4519 } else { |
| 4520 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 4521 } |
| 4522 } else { |
4510 service->DisableExtension(id); | 4523 service->DisableExtension(id); |
4511 | 4524 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
4512 service->SetIsIncognitoEnabled(id, allow_in_incognito); | 4525 } |
4513 reply.SendSuccess(NULL); | |
4514 } | 4526 } |
4515 | 4527 |
4516 // See TriggerPageActionById() in chrome/test/pyautolib/pyauto.py | 4528 // See TriggerPageActionById() in chrome/test/pyautolib/pyauto.py |
4517 // for sample json input. | 4529 // for sample json input. |
4518 void TestingAutomationProvider::TriggerPageActionById( | 4530 void TestingAutomationProvider::TriggerPageActionById( |
4519 DictionaryValue* args, | 4531 DictionaryValue* args, |
4520 IPC::Message* reply_message) { | 4532 IPC::Message* reply_message) { |
4521 AutomationJSONReply reply(this, reply_message); | 4533 AutomationJSONReply reply(this, reply_message); |
4522 | 4534 |
4523 std::string error; | 4535 std::string error; |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5625 NativeWebKeyboardEvent event; | 5637 NativeWebKeyboardEvent event; |
5626 // In the event of an error, BuildWebKeyEventFromArgs handles telling what | 5638 // In the event of an error, BuildWebKeyEventFromArgs handles telling what |
5627 // went wrong and sending the reply message; if it fails, we just have to | 5639 // went wrong and sending the reply message; if it fails, we just have to |
5628 // stop here. | 5640 // stop here. |
5629 std::string error; | 5641 std::string error; |
5630 if (!BuildWebKeyEventFromArgs(args, &error, &event)) { | 5642 if (!BuildWebKeyEventFromArgs(args, &error, &event)) { |
5631 AutomationJSONReply(this, reply_message).SendError(error); | 5643 AutomationJSONReply(this, reply_message).SendError(error); |
5632 return; | 5644 return; |
5633 } | 5645 } |
5634 | 5646 |
5635 TabContents* tab_contents; | 5647 RenderViewHost* view; |
5636 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 5648 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
5637 AutomationJSONReply(this, reply_message).SendError(error); | 5649 AutomationJSONReply(this, reply_message).SendError(error); |
5638 return; | 5650 return; |
5639 } | 5651 } |
5640 new InputEventAckNotificationObserver(this, reply_message, event.type, 1); | 5652 new InputEventAckNotificationObserver(this, reply_message, event.type, 1); |
5641 tab_contents->render_view_host()->ForwardKeyboardEvent(event); | 5653 view->ForwardKeyboardEvent(event); |
5642 } | 5654 } |
5643 | 5655 |
5644 void TestingAutomationProvider::SendOSLevelKeyEventToTab( | 5656 void TestingAutomationProvider::SendOSLevelKeyEventToTab( |
5645 DictionaryValue* args, | 5657 DictionaryValue* args, |
5646 IPC::Message* reply_message) { | 5658 IPC::Message* reply_message) { |
5647 if (SendErrorIfModalDialogActive(this, reply_message)) | 5659 if (SendErrorIfModalDialogActive(this, reply_message)) |
5648 return; | 5660 return; |
5649 | 5661 |
5650 int modifiers, keycode; | 5662 int modifiers, keycode; |
5651 if (!args->GetInteger("keyCode", &keycode)) { | 5663 if (!args->GetInteger("keyCode", &keycode)) { |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6057 } | 6069 } |
6058 | 6070 |
6059 void TestingAutomationProvider::ExecuteJavascriptJSON( | 6071 void TestingAutomationProvider::ExecuteJavascriptJSON( |
6060 DictionaryValue* args, | 6072 DictionaryValue* args, |
6061 IPC::Message* reply_message) { | 6073 IPC::Message* reply_message) { |
6062 if (SendErrorIfModalDialogActive(this, reply_message)) | 6074 if (SendErrorIfModalDialogActive(this, reply_message)) |
6063 return; | 6075 return; |
6064 | 6076 |
6065 string16 frame_xpath, javascript; | 6077 string16 frame_xpath, javascript; |
6066 std::string error; | 6078 std::string error; |
6067 TabContents* tab_contents; | 6079 RenderViewHost* render_view; |
6068 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 6080 if (!GetRenderViewFromJSONArgs(args, profile(), &render_view, &error)) { |
6069 AutomationJSONReply(this, reply_message).SendError(error); | 6081 AutomationJSONReply(this, reply_message).SendError(error); |
6070 return; | 6082 return; |
6071 } | 6083 } |
6072 if (!args->GetString("frame_xpath", &frame_xpath)) { | 6084 if (!args->GetString("frame_xpath", &frame_xpath)) { |
6073 AutomationJSONReply(this, reply_message) | 6085 AutomationJSONReply(this, reply_message) |
6074 .SendError("'frame_xpath' missing or invalid"); | 6086 .SendError("'frame_xpath' missing or invalid"); |
6075 return; | 6087 return; |
6076 } | 6088 } |
6077 if (!args->GetString("javascript", &javascript)) { | 6089 if (!args->GetString("javascript", &javascript)) { |
6078 AutomationJSONReply(this, reply_message) | 6090 AutomationJSONReply(this, reply_message) |
6079 .SendError("'javascript' missing or invalid"); | 6091 .SendError("'javascript' missing or invalid"); |
6080 return; | 6092 return; |
6081 } | 6093 } |
6082 | 6094 |
6083 new DomOperationMessageSender(this, reply_message, true); | 6095 new DomOperationMessageSender(this, reply_message, true); |
6084 ExecuteJavascriptInRenderViewFrame(frame_xpath, javascript, reply_message, | 6096 ExecuteJavascriptInRenderViewFrame(frame_xpath, javascript, reply_message, |
6085 tab_contents->render_view_host()); | 6097 render_view); |
6086 } | 6098 } |
6087 | 6099 |
6088 void TestingAutomationProvider::ExecuteJavascriptInRenderView( | 6100 void TestingAutomationProvider::ExecuteJavascriptInRenderView( |
6089 DictionaryValue* args, | 6101 DictionaryValue* args, |
6090 IPC::Message* reply_message) { | 6102 IPC::Message* reply_message) { |
6091 string16 frame_xpath, javascript, extension_id, url_text; | 6103 string16 frame_xpath, javascript, extension_id, url_text; |
6092 std::string error; | 6104 std::string error; |
6093 int render_process_id, render_view_id; | 6105 int render_process_id, render_view_id; |
6094 if (!args->GetString("frame_xpath", &frame_xpath)) { | 6106 if (!args->GetString("frame_xpath", &frame_xpath)) { |
6095 AutomationJSONReply(this, reply_message) | 6107 AutomationJSONReply(this, reply_message) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6184 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 6196 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
6185 AutomationJSONReply(this, reply_message).SendError(error); | 6197 AutomationJSONReply(this, reply_message).SendError(error); |
6186 return; | 6198 return; |
6187 } | 6199 } |
6188 NavigationController& controller = tab_contents->controller(); | 6200 NavigationController& controller = tab_contents->controller(); |
6189 new NavigationNotificationObserver(&controller, this, reply_message, | 6201 new NavigationNotificationObserver(&controller, this, reply_message, |
6190 1, false, true); | 6202 1, false, true); |
6191 controller.Reload(false); | 6203 controller.Reload(false); |
6192 } | 6204 } |
6193 | 6205 |
6194 void TestingAutomationProvider::GetTabURLJSON( | |
6195 DictionaryValue* args, | |
6196 IPC::Message* reply_message) { | |
6197 AutomationJSONReply reply(this, reply_message); | |
6198 TabContents* tab_contents; | |
6199 std::string error; | |
6200 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | |
6201 reply.SendError(error); | |
6202 return; | |
6203 } | |
6204 DictionaryValue dict; | |
6205 dict.SetString("url", tab_contents->GetURL().possibly_invalid_spec()); | |
6206 reply.SendSuccess(&dict); | |
6207 } | |
6208 | |
6209 void TestingAutomationProvider::GetTabTitleJSON( | |
6210 DictionaryValue* args, | |
6211 IPC::Message* reply_message) { | |
6212 AutomationJSONReply reply(this, reply_message); | |
6213 TabContents* tab_contents; | |
6214 std::string error; | |
6215 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | |
6216 reply.SendError(error); | |
6217 return; | |
6218 } | |
6219 DictionaryValue dict; | |
6220 dict.SetString("title", tab_contents->GetTitle()); | |
6221 reply.SendSuccess(&dict); | |
6222 } | |
6223 | |
6224 void TestingAutomationProvider::CaptureEntirePageJSON( | 6206 void TestingAutomationProvider::CaptureEntirePageJSON( |
6225 DictionaryValue* args, | 6207 DictionaryValue* args, |
6226 IPC::Message* reply_message) { | 6208 IPC::Message* reply_message) { |
6227 if (SendErrorIfModalDialogActive(this, reply_message)) | 6209 if (SendErrorIfModalDialogActive(this, reply_message)) |
6228 return; | 6210 return; |
6229 | 6211 |
6230 TabContents* tab_contents; | 6212 TabContents* tab_contents; |
6231 std::string error; | 6213 std::string error; |
6232 | 6214 |
6233 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { | 6215 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6281 int id = browser->GetTabContentsWrapperAt(i)->restore_tab_helper()-> | 6263 int id = browser->GetTabContentsWrapperAt(i)->restore_tab_helper()-> |
6282 session_id().id(); | 6264 session_id().id(); |
6283 id_list->Append(Value::CreateIntegerValue(id)); | 6265 id_list->Append(Value::CreateIntegerValue(id)); |
6284 } | 6266 } |
6285 } | 6267 } |
6286 DictionaryValue dict; | 6268 DictionaryValue dict; |
6287 dict.Set("ids", id_list); | 6269 dict.Set("ids", id_list); |
6288 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 6270 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
6289 } | 6271 } |
6290 | 6272 |
| 6273 void TestingAutomationProvider::GetViews( |
| 6274 DictionaryValue* args, IPC::Message* reply_message) { |
| 6275 ListValue* view_list = new ListValue(); |
| 6276 BrowserList::const_iterator browser_iter = BrowserList::begin(); |
| 6277 for (; browser_iter != BrowserList::end(); ++browser_iter) { |
| 6278 Browser* browser = *browser_iter; |
| 6279 for (int i = 0; i < browser->tab_count(); ++i) { |
| 6280 DictionaryValue* dict = new DictionaryValue(); |
| 6281 AutomationId id = automation_util::GetIdForTab( |
| 6282 browser->GetTabContentsWrapperAt(i)); |
| 6283 dict->Set("auto_id", id.ToValue()); |
| 6284 view_list->Append(dict); |
| 6285 } |
| 6286 } |
| 6287 |
| 6288 ExtensionProcessManager* extension_mgr = |
| 6289 profile()->GetExtensionProcessManager(); |
| 6290 ExtensionProcessManager::const_iterator iter; |
| 6291 for (iter = extension_mgr->begin(); iter != extension_mgr->end(); |
| 6292 ++iter) { |
| 6293 ExtensionHost* host = *iter; |
| 6294 DictionaryValue* dict = new DictionaryValue(); |
| 6295 AutomationId id = automation_util::GetIdForExtensionView(host); |
| 6296 if (!id.is_valid()) |
| 6297 continue; |
| 6298 dict->Set("auto_id", id.ToValue()); |
| 6299 dict->Set("extension_id", automation_util::GetIdForExtension( |
| 6300 host->extension()).ToValue()); |
| 6301 view_list->Append(dict); |
| 6302 } |
| 6303 DictionaryValue dict; |
| 6304 dict.Set("views", view_list); |
| 6305 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 6306 } |
| 6307 |
6291 void TestingAutomationProvider::IsTabIdValid( | 6308 void TestingAutomationProvider::IsTabIdValid( |
6292 DictionaryValue* args, IPC::Message* reply_message) { | 6309 DictionaryValue* args, IPC::Message* reply_message) { |
6293 AutomationJSONReply reply(this, reply_message); | 6310 AutomationJSONReply reply(this, reply_message); |
6294 int id; | 6311 int id; |
6295 if (!args->GetInteger("id", &id)) { | 6312 if (!args->GetInteger("id", &id)) { |
6296 reply.SendError("'id' missing or invalid"); | 6313 reply.SendError("'id' missing or invalid"); |
6297 return; | 6314 return; |
6298 } | 6315 } |
6299 bool is_valid = false; | 6316 bool is_valid = false; |
6300 BrowserList::const_iterator iter = BrowserList::begin(); | 6317 BrowserList::const_iterator iter = BrowserList::begin(); |
6301 for (; iter != BrowserList::end(); ++iter) { | 6318 for (; iter != BrowserList::end(); ++iter) { |
6302 Browser* browser = *iter; | 6319 Browser* browser = *iter; |
6303 for (int i = 0; i < browser->tab_count(); ++i) { | 6320 for (int i = 0; i < browser->tab_count(); ++i) { |
6304 TabContentsWrapper* tab = browser->GetTabContentsWrapperAt(i); | 6321 TabContentsWrapper* tab = browser->GetTabContentsWrapperAt(i); |
6305 if (tab->restore_tab_helper()->session_id().id() == id) { | 6322 if (tab->restore_tab_helper()->session_id().id() == id) { |
6306 is_valid = true; | 6323 is_valid = true; |
6307 break; | 6324 break; |
6308 } | 6325 } |
6309 } | 6326 } |
6310 } | 6327 } |
6311 DictionaryValue dict; | 6328 DictionaryValue dict; |
6312 dict.SetBoolean("is_valid", is_valid); | 6329 dict.SetBoolean("is_valid", is_valid); |
6313 reply.SendSuccess(&dict); | 6330 reply.SendSuccess(&dict); |
6314 } | 6331 } |
6315 | 6332 |
| 6333 void TestingAutomationProvider::DoesAutomationObjectExist( |
| 6334 DictionaryValue* args, IPC::Message* reply_message) { |
| 6335 AutomationJSONReply reply(this, reply_message); |
| 6336 AutomationId id; |
| 6337 std::string error_msg; |
| 6338 if (!GetAutomationIdFromJSONArgs(args, "auto_id", &id, &error_msg)) { |
| 6339 reply.SendError(error_msg); |
| 6340 return; |
| 6341 } |
| 6342 DictionaryValue dict; |
| 6343 dict.SetBoolean( |
| 6344 "does_exist", |
| 6345 automation_util::DoesObjectWithIdExist(id, profile())); |
| 6346 reply.SendSuccess(&dict); |
| 6347 } |
| 6348 |
6316 void TestingAutomationProvider::CloseTabJSON( | 6349 void TestingAutomationProvider::CloseTabJSON( |
6317 DictionaryValue* args, IPC::Message* reply_message) { | 6350 DictionaryValue* args, IPC::Message* reply_message) { |
6318 AutomationJSONReply reply(this, reply_message); | 6351 AutomationJSONReply reply(this, reply_message); |
6319 Browser* browser; | 6352 RenderViewHost* view; |
6320 TabContents* tab_contents; | |
6321 std::string error; | 6353 std::string error; |
6322 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &tab_contents, &error)) { | 6354 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
6323 reply.SendError(error); | 6355 reply.SendError(error); |
6324 return; | 6356 return; |
6325 } | 6357 } |
6326 browser->CloseTabContents(tab_contents); | 6358 view->ClosePage(); |
6327 reply.SendSuccess(NULL); | 6359 reply.SendSuccess(NULL); |
6328 } | 6360 } |
6329 | 6361 |
6330 void TestingAutomationProvider::ActivateTabJSON( | 6362 void TestingAutomationProvider::ActivateTabJSON( |
6331 DictionaryValue* args, | 6363 DictionaryValue* args, |
6332 IPC::Message* reply_message) { | 6364 IPC::Message* reply_message) { |
6333 if (SendErrorIfModalDialogActive(this, reply_message)) | 6365 if (SendErrorIfModalDialogActive(this, reply_message)) |
6334 return; | 6366 return; |
6335 | 6367 |
6336 AutomationJSONReply reply(this, reply_message); | 6368 AutomationJSONReply reply(this, reply_message); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6561 | 6593 |
6562 Send(reply_message_); | 6594 Send(reply_message_); |
6563 redirect_query_ = 0; | 6595 redirect_query_ = 0; |
6564 reply_message_ = NULL; | 6596 reply_message_ = NULL; |
6565 } | 6597 } |
6566 | 6598 |
6567 void TestingAutomationProvider::OnRemoveProvider() { | 6599 void TestingAutomationProvider::OnRemoveProvider() { |
6568 if (g_browser_process) | 6600 if (g_browser_process) |
6569 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6601 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
6570 } | 6602 } |
OLD | NEW |