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 or |
27 // handle. Returns true on success. | 44 // |TabProxy| handle. Returns true on success. |
28 bool SendGetIndicesFromTabJSONRequest( | 45 bool SendGetIndicesFromTabJSONRequest( |
29 AutomationMessageSender* sender, | 46 AutomationMessageSender* sender, |
30 int handle, | 47 int id_or_handle, |
Paweł Hajdan Jr.
2011/03/05 11:44:56
This looks like a very unintuitive interface. Can
kkania
2011/03/07 04:31:51
Ok, I separated into two functions.
| |
48 bool is_id, | |
31 int* browser_index, | 49 int* browser_index, |
32 int* tab_index) WARN_UNUSED_RESULT; | 50 int* tab_index) WARN_UNUSED_RESULT; |
33 | 51 |
34 // Requests to navigate to the given url and wait for the given number of | 52 // Requests to navigate to the given url and wait for the given number of |
35 // navigations to complete. Returns true on success. | 53 // navigations to complete. Returns true on success. |
36 bool SendNavigateToURLJSONRequest( | 54 bool SendNavigateToURLJSONRequest( |
37 AutomationMessageSender* sender, | 55 AutomationMessageSender* sender, |
38 int browser_index, | 56 int browser_index, |
39 int tab_index, | 57 int tab_index, |
40 const GURL& url, | 58 const GURL& url, |
41 int navigation_count, | 59 int navigation_count, |
42 AutomationMsg_NavigationResponseValues* nav_response) WARN_UNUSED_RESULT; | 60 AutomationMsg_NavigationResponseValues* nav_response) WARN_UNUSED_RESULT; |
43 | 61 |
62 // Requests the given javascript to be executed in the frame specified by the | |
63 // given xpath. Returns true on success. If true, |result| will be set to the | |
64 // result of the execution and ownership will be given to the caller. | |
65 bool SendExecuteJavascriptJSONRequest( | |
66 AutomationMessageSender* sender, | |
67 int browser_index, | |
68 int tab_index, | |
69 const std::string& frame_xpath, | |
70 const std::string& javascript, | |
71 Value** result) WARN_UNUSED_RESULT; | |
72 | |
73 // Requests the specified tab to go forward. Waits for the load to complete. | |
74 // Returns true on success. | |
75 bool SendGoForwardJSONRequest( | |
76 AutomationMessageSender* sender, | |
77 int browser_index, | |
78 int tab_index) WARN_UNUSED_RESULT; | |
79 | |
80 // Requests the specified tab to go back. Waits for the load to complete. | |
81 // Returns true on success. | |
82 bool SendGoBackJSONRequest( | |
83 AutomationMessageSender* sender, | |
84 int browser_index, | |
85 int tab_index) WARN_UNUSED_RESULT; | |
86 | |
87 // Requests the specified tab to reload. Waits for the load to complete. | |
88 // Returns true on success. | |
89 bool SendReloadJSONRequest( | |
90 AutomationMessageSender* sender, | |
91 int browser_index, | |
92 int tab_index) WARN_UNUSED_RESULT; | |
93 | |
94 // Requests the url of the specified tab. Returns true on success. | |
95 bool SendGetTabURLJSONRequest( | |
96 AutomationMessageSender* sender, | |
97 int browser_index, | |
98 int tab_index, | |
99 std::string* url) WARN_UNUSED_RESULT; | |
100 | |
101 // Requests the title of the specified tab. Returns true on success. | |
102 bool SendGetTabTitleJSONRequest( | |
103 AutomationMessageSender* sender, | |
104 int browser_index, | |
105 int tab_index, | |
106 std::string* tab_title) WARN_UNUSED_RESULT; | |
107 | |
108 // Requests all the cookies for the given URL. Returns true on success. | |
109 bool SendGetCookiesJSONRequest( | |
110 AutomationMessageSender* sender, | |
111 int browser_index, | |
112 const std::string& url, | |
113 std::string* cookies) WARN_UNUSED_RESULT; | |
114 | |
115 // Requests deletion of the cookie with the given name and URL. Returns true | |
116 // on success. | |
117 bool SendDeleteCookieJSONRequest( | |
118 AutomationMessageSender* sender, | |
119 int browser_index, | |
120 const std::string& url, | |
121 const std::string& cookie_name) WARN_UNUSED_RESULT; | |
122 | |
123 // Requests setting the given cookie for the given URL. Returns true on | |
124 // success. | |
125 bool SendSetCookieJSONRequest( | |
126 AutomationMessageSender* sender, | |
127 int browser_index, | |
128 const std::string& url, | |
129 const std::string& cookie) WARN_UNUSED_RESULT; | |
130 | |
131 // Requests the IDs for all open tabs. Returns true on success. | |
132 bool SendGetTabIdsJSONRequest( | |
133 AutomationMessageSender* sender, | |
134 std::vector<int>* tab_ids) WARN_UNUSED_RESULT; | |
135 | |
136 // Requests whether the given tab ID is valid. Returns true on success. | |
137 bool SendIsTabIdValidJSONRequest( | |
138 AutomationMessageSender* sender, | |
139 int tab_id, | |
140 bool* is_valid) WARN_UNUSED_RESULT; | |
141 | |
142 // Requests to close the given tab. Returns true on success. | |
143 bool SendCloseTabJSONRequest( | |
144 AutomationMessageSender* sender, | |
145 int browser_index, | |
146 int tab_index) WARN_UNUSED_RESULT; | |
147 | |
148 // Requests to send the WebKit event for a mouse move to the given | |
149 // coordinate in the specified tab. Returns true on success. | |
150 bool SendMouseMoveJSONRequest( | |
151 AutomationMessageSender* sender, | |
152 int browser_index, | |
153 int tab_index, | |
154 int x, | |
155 int y) WARN_UNUSED_RESULT; | |
156 | |
157 // Requests to send the WebKit events for a mouse click at the given | |
158 // coordinate in the specified tab. Returns true on success. | |
159 bool SendMouseClickJSONRequest( | |
160 AutomationMessageSender* sender, | |
161 int browser_index, | |
162 int tab_index, | |
163 automation::MouseButton button, | |
164 int x, | |
165 int y) WARN_UNUSED_RESULT; | |
166 | |
167 // Requests to send the WebKit events for a mouse drag from the start to end | |
168 // coordinates given in the specified tab. Returns true on success. | |
169 bool SendMouseDragJSONRequest( | |
170 AutomationMessageSender* sender, | |
171 int browser_index, | |
172 int tab_index, | |
173 int start_x, | |
174 int start_y, | |
175 int end_x, | |
176 int end_y) WARN_UNUSED_RESULT; | |
177 | |
178 // Requests to send the WebKit event for the given |WebKeyEvent| in a | |
179 // specified tab. Returns true on success. | |
180 bool SendWebKeyEventJSONRequest( | |
181 AutomationMessageSender* sender, | |
182 int browser_index, | |
183 int tab_index, | |
184 const WebKeyEvent& key_event) WARN_UNUSED_RESULT; | |
185 | |
186 // Requests to wait for all tabs to stop loading. Returns true on success. | |
187 bool SendWaitForAllTabsToStopLoadingJSONRequest( | |
188 AutomationMessageSender* sender) WARN_UNUSED_RESULT; | |
189 | |
44 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_JSON_REQUESTS_H_ | 190 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_JSON_REQUESTS_H_ |
OLD | NEW |