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