From 457f5cf27e7b74c5e6d161015532794f2ae88365 Mon Sep 17 00:00:00 2001 From: "phajdan.jr@chromium.org" Date: Tue, 18 Aug 2009 16:37:52 +0000 Subject: Cleanup in AutomationProvider's navigation observer. Remove unnecessary parameters. Instead of making the callers customize the return codes, just standardize on already present constants. This is a preparation needed before implementing waiting for multiple navigations. TEST=Covered by ui_tests. http://crbug.com/19395 Review URL: http://codereview.chromium.org/171064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23634 0039d316-1c4b-4281-b951-d872f2087c98 --- .../test/automation/automation_messages_internal.h | 20 ++++++----- chrome/test/automation/tab_proxy.cc | 41 +++++++++++++--------- 2 files changed, 36 insertions(+), 25 deletions(-) (limited to 'chrome/test/automation') diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index cb7d769..5ebaca0 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -179,19 +179,17 @@ IPC_BEGIN_MESSAGES(Automation) // This message tells the AutomationProvider to provide the given // authentication data to the specified tab, in response to an HTTP/FTP // authentication challenge. - // The response status will be negative on error. IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_SetAuth, int, // tab handle std::wstring, // username std::wstring, // password - int) // status + AutomationMsg_NavigationResponseValues) // status // This message tells the AutomationProvider to cancel the login in the // specified tab. - // The response status will be negative on error. IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_CancelAuth, int, // tab handle - int) // status + AutomationMsg_NavigationResponseValues) // status // Requests that the automation provider ask history for the most recent // chain of redirects coming from the given URL. The response must be @@ -461,7 +459,7 @@ IPC_BEGIN_MESSAGES(Automation) IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_ShowInterstitialPage, int, std::string, - bool) + AutomationMsg_NavigationResponseValues) // This message notifies the AutomationProvider to hide the current // interstitial page in the tab with given handle. The parameter is the @@ -607,9 +605,9 @@ IPC_BEGIN_MESSAGES(Automation) // - int: handle of the tab // - bool: whether to proceed or abort the navigation // Response: - // - bool: whether the operation was successful. + // - AutomationMsg_NavigationResponseValues: result of the operation. IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_ActionOnSSLBlockingPage, int, bool, - bool) + AutomationMsg_NavigationResponseValues) // Message to request that a browser window is brought to the front and // activated. @@ -776,7 +774,9 @@ IPC_BEGIN_MESSAGES(Automation) int /* tab_handle */, int /* info bar index */, bool /* wait for navigation */, - bool /* success flag */) + + /* navigation result */ + AutomationMsg_NavigationResponseValues) // This message retrieves the last time a navigation occurred in the specified // tab. The value is intended to be used with WaitForNavigation. @@ -789,7 +789,9 @@ IPC_BEGIN_MESSAGES(Automation) IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_WaitForNavigation, int /* tab_handle */, int64 /* last navigation time */, - bool /* success */) + + /* navigation result */ + AutomationMsg_NavigationResponseValues) // This messages sets an int-value preference. IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_SetIntPreference, diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index f52f16f..6ee36a2 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -103,19 +103,21 @@ bool TabProxy::SetAuth(const std::wstring& username, if (!is_valid()) return false; - int navigate_response = -1; + AutomationMsg_NavigationResponseValues navigate_response = + AUTOMATION_MSG_NAVIGATION_ERROR; sender_->Send(new AutomationMsg_SetAuth(0, handle_, username, password, &navigate_response)); - return navigate_response >= 0; + return navigate_response == AUTOMATION_MSG_NAVIGATION_SUCCESS; } bool TabProxy::CancelAuth() { if (!is_valid()) return false; - int navigate_response = -1; + AutomationMsg_NavigationResponseValues navigate_response = + AUTOMATION_MSG_NAVIGATION_ERROR; sender_->Send(new AutomationMsg_CancelAuth(0, handle_, &navigate_response)); - return navigate_response >= 0; + return navigate_response == AUTOMATION_MSG_NAVIGATION_SUCCESS; } bool TabProxy::NeedsAuth() const { @@ -420,10 +422,11 @@ bool TabProxy::ShowInterstitialPage(const std::string& html_text, if (!is_valid()) return false; - bool succeeded = false; + AutomationMsg_NavigationResponseValues result = + AUTOMATION_MSG_NAVIGATION_ERROR; sender_->SendWithTimeout(new AutomationMsg_ShowInterstitialPage( - 0, handle_, html_text, &succeeded), timeout_ms, NULL); - return succeeded; + 0, handle_, html_text, &result), timeout_ms, NULL); + return result == AUTOMATION_MSG_NAVIGATION_SUCCESS; } bool TabProxy::HideInterstitialPage() { @@ -506,10 +509,12 @@ bool TabProxy::TakeActionOnSSLBlockingPage(bool proceed) { if (!is_valid()) return false; - bool success = false; + AutomationMsg_NavigationResponseValues result = + AUTOMATION_MSG_NAVIGATION_ERROR; sender_->Send(new AutomationMsg_ActionOnSSLBlockingPage(0, handle_, proceed, - &success)); - return success; + &result)); + return result == AUTOMATION_MSG_NAVIGATION_SUCCESS || + result == AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED; } bool TabProxy::PrintNow() { @@ -566,10 +571,12 @@ bool TabProxy::ClickSSLInfoBarLink(int info_bar_index, if (!is_valid()) return false; - bool success = false; + AutomationMsg_NavigationResponseValues result = + AUTOMATION_MSG_NAVIGATION_ERROR; sender_->Send(new AutomationMsg_ClickSSLInfoBarLink( - 0, handle_, info_bar_index, wait_for_navigation, &success)); - return success; + 0, handle_, info_bar_index, wait_for_navigation, &result)); + return result == AUTOMATION_MSG_NAVIGATION_SUCCESS || + result == AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED; } bool TabProxy::GetLastNavigationTime(int64* nav_time) { @@ -586,11 +593,13 @@ bool TabProxy::WaitForNavigation(int64 last_navigation_time) { if (!is_valid()) return false; - bool success = false; + AutomationMsg_NavigationResponseValues result = + AUTOMATION_MSG_NAVIGATION_ERROR; sender_->Send(new AutomationMsg_WaitForNavigation(0, handle_, last_navigation_time, - &success)); - return success; + &result)); + return result == AUTOMATION_MSG_NAVIGATION_SUCCESS || + result == AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED; } bool TabProxy::GetPageCurrentEncoding(std::wstring* encoding) { -- cgit v1.1