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 #ifndef CHROME_TEST_AUTOMATION_AUTOMATION_JSON_REQUESTS_H_ | 5 #ifndef CHROME_TEST_AUTOMATION_AUTOMATION_JSON_REQUESTS_H_ |
6 #define CHROME_TEST_AUTOMATION_AUTOMATION_JSON_REQUESTS_H_ | 6 #define CHROME_TEST_AUTOMATION_AUTOMATION_JSON_REQUESTS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
| 10 #include <vector> |
10 | 11 |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "chrome/common/automation_constants.h" | 13 #include "chrome/common/automation_constants.h" |
| 14 #include "ui/base/keycodes/keyboard_codes.h" |
13 | 15 |
14 class AutomationMessageSender; | 16 class AutomationMessageSender; |
15 class GURL; | 17 class GURL; |
| 18 class Value; |
| 19 |
| 20 struct WebKeyEvent { |
| 21 WebKeyEvent(automation::KeyEventTypes type, |
| 22 ui::KeyboardCode key_code, |
| 23 const std::string& unmodified_text, |
| 24 const std::string& modified_text, |
| 25 int modifiers); |
| 26 |
| 27 automation::KeyEventTypes type; |
| 28 ui::KeyboardCode key_code; |
| 29 std::string unmodified_text; |
| 30 std::string modified_text; |
| 31 int modifiers; |
| 32 }; |
16 | 33 |
17 // Sends a JSON request to the chrome automation provider. Returns true | 34 // Sends a JSON request to the chrome automation provider. Returns true |
18 // if the JSON request was successfully sent and the reply was received. | 35 // if the JSON request was successfully sent and the reply was received. |
19 // If true, |success| will be set to whether the JSON request was | 36 // If true, |success| will be set to whether the JSON request was |
20 // completed successfully by the automation provider. | 37 // completed successfully by the automation provider. |
21 bool SendAutomationJSONRequest(AutomationMessageSender* sender, | 38 bool SendAutomationJSONRequest(AutomationMessageSender* sender, |
22 const std::string& request, | 39 const std::string& request, |
23 std::string* reply, | 40 std::string* reply, |
24 bool* success) WARN_UNUSED_RESULT; | 41 bool* success) WARN_UNUSED_RESULT; |
25 | 42 |
26 // Requests the current browser and tab indices for the given |TabProxy| | 43 // Requests the current browser and tab indices for the given tab ID. |
27 // handle. Returns true on success. | 44 // Returns true on success. |
28 bool SendGetIndicesFromTabJSONRequest( | 45 bool SendGetIndicesFromTabIdJSONRequest( |
29 AutomationMessageSender* sender, | 46 AutomationMessageSender* sender, |
30 int handle, | 47 int tab_id, |
31 int* browser_index, | 48 int* browser_index, |
32 int* tab_index) WARN_UNUSED_RESULT; | 49 int* tab_index) WARN_UNUSED_RESULT; |
33 | 50 |
| 51 // Requests the current browser and tab indices for the given |TabProxy| |
| 52 // handle. Returns true on success. |
| 53 bool SendGetIndicesFromTabHandleJSONRequest( |
| 54 AutomationMessageSender* sender, |
| 55 int tab_proxy_handle, |
| 56 int* browser_index, |
| 57 int* tab_index) WARN_UNUSED_RESULT; |
| 58 |
34 // Requests to navigate to the given url and wait for the given number of | 59 // Requests to navigate to the given url and wait for the given number of |
35 // navigations to complete. Returns true on success. | 60 // navigations to complete. Returns true on success. |
36 bool SendNavigateToURLJSONRequest( | 61 bool SendNavigateToURLJSONRequest( |
37 AutomationMessageSender* sender, | 62 AutomationMessageSender* sender, |
38 int browser_index, | 63 int browser_index, |
39 int tab_index, | 64 int tab_index, |
40 const GURL& url, | 65 const GURL& url, |
41 int navigation_count, | 66 int navigation_count, |
42 AutomationMsg_NavigationResponseValues* nav_response) WARN_UNUSED_RESULT; | 67 AutomationMsg_NavigationResponseValues* nav_response) WARN_UNUSED_RESULT; |
43 | 68 |
| 69 // Requests the given javascript to be executed in the frame specified by the |
| 70 // given xpath. Returns true on success. If true, |result| will be set to the |
| 71 // result of the execution and ownership will be given to the caller. |
| 72 bool SendExecuteJavascriptJSONRequest( |
| 73 AutomationMessageSender* sender, |
| 74 int browser_index, |
| 75 int tab_index, |
| 76 const std::string& frame_xpath, |
| 77 const std::string& javascript, |
| 78 Value** result) WARN_UNUSED_RESULT; |
| 79 |
| 80 // Requests the specified tab to go forward. Waits for the load to complete. |
| 81 // Returns true on success. |
| 82 bool SendGoForwardJSONRequest( |
| 83 AutomationMessageSender* sender, |
| 84 int browser_index, |
| 85 int tab_index) WARN_UNUSED_RESULT; |
| 86 |
| 87 // Requests the specified tab to go back. Waits for the load to complete. |
| 88 // Returns true on success. |
| 89 bool SendGoBackJSONRequest( |
| 90 AutomationMessageSender* sender, |
| 91 int browser_index, |
| 92 int tab_index) WARN_UNUSED_RESULT; |
| 93 |
| 94 // Requests the specified tab to reload. Waits for the load to complete. |
| 95 // Returns true on success. |
| 96 bool SendReloadJSONRequest( |
| 97 AutomationMessageSender* sender, |
| 98 int browser_index, |
| 99 int tab_index) WARN_UNUSED_RESULT; |
| 100 |
| 101 // Requests the url of the specified tab. Returns true on success. |
| 102 bool SendGetTabURLJSONRequest( |
| 103 AutomationMessageSender* sender, |
| 104 int browser_index, |
| 105 int tab_index, |
| 106 std::string* url) WARN_UNUSED_RESULT; |
| 107 |
| 108 // Requests the title of the specified tab. Returns true on success. |
| 109 bool SendGetTabTitleJSONRequest( |
| 110 AutomationMessageSender* sender, |
| 111 int browser_index, |
| 112 int tab_index, |
| 113 std::string* tab_title) WARN_UNUSED_RESULT; |
| 114 |
| 115 // Requests all the cookies for the given URL. Returns true on success. |
| 116 bool SendGetCookiesJSONRequest( |
| 117 AutomationMessageSender* sender, |
| 118 int browser_index, |
| 119 const std::string& url, |
| 120 std::string* cookies) WARN_UNUSED_RESULT; |
| 121 |
| 122 // Requests deletion of the cookie with the given name and URL. Returns true |
| 123 // on success. |
| 124 bool SendDeleteCookieJSONRequest( |
| 125 AutomationMessageSender* sender, |
| 126 int browser_index, |
| 127 const std::string& url, |
| 128 const std::string& cookie_name) WARN_UNUSED_RESULT; |
| 129 |
| 130 // Requests setting the given cookie for the given URL. Returns true on |
| 131 // success. |
| 132 bool SendSetCookieJSONRequest( |
| 133 AutomationMessageSender* sender, |
| 134 int browser_index, |
| 135 const std::string& url, |
| 136 const std::string& cookie) WARN_UNUSED_RESULT; |
| 137 |
| 138 // Requests the IDs for all open tabs. Returns true on success. |
| 139 bool SendGetTabIdsJSONRequest( |
| 140 AutomationMessageSender* sender, |
| 141 std::vector<int>* tab_ids) WARN_UNUSED_RESULT; |
| 142 |
| 143 // Requests whether the given tab ID is valid. Returns true on success. |
| 144 bool SendIsTabIdValidJSONRequest( |
| 145 AutomationMessageSender* sender, |
| 146 int tab_id, |
| 147 bool* is_valid) WARN_UNUSED_RESULT; |
| 148 |
| 149 // Requests to close the given tab. Returns true on success. |
| 150 bool SendCloseTabJSONRequest( |
| 151 AutomationMessageSender* sender, |
| 152 int browser_index, |
| 153 int tab_index) WARN_UNUSED_RESULT; |
| 154 |
| 155 // Requests to send the WebKit event for a mouse move to the given |
| 156 // coordinate in the specified tab. Returns true on success. |
| 157 bool SendMouseMoveJSONRequest( |
| 158 AutomationMessageSender* sender, |
| 159 int browser_index, |
| 160 int tab_index, |
| 161 int x, |
| 162 int y) WARN_UNUSED_RESULT; |
| 163 |
| 164 // Requests to send the WebKit events for a mouse click at the given |
| 165 // coordinate in the specified tab. Returns true on success. |
| 166 bool SendMouseClickJSONRequest( |
| 167 AutomationMessageSender* sender, |
| 168 int browser_index, |
| 169 int tab_index, |
| 170 automation::MouseButton button, |
| 171 int x, |
| 172 int y) WARN_UNUSED_RESULT; |
| 173 |
| 174 // Requests to send the WebKit events for a mouse drag from the start to end |
| 175 // coordinates given in the specified tab. Returns true on success. |
| 176 bool SendMouseDragJSONRequest( |
| 177 AutomationMessageSender* sender, |
| 178 int browser_index, |
| 179 int tab_index, |
| 180 int start_x, |
| 181 int start_y, |
| 182 int end_x, |
| 183 int end_y) WARN_UNUSED_RESULT; |
| 184 |
| 185 // Requests to send the WebKit event for the given |WebKeyEvent| in a |
| 186 // specified tab. Returns true on success. |
| 187 bool SendWebKeyEventJSONRequest( |
| 188 AutomationMessageSender* sender, |
| 189 int browser_index, |
| 190 int tab_index, |
| 191 const WebKeyEvent& key_event) WARN_UNUSED_RESULT; |
| 192 |
| 193 // Requests to wait for all tabs to stop loading. Returns true on success. |
| 194 bool SendWaitForAllTabsToStopLoadingJSONRequest( |
| 195 AutomationMessageSender* sender) WARN_UNUSED_RESULT; |
| 196 |
44 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_JSON_REQUESTS_H_ | 197 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_JSON_REQUESTS_H_ |
OLD | NEW |