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_TAB_PROXY_H_ | 5 #ifndef CHROME_TEST_AUTOMATION_TAB_PROXY_H_ |
6 #define CHROME_TEST_AUTOMATION_TAB_PROXY_H_ | 6 #define CHROME_TEST_AUTOMATION_TAB_PROXY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" // NOLINT | 9 #include "build/build_config.h" // NOLINT |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 virtual void OnChannelError(TabProxy* tab) {} | 50 virtual void OnChannelError(TabProxy* tab) {} |
51 | 51 |
52 protected: | 52 protected: |
53 virtual ~TabProxyDelegate() {} | 53 virtual ~TabProxyDelegate() {} |
54 }; | 54 }; |
55 | 55 |
56 TabProxy(AutomationMessageSender* sender, | 56 TabProxy(AutomationMessageSender* sender, |
57 AutomationHandleTracker* tracker, | 57 AutomationHandleTracker* tracker, |
58 int handle); | 58 int handle); |
59 | 59 |
60 // Gets the browser that holds this tab. | |
61 scoped_refptr<BrowserProxy> GetParentBrowser() const; | |
62 | |
63 // Gets the current url of the tab. | 60 // Gets the current url of the tab. |
64 bool GetCurrentURL(GURL* url) const WARN_UNUSED_RESULT; | 61 bool GetCurrentURL(GURL* url) const WARN_UNUSED_RESULT; |
65 | 62 |
66 // Gets the title of the tab. | 63 // Gets the title of the tab. |
67 bool GetTabTitle(std::wstring* title) const WARN_UNUSED_RESULT; | 64 bool GetTabTitle(std::wstring* title) const WARN_UNUSED_RESULT; |
68 | 65 |
69 // Gets the tabstrip index of the tab. | 66 // Gets the tabstrip index of the tab. |
70 bool GetTabIndex(int* index) const WARN_UNUSED_RESULT; | 67 bool GetTabIndex(int* index) const WARN_UNUSED_RESULT; |
71 | 68 |
72 // Executes a javascript in a frame's context whose xpath is provided as the | 69 // Executes a javascript in a frame's context whose xpath is provided as the |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 104 |
108 | 105 |
109 // Navigates to a url. This is an asynchronous version of NavigateToURL. | 106 // Navigates to a url. This is an asynchronous version of NavigateToURL. |
110 // The function returns immediately after sending the LoadURL notification | 107 // The function returns immediately after sending the LoadURL notification |
111 // to the browser. | 108 // to the browser. |
112 // TODO(vibhor): Add a callback if needed in future. | 109 // TODO(vibhor): Add a callback if needed in future. |
113 // TODO(mpcomplete): If the navigation results in an auth challenge, the | 110 // TODO(mpcomplete): If the navigation results in an auth challenge, the |
114 // TabProxy we attach won't know about it. See bug 666730. | 111 // TabProxy we attach won't know about it. See bug 666730. |
115 bool NavigateToURLAsync(const GURL& url) WARN_UNUSED_RESULT; | 112 bool NavigateToURLAsync(const GURL& url) WARN_UNUSED_RESULT; |
116 | 113 |
117 // Asynchronously navigates to a url using a non-default disposition. | |
118 // This can be used for example to open a URL in a new tab. | |
119 bool NavigateToURLAsyncWithDisposition( | |
120 const GURL& url, | |
121 WindowOpenDisposition disposition) WARN_UNUSED_RESULT; | |
122 | |
123 // Equivalent to hitting the Back button. This is a synchronous call and | 114 // Equivalent to hitting the Back button. This is a synchronous call and |
124 // hence blocks until the navigation completes. | 115 // hence blocks until the navigation completes. |
125 AutomationMsg_NavigationResponseValues GoBack() WARN_UNUSED_RESULT; | 116 AutomationMsg_NavigationResponseValues GoBack() WARN_UNUSED_RESULT; |
126 | 117 |
127 // Equivalent to hitting the Back button. This is a synchronous call and | 118 // Equivalent to hitting the Back button. This is a synchronous call and |
128 // hence blocks until the |number_of_navigations| navigations complete. | 119 // hence blocks until the |number_of_navigations| navigations complete. |
129 AutomationMsg_NavigationResponseValues GoBackBlockUntilNavigationsComplete( | 120 AutomationMsg_NavigationResponseValues GoBackBlockUntilNavigationsComplete( |
130 int number_of_navigations) WARN_UNUSED_RESULT; | 121 int number_of_navigations) WARN_UNUSED_RESULT; |
131 | 122 |
132 // Equivalent to hitting the Forward button. This is a synchronous call and | 123 // Equivalent to hitting the Forward button. This is a synchronous call and |
(...skipping 21 matching lines...) Expand all Loading... |
154 // until the browser has initiated the close (wait_until_closed = false). | 145 // until the browser has initiated the close (wait_until_closed = false). |
155 // | 146 // |
156 // When a tab is closed the browser does additional work via invoke later | 147 // When a tab is closed the browser does additional work via invoke later |
157 // and may wait for messages from the renderer. Supplying a value of true to | 148 // and may wait for messages from the renderer. Supplying a value of true to |
158 // this method waits until all processing is done. Be careful with this, | 149 // this method waits until all processing is done. Be careful with this, |
159 // when closing the last tab it is possible for the browser to shutdown BEFORE | 150 // when closing the last tab it is possible for the browser to shutdown BEFORE |
160 // the tab has completely closed. In other words, this may NOT be sent for | 151 // the tab has completely closed. In other words, this may NOT be sent for |
161 // the last tab. | 152 // the last tab. |
162 bool Close(bool wait_until_closed) WARN_UNUSED_RESULT; | 153 bool Close(bool wait_until_closed) WARN_UNUSED_RESULT; |
163 | 154 |
164 // Gets the process ID that corresponds to the content area of this tab. | |
165 // Returns true if the call was successful. If the specified tab has no | |
166 // separate process for rendering its content, the return value is true but | |
167 // the process_id is 0. | |
168 bool GetProcessID(int* process_id) const WARN_UNUSED_RESULT; | |
169 | |
170 // Starts a search within the current tab. The parameter |search_string| | 155 // Starts a search within the current tab. The parameter |search_string| |
171 // specifies what string to search for, |forward| specifies whether to search | 156 // specifies what string to search for, |forward| specifies whether to search |
172 // in forward direction, and |match_case| specifies case sensitivity | 157 // in forward direction, and |match_case| specifies case sensitivity |
173 // (true=case sensitive). |find_next| specifies whether this is a new search | 158 // (true=case sensitive). |find_next| specifies whether this is a new search |
174 // or a continuation of the old one. |ordinal| is an optional parameter that | 159 // or a continuation of the old one. |ordinal| is an optional parameter that |
175 // returns the ordinal of the active match (also known as "the 7" part of | 160 // returns the ordinal of the active match (also known as "the 7" part of |
176 // "7 of 9"). A return value of -1 indicates failure. | 161 // "7 of 9"). A return value of -1 indicates failure. |
177 int FindInPage(const std::wstring& search_string, FindInPageDirection forward, | 162 int FindInPage(const std::wstring& search_string, FindInPageDirection forward, |
178 FindInPageCase match_case, bool find_next, int* ordinal); | 163 FindInPageCase match_case, bool find_next, int* ordinal); |
179 | 164 |
180 bool GetCookies(const GURL& url, std::string* cookies) WARN_UNUSED_RESULT; | 165 bool GetCookies(const GURL& url, std::string* cookies) WARN_UNUSED_RESULT; |
181 bool GetCookieByName(const GURL& url, | 166 bool GetCookieByName(const GURL& url, |
182 const std::string& name, | 167 const std::string& name, |
183 std::string* cookies) WARN_UNUSED_RESULT; | 168 std::string* cookies) WARN_UNUSED_RESULT; |
184 bool SetCookie(const GURL& url, const std::string& value) WARN_UNUSED_RESULT; | 169 bool SetCookie(const GURL& url, const std::string& value) WARN_UNUSED_RESULT; |
185 bool DeleteCookie(const GURL& url, | |
186 const std::string& name) WARN_UNUSED_RESULT; | |
187 | |
188 // Sends a InspectElement message for the current tab. |x| and |y| are the | |
189 // coordinates that we want to simulate that the user is trying to inspect. | |
190 int InspectElement(int x, int y); | |
191 | |
192 // Gets the number of popups blocked from this tab. | |
193 bool GetBlockedPopupCount(int* count) const WARN_UNUSED_RESULT; | |
194 | |
195 // Blocks the thread until the number of blocked popup is equal to | |
196 // |target_count|. | |
197 bool WaitForBlockedPopupCountToChangeTo(int target_count, | |
198 int wait_timeout) WARN_UNUSED_RESULT; | |
199 | 170 |
200 bool GetDownloadDirectory(FilePath* download_directory) WARN_UNUSED_RESULT; | 171 bool GetDownloadDirectory(FilePath* download_directory) WARN_UNUSED_RESULT; |
201 | 172 |
202 // Shows an interstitial page. Blocks until the interstitial page | |
203 // has been loaded. Return false if a failure happens. | |
204 bool ShowInterstitialPage(const std::string& html_text) WARN_UNUSED_RESULT; | |
205 | |
206 // Hides the currently shown interstitial page. Blocks until the interstitial | |
207 // page has been hidden. Return false if a failure happens. | |
208 bool HideInterstitialPage() WARN_UNUSED_RESULT; | |
209 | |
210 #if defined(OS_WIN) | 173 #if defined(OS_WIN) |
211 // The functions in this block are for external tabs, hence Windows only. | 174 // The functions in this block are for external tabs, hence Windows only. |
212 | 175 |
213 // The container of an externally hosted tab calls this to reflect any | 176 // The container of an externally hosted tab calls this to reflect any |
214 // accelerator keys that it did not process. This gives the tab a chance | 177 // accelerator keys that it did not process. This gives the tab a chance |
215 // to handle the keys | 178 // to handle the keys |
216 bool ProcessUnhandledAccelerator(const MSG& msg) WARN_UNUSED_RESULT; | 179 bool ProcessUnhandledAccelerator(const MSG& msg) WARN_UNUSED_RESULT; |
217 | 180 |
218 // Ask the tab to set focus to either the first or last element on the page. | 181 // Ask the tab to set focus to either the first or last element on the page. |
219 // When the restore_focus_to_view parameter is true, the render view | 182 // When the restore_focus_to_view parameter is true, the render view |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 bool GetPageType(content::PageType* page_type) WARN_UNUSED_RESULT; | 215 bool GetPageType(content::PageType* page_type) WARN_UNUSED_RESULT; |
253 | 216 |
254 // Simulates the user action on the SSL blocking page. if |proceed| is true, | 217 // Simulates the user action on the SSL blocking page. if |proceed| is true, |
255 // this is equivalent to clicking the 'Proceed' button, if false to 'Take me | 218 // this is equivalent to clicking the 'Proceed' button, if false to 'Take me |
256 // out of there' button. | 219 // out of there' button. |
257 bool TakeActionOnSSLBlockingPage(bool proceed) WARN_UNUSED_RESULT; | 220 bool TakeActionOnSSLBlockingPage(bool proceed) WARN_UNUSED_RESULT; |
258 | 221 |
259 // Sends off an asynchronous request for printing. | 222 // Sends off an asynchronous request for printing. |
260 bool PrintAsync() WARN_UNUSED_RESULT; | 223 bool PrintAsync() WARN_UNUSED_RESULT; |
261 | 224 |
262 // Save the current web page. |file_name| is the HTML file name, and | |
263 // |dir_path| is the directory for saving resource files. |type| indicates | |
264 // which type we're saving as: HTML only or the complete web page. | |
265 bool SavePage(const FilePath& file_name, const FilePath& dir_path, | |
266 content::SavePageType type) WARN_UNUSED_RESULT; | |
267 | |
268 // Retrieves the number of info-bars currently showing in |count|. | |
269 bool GetInfoBarCount(size_t* count) WARN_UNUSED_RESULT; | |
270 | |
271 // Waits until the infobar count is |count|. | 225 // Waits until the infobar count is |count|. |
272 // Returns true on success. | 226 // Returns true on success. |
273 bool WaitForInfoBarCount(size_t count) WARN_UNUSED_RESULT; | 227 bool WaitForInfoBarCount(size_t count) WARN_UNUSED_RESULT; |
274 | 228 |
275 // Causes a click on the "accept" button of the info-bar at |info_bar_index|. | |
276 // If |wait_for_navigation| is true, this call does not return until a | |
277 // navigation has occurred. | |
278 bool ClickInfoBarAccept(size_t info_bar_index, | |
279 bool wait_for_navigation) WARN_UNUSED_RESULT; | |
280 | |
281 // Retrieves the time at which the last navigation occurred. This is intended | |
282 // to be used with WaitForNavigation (see below). | |
283 bool GetLastNavigationTime(int64* last_navigation_time) WARN_UNUSED_RESULT; | |
284 | |
285 // Waits for a new navigation if none as occurred since |last_navigation_time| | |
286 // The purpose of this function is for operations that causes asynchronous | |
287 // navigation to happen. | |
288 // It is supposed to be used as follow: | |
289 // int64 last_nav_time; | |
290 // tab_proxy->GetLastNavigationTime(&last_nav_time); | |
291 // tab_proxy->SomeOperationThatTriggersAnAsynchronousNavigation(); | |
292 // tab_proxy->WaitForNavigation(last_nav_time); | |
293 bool WaitForNavigation(int64 last_navigation_time) WARN_UNUSED_RESULT; | |
294 | |
295 // Gets the current used encoding of the page in the tab. | |
296 bool GetPageCurrentEncoding(std::string* encoding) WARN_UNUSED_RESULT; | |
297 | |
298 // Uses the specified encoding to override encoding of the page in the tab. | 229 // Uses the specified encoding to override encoding of the page in the tab. |
299 bool OverrideEncoding(const std::string& encoding) WARN_UNUSED_RESULT; | 230 bool OverrideEncoding(const std::string& encoding) WARN_UNUSED_RESULT; |
300 | 231 |
301 // Captures the entire page and saves as a PNG at the given path. Returns | 232 // Captures the entire page and saves as a PNG at the given path. Returns |
302 // true on success. | 233 // true on success. |
303 bool CaptureEntirePageAsPNG(const FilePath& path) WARN_UNUSED_RESULT; | 234 bool CaptureEntirePageAsPNG(const FilePath& path) WARN_UNUSED_RESULT; |
304 | 235 |
305 #if defined(OS_WIN) | 236 #if defined(OS_WIN) |
306 // Resizes the tab window. | 237 // Resizes the tab window. |
307 // The parent_window parameter allows a parent to be specified for the window | 238 // The parent_window parameter allows a parent to be specified for the window |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 const std::wstring& frame_xpath, | 293 const std::wstring& frame_xpath, |
363 const std::wstring& jscript) WARN_UNUSED_RESULT; | 294 const std::wstring& jscript) WARN_UNUSED_RESULT; |
364 | 295 |
365 private: | 296 private: |
366 base::Lock list_lock_; // Protects the observers_list_. | 297 base::Lock list_lock_; // Protects the observers_list_. |
367 ObserverList<TabProxyDelegate> observers_list_; | 298 ObserverList<TabProxyDelegate> observers_list_; |
368 DISALLOW_COPY_AND_ASSIGN(TabProxy); | 299 DISALLOW_COPY_AND_ASSIGN(TabProxy); |
369 }; | 300 }; |
370 | 301 |
371 #endif // CHROME_TEST_AUTOMATION_TAB_PROXY_H_ | 302 #endif // CHROME_TEST_AUTOMATION_TAB_PROXY_H_ |
OLD | NEW |