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