diff options
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 1381 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 310 | ||||
-rw-r--r-- | chrome/common/ipc_message_macros.h | 38 | ||||
-rw-r--r-- | chrome/test/automation/autocomplete_edit_proxy.cc | 61 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 691 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.cc | 213 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.h | 36 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.cc | 303 | ||||
-rw-r--r-- | chrome/test/automation/constrained_window_proxy.cc | 40 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.cc | 430 | ||||
-rw-r--r-- | chrome/test/automation/window_proxy.cc | 119 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 16 |
12 files changed, 1507 insertions, 2131 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index b78150a..ce3e169 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -26,7 +26,6 @@ #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/ssl/ssl_manager.h" #include "chrome/browser/ssl/ssl_blocking_page.h" -#include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/web_contents.h" #include "chrome/browser/tab_contents/web_contents_view.h" #include "chrome/browser/views/bookmark_bar_view.h" @@ -34,9 +33,9 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/pref_service.h" -#include "chrome/test/automation/automation_messages.h" #include "chrome/views/app_modal_dialog_delegate.h" #include "chrome/views/window.h" +#include "chrome/test/automation/automation_messages.h" #include "net/base/cookie_monster.h" #include "net/url_request/url_request_filter.h" @@ -133,10 +132,12 @@ class NavigationControllerRestoredObserver : public NotificationObserver { public: NavigationControllerRestoredObserver(AutomationProvider* automation, NavigationController* controller, - int32 routing_id) + int32 routing_id, + IPC::Message* reply_message) : automation_(automation), controller_(controller), - routing_id_(routing_id) { + routing_id_(routing_id), + reply_message_(reply_message) { if (FinishedRestoring()) { registered_ = false; SendDone(); @@ -176,28 +177,35 @@ class NavigationControllerRestoredObserver : public NotificationObserver { } void SendDone() { - automation_->Send(new AutomationMsg_TabFinishedRestoring(routing_id_)); + DCHECK(reply_message_ != NULL); + automation_->Send(reply_message_); } bool registered_; AutomationProvider* automation_; NavigationController* controller_; const int routing_id_; + IPC::Message* reply_message_; DISALLOW_COPY_AND_ASSIGN(NavigationControllerRestoredObserver); }; +template<class NavigationCodeType> class NavigationNotificationObserver : public NotificationObserver { public: NavigationNotificationObserver(NavigationController* controller, AutomationProvider* automation, - IPC::Message* completed_response, - IPC::Message* auth_needed_response) + IPC::Message* reply_message, + NavigationCodeType success_code, + NavigationCodeType auth_needed_code, + NavigationCodeType failed_code) : automation_(automation), - completed_response_(completed_response), - auth_needed_response_(auth_needed_response), + reply_message_(reply_message), controller_(controller), - navigation_started_(false) { + navigation_started_(false), + success_code_(success_code), + auth_needed_code_(auth_needed_code), + failed_code_(failed_code) { NotificationService* service = NotificationService::current(); service->AddObserver(this, NotificationType::NAV_ENTRY_COMMITTED, Source<NavigationController>(controller_)); @@ -212,21 +220,32 @@ class NavigationNotificationObserver : public NotificationObserver { } ~NavigationNotificationObserver() { - if (completed_response_) delete completed_response_; - if (auth_needed_response_) delete auth_needed_response_; Unregister(); } - void ConditionMet(IPC::Message** response) { - if (*response) { - automation_->Send(*response); - *response = NULL; // *response is deleted by Send. - } + void ConditionMet(NavigationCodeType navigation_result) { + DCHECK(reply_message_ != NULL); + + IPC::ParamTraits<NavigationCodeType>::Write(reply_message_, + navigation_result); + automation_->Send(reply_message_); + reply_message_ = NULL; + automation_->RemoveNavigationStatusListener(this); delete this; } void Unregister() { + // This means we did not receive a notification for this navigation. + // Send over a failed navigation status back to the caller to ensure that + // the caller does not hang waiting for the response. + if (reply_message_) { + IPC::ParamTraits<NavigationCodeType>::Write(reply_message_, + failed_code_); + automation_->Send(reply_message_); + reply_message_ = NULL; + } + NotificationService* service = NotificationService::current(); service->RemoveObserver(this, NotificationType::NAV_ENTRY_COMMITTED, Source<NavigationController>(controller_)); @@ -256,7 +275,7 @@ class NavigationNotificationObserver : public NotificationObserver { } else if (type == NotificationType::LOAD_STOP) { if (navigation_started_) { navigation_started_ = false; - ConditionMet(&completed_response_); + ConditionMet(success_code_); } } else if (type == NotificationType::AUTH_SUPPLIED) { // The LoginHandler for this tab is no longer valid. @@ -274,7 +293,7 @@ class NavigationNotificationObserver : public NotificationObserver { // Respond that authentication is needed. navigation_started_ = false; - ConditionMet(&auth_needed_response_); + ConditionMet(auth_needed_code_); } else { NOTREACHED(); } @@ -285,10 +304,12 @@ class NavigationNotificationObserver : public NotificationObserver { private: AutomationProvider* automation_; - IPC::Message* completed_response_; - IPC::Message* auth_needed_response_; + IPC::Message* reply_message_; NavigationController* controller_; bool navigation_started_; + NavigationCodeType success_code_; + NavigationCodeType auth_needed_code_; + NavigationCodeType failed_code_; }; class TabStripNotificationObserver : public NotificationObserver { @@ -338,9 +359,11 @@ class TabStripNotificationObserver : public NotificationObserver { class TabAppendedNotificationObserver : public TabStripNotificationObserver { public: TabAppendedNotificationObserver(Browser* parent, - AutomationProvider* automation, int32 routing_id) + AutomationProvider* automation, int32 routing_id, + IPC::Message* reply_message) : TabStripNotificationObserver(parent, NotificationType::TAB_PARENTED, - automation, routing_id) { + automation, routing_id), + reply_message_(reply_message) { } virtual void ObserveTab(NavigationController* controller) { @@ -352,10 +375,13 @@ class TabAppendedNotificationObserver : public TabStripNotificationObserver { } // Give the same response even if auth is needed, since it doesn't matter. - automation_->AddNavigationStatusListener(controller, - new AutomationMsg_AppendTabResponse(routing_id_, tab_index), - new AutomationMsg_AppendTabResponse(routing_id_, tab_index)); + automation_->AddNavigationStatusListener<int>( + controller, reply_message_, AUTOMATION_MSG_NAVIGATION_SUCCESS, + AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED, AUTOMATION_MSG_NAVIGATION_ERROR); } + + protected: + IPC::Message* reply_message_; }; class TabClosedNotificationObserver : public TabStripNotificationObserver { @@ -363,26 +389,34 @@ class TabClosedNotificationObserver : public TabStripNotificationObserver { TabClosedNotificationObserver(Browser* parent, AutomationProvider* automation, int32 routing_id, - bool wait_until_closed) + bool wait_until_closed, + IPC::Message* reply_message) : TabStripNotificationObserver(parent, wait_until_closed ? NotificationType::TAB_CLOSED : NotificationType::TAB_CLOSING, automation, - routing_id) { + routing_id), + reply_message_(reply_message) { } virtual void ObserveTab(NavigationController* controller) { - automation_->Send(new AutomationMsg_CloseTabResponse(routing_id_, true)); + AutomationMsg_CloseTab::WriteReplyParams(reply_message_, true); + automation_->Send(reply_message_); } + + protected: + IPC::Message* reply_message_; }; class BrowserClosedNotificationObserver : public NotificationObserver { public: BrowserClosedNotificationObserver(Browser* browser, AutomationProvider* automation, - int32 routing_id) + int32 routing_id, + IPC::Message* reply_message) : automation_(automation), - routing_id_(routing_id) { + routing_id_(routing_id), + reply_message_(reply_message) { NotificationService::current()->AddObserver(this, NotificationType::BROWSER_CLOSED, Source<Browser>(browser)); } @@ -392,27 +426,31 @@ class BrowserClosedNotificationObserver : public NotificationObserver { const NotificationDetails& details) { DCHECK(type == NotificationType::BROWSER_CLOSED); Details<bool> close_app(details); - automation_->Send( - new AutomationMsg_CloseBrowserResponse(routing_id_, - true, - *(close_app.ptr()))); + DCHECK(reply_message_ != NULL); + AutomationMsg_CloseBrowser::WriteReplyParams(reply_message_, true, + *(close_app.ptr())); + automation_->Send(reply_message_); + reply_message_ = NULL; delete this; } private: AutomationProvider* automation_; int32 routing_id_; + IPC::Message* reply_message_; }; class FindInPageNotificationObserver : public NotificationObserver { public: FindInPageNotificationObserver(AutomationProvider* automation, TabContents* parent_tab, - int32 routing_id) + int32 routing_id, + IPC::Message* reply_message) : automation_(automation), parent_tab_(parent_tab), routing_id_(routing_id), - active_match_ordinal_(-1) { + active_match_ordinal_(-1), + reply_message_(reply_message) { NotificationService::current()->AddObserver( this, NotificationType::FIND_RESULT_AVAILABLE, @@ -424,6 +462,7 @@ class FindInPageNotificationObserver : public NotificationObserver { } void Unregister() { + DCHECK(reply_message_ == NULL); NotificationService::current()-> RemoveObserver(this, NotificationType::FIND_RESULT_AVAILABLE, Source<TabContents>(parent_tab_)); @@ -439,9 +478,14 @@ class FindInPageNotificationObserver : public NotificationObserver { if (find_details->active_match_ordinal() > -1) active_match_ordinal_ = find_details->active_match_ordinal(); if (find_details->final_update()) { - automation_->Send(new AutomationMsg_FindInPageResponse2(routing_id_, - active_match_ordinal_, - find_details->number_of_matches())); + DCHECK(reply_message_ != NULL); + + AutomationMsg_FindInPage::WriteReplyParams( + reply_message_, active_match_ordinal_, + find_details->number_of_matches()); + + automation_->Send(reply_message_); + reply_message_ = NULL; } else { DLOG(INFO) << "Ignoring, since we only care about the final message"; } @@ -466,6 +510,7 @@ class FindInPageNotificationObserver : public NotificationObserver { // We will at some point (before final update) be notified of the ordinal and // we need to preserve it so we can send it later. int active_match_ordinal_; + IPC::Message* reply_message_; }; const int FindInPageNotificationObserver::kFindInPageRequestId = -1; @@ -489,9 +534,13 @@ class DomOperationNotificationObserver : public NotificationObserver { const NotificationDetails& details) { if (NotificationType::DOM_OPERATION_RESPONSE == type) { Details<DomOperationNotificationDetails> dom_op_details(details); - automation_->Send(new AutomationMsg_DomOperationResponse( - dom_op_details->automation_id(), - dom_op_details->json())); + + IPC::Message* reply_message = automation_->reply_message_release(); + DCHECK(reply_message != NULL); + + AutomationMsg_DomOperation::WriteReplyParams( + reply_message, dom_op_details->json()); + automation_->Send(reply_message); } } private: @@ -530,10 +579,12 @@ class DomInspectorNotificationObserver : public NotificationObserver { class DocumentPrintedNotificationObserver : public NotificationObserver { public: DocumentPrintedNotificationObserver(AutomationProvider* automation, - int32 routing_id) + int32 routing_id, + IPC::Message* reply_message) : automation_(automation), routing_id_(routing_id), - success_(false) { + success_(false), + reply_message_(reply_message) { NotificationService::current()->AddObserver( this, NotificationType::PRINT_JOB_EVENT, @@ -541,8 +592,9 @@ class DocumentPrintedNotificationObserver : public NotificationObserver { } ~DocumentPrintedNotificationObserver() { - automation_->Send( - new AutomationMsg_PrintNowResponse(routing_id_, success_)); + DCHECK(reply_message_ != NULL); + AutomationMsg_PrintNow::WriteReplyParams(reply_message_, success_); + automation_->Send(reply_message_); automation_->RemoveNavigationStatusListener(this); NotificationService::current()->RemoveObserver( this, @@ -588,6 +640,7 @@ class DocumentPrintedNotificationObserver : public NotificationObserver { scoped_refptr<AutomationProvider> automation_; int32 routing_id_; bool success_; + IPC::Message* reply_message_; }; class AutomationInterstitialPage : public InterstitialPage { @@ -609,7 +662,8 @@ class AutomationInterstitialPage : public InterstitialPage { AutomationProvider::AutomationProvider(Profile* profile) : redirect_query_(0), - profile_(profile) { + profile_(profile), + reply_message_(NULL) { browser_tracker_.reset(new AutomationBrowserTracker(this)); window_tracker_.reset(new AutomationWindowTracker(this)); tab_tracker_.reset(new AutomationTabTracker(this)); @@ -631,8 +685,9 @@ AutomationProvider::~AutomationProvider() { void AutomationProvider::ConnectToChannel(const std::wstring& channel_id) { channel_.reset( - new IPC::ChannelProxy(channel_id, IPC::Channel::MODE_CLIENT, this, NULL, - g_browser_process->io_thread()->message_loop())); + new IPC::SyncChannel(channel_id, IPC::Channel::MODE_CLIENT, this, NULL, + g_browser_process->io_thread()->message_loop(), + true, g_browser_process->shutdown_event())); channel_->Send(new AutomationMsg_Hello(0)); } @@ -644,14 +699,18 @@ void AutomationProvider::SetExpectedTabCount(size_t expected_tabs) { } } +template<class NavigationCodeType> NotificationObserver* AutomationProvider::AddNavigationStatusListener( - NavigationController* tab, IPC::Message* completed_response, - IPC::Message* auth_needed_response) { + NavigationController* tab, IPC::Message* reply_message, + NavigationCodeType success_code, + NavigationCodeType auth_needed_code, + NavigationCodeType failed_code) { NotificationObserver* observer = - new NavigationNotificationObserver(tab, this, completed_response, - auth_needed_response); - notification_observer_list_.AddObserver(observer); + new NavigationNotificationObserver<NavigationCodeType>( + tab, this, reply_message, success_code, auth_needed_code, + failed_code); + notification_observer_list_.AddObserver(observer); return observer; } @@ -661,9 +720,10 @@ void AutomationProvider::RemoveNavigationStatusListener( } NotificationObserver* AutomationProvider::AddTabStripObserver( - Browser* parent, int32 routing_id) { - NotificationObserver* observer = new - TabAppendedNotificationObserver(parent, this, routing_id); + Browser* parent, int32 routing_id, IPC::Message* reply_message) { + NotificationObserver* observer = + new TabAppendedNotificationObserver(parent, this, routing_id, + reply_message); notification_observer_list_.AddObserver(observer); return observer; @@ -691,172 +751,182 @@ int AutomationProvider::GetIndexForNavigationController( void AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(AutomationProvider, message) - IPC_MESSAGE_HANDLER(AutomationMsg_CloseBrowserRequest, CloseBrowser) - IPC_MESSAGE_HANDLER(AutomationMsg_ActivateTabRequest, ActivateTab) - IPC_MESSAGE_HANDLER(AutomationMsg_ActiveTabIndexRequest, GetActiveTabIndex) - IPC_MESSAGE_HANDLER(AutomationMsg_AppendTabRequest, AppendTab) - IPC_MESSAGE_HANDLER(AutomationMsg_CloseTabRequest, CloseTab) - IPC_MESSAGE_HANDLER(AutomationMsg_GetCookiesRequest, GetCookies) - IPC_MESSAGE_HANDLER(AutomationMsg_SetCookieRequest, SetCookie) - IPC_MESSAGE_HANDLER(AutomationMsg_NavigateToURLRequest, NavigateToURL) - IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsyncRequest, NavigationAsync) - IPC_MESSAGE_HANDLER(AutomationMsg_GoBackRequest, GoBack) - IPC_MESSAGE_HANDLER(AutomationMsg_GoForwardRequest, GoForward) - IPC_MESSAGE_HANDLER(AutomationMsg_ReloadRequest, Reload) - IPC_MESSAGE_HANDLER(AutomationMsg_SetAuthRequest, SetAuth) - IPC_MESSAGE_HANDLER(AutomationMsg_CancelAuthRequest, CancelAuth) - IPC_MESSAGE_HANDLER(AutomationMsg_NeedsAuthRequest, NeedsAuth) - IPC_MESSAGE_HANDLER(AutomationMsg_RedirectsFromRequest, GetRedirectsFrom) - IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindowCountRequest, + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseBrowser, + CloseBrowser) + IPC_MESSAGE_HANDLER(AutomationMsg_CloseBrowserRequestAsync, + CloseBrowserAsync) + IPC_MESSAGE_HANDLER(AutomationMsg_ActivateTab, ActivateTab) + IPC_MESSAGE_HANDLER(AutomationMsg_ActiveTabIndex, GetActiveTabIndex) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_AppendTab, AppendTab) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseTab, CloseTab) + IPC_MESSAGE_HANDLER(AutomationMsg_GetCookies, GetCookies) + IPC_MESSAGE_HANDLER(AutomationMsg_SetCookie, SetCookie) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_NavigateToURL, + NavigateToURL) + IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsync, NavigationAsync) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_GoBack, GoBack) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_GoForward, GoForward) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Reload, Reload) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SetAuth, SetAuth) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CancelAuth, + CancelAuth) + IPC_MESSAGE_HANDLER(AutomationMsg_NeedsAuth, NeedsAuth) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_RedirectsFrom, + GetRedirectsFrom) + IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindowCount, GetBrowserWindowCount) - IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindowRequest, GetBrowserWindow) - IPC_MESSAGE_HANDLER(AutomationMsg_LastActiveBrowserWindowRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindow, GetBrowserWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_LastActiveBrowserWindow, GetLastActiveBrowserWindow) - IPC_MESSAGE_HANDLER(AutomationMsg_ActiveWindowRequest, GetActiveWindow) - IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowActiveRequest, IsWindowActive) + IPC_MESSAGE_HANDLER(AutomationMsg_ActiveWindow, GetActiveWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowActive, IsWindowActive) IPC_MESSAGE_HANDLER(AutomationMsg_ActivateWindow, ActivateWindow); - IPC_MESSAGE_HANDLER(AutomationMsg_WindowHWNDRequest, GetWindowHWND) - IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommandRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_WindowHWND, GetWindowHWND) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommand, ExecuteBrowserCommand) - IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBoundsRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, WindowGetViewBounds) - IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowVisibleRequest, SetWindowVisible) - IPC_MESSAGE_HANDLER(AutomationMsg_WindowClickRequest, WindowSimulateClick) - IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPressRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowVisible, + SetWindowVisible) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowClick, WindowSimulateClick) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) - IPC_MESSAGE_HANDLER(AutomationMsg_WindowDragRequest, WindowSimulateDrag) - IPC_MESSAGE_HANDLER(AutomationMsg_TabCountRequest, GetTabCount) - IPC_MESSAGE_HANDLER(AutomationMsg_TabRequest, GetTab) - IPC_MESSAGE_HANDLER(AutomationMsg_TabHWNDRequest, GetTabHWND) - IPC_MESSAGE_HANDLER(AutomationMsg_TabProcessIDRequest, GetTabProcessID) - IPC_MESSAGE_HANDLER(AutomationMsg_TabTitleRequest, GetTabTitle) - IPC_MESSAGE_HANDLER(AutomationMsg_TabURLRequest, GetTabURL) - IPC_MESSAGE_HANDLER(AutomationMsg_ShelfVisibilityRequest, + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowDrag, + WindowSimulateDrag) + IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) + IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) + IPC_MESSAGE_HANDLER(AutomationMsg_TabHWND, GetTabHWND) + IPC_MESSAGE_HANDLER(AutomationMsg_TabProcessID, GetTabProcessID) + IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) + IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) + IPC_MESSAGE_HANDLER(AutomationMsg_ShelfVisibility, GetShelfVisibility) IPC_MESSAGE_HANDLER(AutomationMsg_HandleUnused, HandleUnused) - IPC_MESSAGE_HANDLER(AutomationMsg_ApplyAcceleratorRequest, ApplyAccelerator) - IPC_MESSAGE_HANDLER(AutomationMsg_DomOperationRequest, ExecuteJavascript) - IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedWindowCountRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_ApplyAccelerator, + ApplyAccelerator) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation, + ExecuteJavascript) + IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedWindowCount, GetConstrainedWindowCount) - IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedWindowRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedWindow, GetConstrainedWindow) - IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedTitleRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedTitle, GetConstrainedTitle) - IPC_MESSAGE_HANDLER(AutomationMsg_FindInPageRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_FindInPage, HandleFindInPageRequest) - IPC_MESSAGE_HANDLER(AutomationMsg_GetFocusedViewIDRequest, GetFocusedViewID) - IPC_MESSAGE_HANDLER(AutomationMsg_InspectElementRequest, - HandleInspectElementRequest) + IPC_MESSAGE_HANDLER(AutomationMsg_GetFocusedViewID, + GetFocusedViewID) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InspectElement, + HandleInspectElementRequest) IPC_MESSAGE_HANDLER(AutomationMsg_SetFilteredInet, SetFilteredInet); - IPC_MESSAGE_HANDLER(AutomationMsg_DownloadDirectoryRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_DownloadDirectory, GetDownloadDirectory); IPC_MESSAGE_HANDLER(AutomationMsg_OpenNewBrowserWindow, OpenNewBrowserWindow); - IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowserRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowser, GetWindowForBrowser); - IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditForBrowserRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditForBrowser, GetAutocompleteEditForBrowser); - IPC_MESSAGE_HANDLER(AutomationMsg_BrowserForWindowRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_BrowserForWindow, GetBrowserForWindow); IPC_MESSAGE_HANDLER(AutomationMsg_CreateExternalTab, CreateExternalTab) - IPC_MESSAGE_HANDLER(AutomationMsg_NavigateInExternalTabRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_NavigateInExternalTab, NavigateInExternalTab) - IPC_MESSAGE_HANDLER(AutomationMsg_ShowInterstitialPageRequest, - ShowInterstitialPage); - IPC_MESSAGE_HANDLER(AutomationMsg_HideInterstitialPageRequest, + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ShowInterstitialPage, + ShowInterstitialPage); + IPC_MESSAGE_HANDLER(AutomationMsg_HideInterstitialPage, HideInterstitialPage); IPC_MESSAGE_HANDLER(AutomationMsg_SetAcceleratorsForTab, SetAcceleratorsForTab) IPC_MESSAGE_HANDLER(AutomationMsg_ProcessUnhandledAccelerator, ProcessUnhandledAccelerator) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabToBeRestored, + WaitForTabToBeRestored) IPC_MESSAGE_HANDLER(AutomationMsg_SetInitialFocus, SetInitialFocus) - IPC_MESSAGE_HANDLER(AutomationMsg_WaitForTabToBeRestored, - WaitForTabToBeRestored) IPC_MESSAGE_HANDLER(AutomationMsg_GetSecurityState, GetSecurityState) IPC_MESSAGE_HANDLER(AutomationMsg_GetPageType, GetPageType) - IPC_MESSAGE_HANDLER(AutomationMsg_ActionOnSSLBlockingPage, - ActionOnSSLBlockingPage) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ActionOnSSLBlockingPage, + ActionOnSSLBlockingPage) IPC_MESSAGE_HANDLER(AutomationMsg_BringBrowserToFront, BringBrowserToFront) IPC_MESSAGE_HANDLER(AutomationMsg_IsPageMenuCommandEnabled, IsPageMenuCommandEnabled) - IPC_MESSAGE_HANDLER(AutomationMsg_PrintNowRequest, PrintNow) - IPC_MESSAGE_HANDLER(AutomationMsg_SavePageRequest, SavePage) - IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditGetTextRequest, + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_PrintNow, PrintNow) + IPC_MESSAGE_HANDLER(AutomationMsg_SavePage, SavePage) + IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditGetText, GetAutocompleteEditText) - IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditSetTextRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditSetText, SetAutocompleteEditText) - IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditIsQueryInProgressRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditIsQueryInProgress, AutocompleteEditIsQueryInProgress) - IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditGetMatchesRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditGetMatches, AutocompleteEditGetMatches) - IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedWindowBoundsRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedWindowBounds, GetConstrainedWindowBounds) - IPC_MESSAGE_HANDLER(AutomationMsg_OpenFindInPageRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_OpenFindInPage, HandleOpenFindInPageRequest) IPC_MESSAGE_HANDLER(AutomationMsg_HandleMessageFromExternalHost, OnMessageFromExternalHost) - IPC_MESSAGE_HANDLER(AutomationMsg_FindRequest, - HandleFindRequest) - IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowVisibilityRequest, + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Find, + HandleFindRequest) + IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowVisibility, GetFindWindowVisibility) - IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowLocationRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowLocation, HandleFindWindowLocationRequest) - IPC_MESSAGE_HANDLER(AutomationMsg_BookmarkBarVisibilityRequest, - GetBookmarkBarVisitility) - IPC_MESSAGE_HANDLER(AutomationMsg_GetSSLInfoBarCountRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_BookmarkBarVisibility, + GetBookmarkBarVisibility) + IPC_MESSAGE_HANDLER(AutomationMsg_GetSSLInfoBarCount, GetSSLInfoBarCount) - IPC_MESSAGE_HANDLER(AutomationMsg_ClickSSLInfoBarLinkRequest, - ClickSSLInfoBarLink) - IPC_MESSAGE_HANDLER(AutomationMsg_GetLastNavigationTimeRequest, + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ClickSSLInfoBarLink, + ClickSSLInfoBarLink) + IPC_MESSAGE_HANDLER(AutomationMsg_GetLastNavigationTime, GetLastNavigationTime) - IPC_MESSAGE_HANDLER(AutomationMsg_WaitForNavigationRequest, - WaitForNavigation) - IPC_MESSAGE_HANDLER(AutomationMsg_SetIntPreferenceRequest, + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForNavigation, + WaitForNavigation) + IPC_MESSAGE_HANDLER(AutomationMsg_SetIntPreference, SetIntPreference) - IPC_MESSAGE_HANDLER(AutomationMsg_ShowingAppModalDialogRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_ShowingAppModalDialog, GetShowingAppModalDialog) - IPC_MESSAGE_HANDLER(AutomationMsg_ClickAppModalDialogButtonRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_ClickAppModalDialogButton, ClickAppModalDialogButton) - IPC_MESSAGE_HANDLER(AutomationMsg_SetStringPreferenceRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_SetStringPreference, SetStringPreference) - IPC_MESSAGE_HANDLER(AutomationMsg_GetBooleanPreferenceRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_GetBooleanPreference, GetBooleanPreference) - IPC_MESSAGE_HANDLER(AutomationMsg_SetBooleanPreferenceRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_SetBooleanPreference, SetBooleanPreference) - IPC_MESSAGE_HANDLER(AutomationMsg_GetPageCurrentEncodingRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_GetPageCurrentEncoding, GetPageCurrentEncoding) - IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncodingRequest, + IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding) IPC_MESSAGE_HANDLER(AutomationMsg_SavePackageShouldPromptUser, SavePackageShouldPromptUser) IPC_END_MESSAGE_MAP() } -void AutomationProvider::ActivateTab(const IPC::Message& message, - int handle, int at_index) { - int status = -1; +void AutomationProvider::ActivateTab(int handle, int at_index, int* status) { + *status = -1; if (browser_tracker_->ContainsHandle(handle) && at_index > -1) { Browser* browser = browser_tracker_->GetResource(handle); if (at_index >= 0 && at_index < browser->tab_count()) { browser->SelectTabContentsAt(at_index, true); - status = 0; + *status = 0; } } - Send(new AutomationMsg_ActivateTabResponse(message.routing_id(), status)); } -void AutomationProvider::AppendTab(const IPC::Message& message, - int handle, const GURL& url) { +void AutomationProvider::AppendTab(int handle, const GURL& url, + IPC::Message* reply_message) { int append_tab_response = -1; // -1 is the error code NotificationObserver* observer = NULL; if (browser_tracker_->ContainsHandle(handle)) { Browser* browser = browser_tracker_->GetResource(handle); - observer = AddTabStripObserver(browser, message.routing_id()); + observer = AddTabStripObserver(browser, reply_message->routing_id(), + reply_message); TabContents* tab_contents = browser->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, NULL); if (tab_contents) { @@ -872,17 +942,16 @@ void AutomationProvider::AppendTab(const IPC::Message& message, delete observer; } - // This will be reached only if the tab could not be appended. In case of a - // successful tab append, a successful navigation notification triggers the - // send. - Send(new AutomationMsg_AppendTabResponse(message.routing_id(), - append_tab_response)); + AutomationMsg_AppendTab::WriteReplyParams(reply_message, + append_tab_response); + Send(reply_message); } } -void AutomationProvider::NavigateToURL(const IPC::Message& message, - int handle, const GURL& url) { - int status = AUTOMATION_MSG_NAVIGATION_ERROR; +void AutomationProvider::NavigateToURL(int handle, const GURL& url, + IPC::Message* reply_message) { + AutomationMsg_NavigationResponseValues status = + AUTOMATION_MSG_NAVIGATION_ERROR; if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); @@ -892,23 +961,25 @@ void AutomationProvider::NavigateToURL(const IPC::Message& message, Browser* browser = FindAndActivateTab(tab); if (browser) { - AddNavigationStatusListener(tab, - new AutomationMsg_NavigateToURLResponse( - message.routing_id(), AUTOMATION_MSG_NAVIGATION_SUCCESS), - new AutomationMsg_NavigateToURLResponse( - message.routing_id(), AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED)); + AddNavigationStatusListener<AutomationMsg_NavigationResponseValues>( + tab, reply_message, AUTOMATION_MSG_NAVIGATION_SUCCESS, + AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED, + AUTOMATION_MSG_NAVIGATION_ERROR); + // TODO(darin): avoid conversion to GURL browser->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); return; } } - Send(new AutomationMsg_NavigateToURLResponse( - message.routing_id(), AUTOMATION_MSG_NAVIGATION_ERROR)); + + AutomationMsg_NavigateToURL::WriteReplyParams( + reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); + Send(reply_message); } -void AutomationProvider::NavigationAsync(const IPC::Message& message, - int handle, const GURL& url) { - bool status = false; +void AutomationProvider::NavigationAsync(int handle, const GURL& url, + bool* status) { + *status = false; if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); @@ -921,70 +992,72 @@ void AutomationProvider::NavigationAsync(const IPC::Message& message, // Don't add any listener unless a callback mechanism is desired. // TODO(vibhor): Do this if such a requirement arises in future. browser->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); - status = true; + *status = true; } } - - Send(new AutomationMsg_NavigationAsyncResponse(message.routing_id(), status)); } -void AutomationProvider::GoBack(const IPC::Message& message, int handle) { +void AutomationProvider::GoBack(int handle, IPC::Message* reply_message) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); Browser* browser = FindAndActivateTab(tab); if (browser && browser->command_updater()->IsCommandEnabled(IDC_BACK)) { - AddNavigationStatusListener(tab, - new AutomationMsg_GoBackResponse( - message.routing_id(), AUTOMATION_MSG_NAVIGATION_SUCCESS), - new AutomationMsg_GoBackResponse( - message.routing_id(), AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED)); + AddNavigationStatusListener<AutomationMsg_NavigationResponseValues>( + tab, reply_message, AUTOMATION_MSG_NAVIGATION_SUCCESS, + AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED, + AUTOMATION_MSG_NAVIGATION_ERROR); browser->GoBack(); return; } } - Send(new AutomationMsg_GoBackResponse(message.routing_id(), - AUTOMATION_MSG_NAVIGATION_ERROR)); + + AutomationMsg_GoBack::WriteReplyParams( + reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); + Send(reply_message); } -void AutomationProvider::GoForward(const IPC::Message& message, int handle) { +void AutomationProvider::GoForward(int handle, IPC::Message* reply_message) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); Browser* browser = FindAndActivateTab(tab); if (browser && browser->command_updater()->IsCommandEnabled(IDC_FORWARD)) { - AddNavigationStatusListener(tab, - new AutomationMsg_GoForwardResponse( - message.routing_id(), AUTOMATION_MSG_NAVIGATION_SUCCESS), - new AutomationMsg_GoForwardResponse( - message.routing_id(), AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED)); + AddNavigationStatusListener<AutomationMsg_NavigationResponseValues>( + tab, reply_message, AUTOMATION_MSG_NAVIGATION_SUCCESS, + AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED, + AUTOMATION_MSG_NAVIGATION_ERROR); browser->GoForward(); return; } } - Send(new AutomationMsg_GoForwardResponse(message.routing_id(), - AUTOMATION_MSG_NAVIGATION_ERROR)); + + AutomationMsg_GoForward::WriteReplyParams( + reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); + Send(reply_message); } -void AutomationProvider::Reload(const IPC::Message& message, int handle) { +void AutomationProvider::Reload(int handle, IPC::Message* reply_message) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); Browser* browser = FindAndActivateTab(tab); if (browser && browser->command_updater()->IsCommandEnabled(IDC_RELOAD)) { - AddNavigationStatusListener(tab, - new AutomationMsg_ReloadResponse( - message.routing_id(), AUTOMATION_MSG_NAVIGATION_SUCCESS), - new AutomationMsg_ReloadResponse( - message.routing_id(), AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED)); + AddNavigationStatusListener<AutomationMsg_NavigationResponseValues>( + tab, reply_message, AUTOMATION_MSG_NAVIGATION_SUCCESS, + AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED, + AUTOMATION_MSG_NAVIGATION_ERROR); browser->Reload(); return; } } - Send(new AutomationMsg_ReloadResponse(message.routing_id(), - AUTOMATION_MSG_NAVIGATION_ERROR)); + + AutomationMsg_Reload::WriteReplyParams( + reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); + Send(reply_message); } -void AutomationProvider::SetAuth(const IPC::Message& message, int tab_handle, +void AutomationProvider::SetAuth(int tab_handle, const std::wstring& username, - const std::wstring& password) { + const std::wstring& password, + IPC::Message* reply_message) { int status = -1; if (tab_tracker_->ContainsHandle(tab_handle)) { @@ -996,20 +1069,19 @@ void AutomationProvider::SetAuth(const IPC::Message& message, int tab_handle, // not strictly correct, because a navigation can require both proxy and // server auth, but it should be OK for now. LoginHandler* handler = iter->second; - AddNavigationStatusListener(tab, - new AutomationMsg_SetAuthResponse(message.routing_id(), 0), - new AutomationMsg_SetAuthResponse(message.routing_id(), -1)); + AddNavigationStatusListener<int>(tab, reply_message, 0, -1, -1); handler->SetAuth(username, password); status = 0; } } if (status < 0) { - Send(new AutomationMsg_SetAuthResponse(message.routing_id(), status)); + AutomationMsg_SetAuth::WriteReplyParams(reply_message, status); + Send(reply_message); } } -void AutomationProvider::CancelAuth(const IPC::Message& message, - int tab_handle) { +void AutomationProvider::CancelAuth(int tab_handle, + IPC::Message* reply_message) { int status = -1; if (tab_tracker_->ContainsHandle(tab_handle)) { @@ -1019,21 +1091,19 @@ void AutomationProvider::CancelAuth(const IPC::Message& message, if (iter != login_handler_map_.end()) { // If auth is needed again after this, something is screwy. LoginHandler* handler = iter->second; - AddNavigationStatusListener(tab, - new AutomationMsg_CancelAuthResponse(message.routing_id(), 0), - new AutomationMsg_CancelAuthResponse(message.routing_id(), -1)); + AddNavigationStatusListener<int>(tab, reply_message, 0, -1, -1); handler->CancelAuth(); status = 0; } } if (status < 0) { - Send(new AutomationMsg_CancelAuthResponse(message.routing_id(), status)); + AutomationMsg_CancelAuth::WriteReplyParams(reply_message, status); + Send(reply_message); } } -void AutomationProvider::NeedsAuth(const IPC::Message& message, - int tab_handle) { - bool needs_auth = false; +void AutomationProvider::NeedsAuth(int tab_handle, bool* needs_auth) { + *needs_auth = false; if (tab_tracker_->ContainsHandle(tab_handle)) { NavigationController* tab = tab_tracker_->GetResource(tab_handle); @@ -1041,16 +1111,14 @@ void AutomationProvider::NeedsAuth(const IPC::Message& message, if (iter != login_handler_map_.end()) { // The LoginHandler will be in our map IFF the tab needs auth. - needs_auth = true; + *needs_auth = true; } } - - Send(new AutomationMsg_NeedsAuthResponse(message.routing_id(), needs_auth)); } -void AutomationProvider::GetRedirectsFrom(const IPC::Message& message, - int tab_handle, - const GURL& source_url) { +void AutomationProvider::GetRedirectsFrom(int tab_handle, + const GURL& source_url, + IPC::Message* reply_message) { DCHECK(!redirect_query_) << "Can only handle one redirect query at once."; if (tab_tracker_->ContainsHandle(tab_handle)) { NavigationController* tab = tab_tracker_->GetResource(tab_handle); @@ -1060,10 +1128,12 @@ void AutomationProvider::GetRedirectsFrom(const IPC::Message& message, DCHECK(history_service) << "Tab " << tab_handle << "'s profile " << "has no history service"; if (history_service) { + DCHECK(reply_message_ == NULL); + reply_message_ = reply_message; // Schedule a history query for redirects. The response will be sent // asynchronously from the callback the history system uses to notify us // that it's done: OnRedirectQueryComplete. - redirect_query_routing_id_ = message.routing_id(); + redirect_query_routing_id_ = reply_message->routing_id(); redirect_query_ = history_service->QueryRedirectsFrom( source_url, &consumer_, NewCallback(this, &AutomationProvider::OnRedirectQueryComplete)); @@ -1072,43 +1142,36 @@ void AutomationProvider::GetRedirectsFrom(const IPC::Message& message, } // Send failure response. - IPC::Message* msg = new IPC::Message( - message.routing_id(), AutomationMsg_RedirectsFromResponse::ID, - IPC::Message::PRIORITY_NORMAL); - msg->WriteBool(false); std::vector<GURL> empty; - IPC::ParamTraits<std::vector<GURL>>::Write(msg, empty); - Send(msg); + AutomationMsg_RedirectsFrom::WriteReplyParams(reply_message, false, empty); + Send(reply_message); } -void AutomationProvider::GetActiveTabIndex(const IPC::Message& message, - int handle) { - int active_tab_index = -1; // -1 is the error code +void AutomationProvider::GetActiveTabIndex(int handle, int* active_tab_index) { + *active_tab_index = -1; // -1 is the error code if (browser_tracker_->ContainsHandle(handle)) { Browser* browser = browser_tracker_->GetResource(handle); - active_tab_index = browser->selected_index(); + *active_tab_index = browser->selected_index(); } - Send(new AutomationMsg_ActiveTabIndexResponse(message.routing_id(), - active_tab_index)); } -void AutomationProvider::GetBrowserWindowCount(const IPC::Message& message) { - Send(new AutomationMsg_BrowserWindowCountResponse( - message.routing_id(), static_cast<int>(BrowserList::size()))); +void AutomationProvider::GetBrowserWindowCount(int* window_count) { + *window_count = static_cast<int>(BrowserList::size()); } -void AutomationProvider::GetShowingAppModalDialog(const IPC::Message& message) { +void AutomationProvider::GetShowingAppModalDialog(bool* showing_dialog, + int* dialog_button) { views::AppModalDialogDelegate* dialog_delegate = AppModalDialogQueue::active_dialog(); - Send(new AutomationMsg_ShowingAppModalDialogResponse( - message.routing_id(), dialog_delegate != NULL, - dialog_delegate ? dialog_delegate->GetDialogButtons() : - views::DialogDelegate::DIALOGBUTTON_NONE)); + *showing_dialog = (dialog_delegate != NULL); + if (*showing_dialog) + *dialog_button = dialog_delegate->GetDialogButtons(); + else + *dialog_button = views::DialogDelegate::DIALOGBUTTON_NONE; } -void AutomationProvider::ClickAppModalDialogButton(const IPC::Message& message, - int button) { - bool success = false; +void AutomationProvider::ClickAppModalDialogButton(int button, bool* success) { + *success = false; views::AppModalDialogDelegate* dialog_delegate = AppModalDialogQueue::active_dialog(); @@ -1119,42 +1182,34 @@ void AutomationProvider::ClickAppModalDialogButton(const IPC::Message& message, if ((button & views::DialogDelegate::DIALOGBUTTON_OK) == views::DialogDelegate::DIALOGBUTTON_OK) { client_view->AcceptWindow(); - success = true; + *success = true; } if ((button & views::DialogDelegate::DIALOGBUTTON_CANCEL) == views::DialogDelegate::DIALOGBUTTON_CANCEL) { - DCHECK(!success) << "invalid param, OK and CANCEL specified"; + DCHECK(!*success) << "invalid param, OK and CANCEL specified"; client_view->CancelWindow(); - success = true; + *success = true; } } - Send(new AutomationMsg_ClickAppModalDialogButtonResponse( - message.routing_id(), success)); } -void AutomationProvider::GetBrowserWindow(const IPC::Message& message, - int index) { - int handle = 0; +void AutomationProvider::GetBrowserWindow(int index, int* handle) { + *handle = 0; if (index >= 0) { BrowserList::const_iterator iter = BrowserList::begin(); for (; (iter != BrowserList::end()) && (index > 0); ++iter, --index); if (iter != BrowserList::end()) { - handle = browser_tracker_->Add(*iter); + *handle = browser_tracker_->Add(*iter); } } - - Send(new AutomationMsg_BrowserWindowResponse(message.routing_id(), handle)); } -void AutomationProvider::GetLastActiveBrowserWindow( - const IPC::Message& message) { - int handle = 0; +void AutomationProvider::GetLastActiveBrowserWindow(int* handle) { + *handle = 0; Browser* browser = BrowserList::GetLastActive(); if (browser) - handle = browser_tracker_->Add(browser); - Send(new AutomationMsg_LastActiveBrowserWindowResponse(message.routing_id(), - handle)); + *handle = browser_tracker_->Add(browser); } BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM l_param) { @@ -1164,7 +1219,7 @@ BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM l_param) { return TRUE; } -void AutomationProvider::GetActiveWindow(const IPC::Message& message) { +void AutomationProvider::GetActiveWindow(int* handle) { HWND window = GetForegroundWindow(); // Let's make sure this window belongs to our process. @@ -1173,43 +1228,35 @@ void AutomationProvider::GetActiveWindow(const IPC::Message& message) { reinterpret_cast<LPARAM>(window))) { // We enumerated all the windows and did not find the foreground window, // it is not our window, ignore it. - Send(new AutomationMsg_ActiveWindowResponse(message.routing_id(), 0)); + *handle = 0; return; } - int handle = window_tracker_->Add(window); - Send(new AutomationMsg_ActiveWindowResponse(message.routing_id(), handle)); + *handle = window_tracker_->Add(window); } -void AutomationProvider::GetWindowHWND(const IPC::Message& message, - int handle) { - HWND win32_handle = window_tracker_->GetResource(handle); - Send(new AutomationMsg_WindowHWNDResponse(message.routing_id(), - win32_handle)); +void AutomationProvider::GetWindowHWND(int handle, HWND* win32_handle) { + *win32_handle = window_tracker_->GetResource(handle); } -void AutomationProvider::ExecuteBrowserCommand(const IPC::Message& message, - int handle, - int command) { - bool success = false; +void AutomationProvider::ExecuteBrowserCommand(int handle, int command, + bool* success) { + *success = false; if (browser_tracker_->ContainsHandle(handle)) { Browser* browser = browser_tracker_->GetResource(handle); if (browser->command_updater()->SupportsCommand(command) && browser->command_updater()->IsCommandEnabled(command)) { browser->ExecuteCommand(command); - success = true; + *success = true; } } - Send(new AutomationMsg_WindowExecuteCommandResponse(message.routing_id(), - success)); } -void AutomationProvider::WindowGetViewBounds(const IPC::Message& message, - int handle, - int view_id, - bool screen_coordinates) { - bool succeeded = false; - gfx::Rect bounds; +void AutomationProvider::WindowGetViewBounds(int handle, int view_id, + bool screen_coordinates, + bool* success, + gfx::Rect* bounds) { + *success = false; void* iter = NULL; if (window_tracker_->ContainsHandle(handle)) { @@ -1218,20 +1265,17 @@ void AutomationProvider::WindowGetViewBounds(const IPC::Message& message, if (root_view) { views::View* view = root_view->GetViewByID(view_id); if (view) { - succeeded = true; + *success = true; gfx::Point point; if (screen_coordinates) views::View::ConvertPointToScreen(view, &point); else views::View::ConvertPointToView(view, root_view, &point); - bounds = view->GetLocalBounds(false); - bounds.set_origin(point); + *bounds = view->GetLocalBounds(false); + bounds->set_origin(point); } } } - - Send(new AutomationMsg_WindowViewBoundsResponse(message.routing_id(), - succeeded, bounds)); } // This task enqueues a mouse event on the event loop, so that the view @@ -1315,17 +1359,22 @@ class InvokeTaskLaterTask : public Task { // loop) have been processed by the time this is sent. class WindowDragResponseTask : public Task { public: - WindowDragResponseTask(AutomationProvider* provider, int routing_id) - : provider_(provider), routing_id_(routing_id) {} + WindowDragResponseTask(AutomationProvider* provider, int routing_id, + IPC::Message* reply_message) + : provider_(provider), routing_id_(routing_id), + reply_message_(reply_message) {} virtual ~WindowDragResponseTask() {} virtual void Run() { - provider_->Send(new AutomationMsg_WindowDragResponse(routing_id_, true)); + DCHECK(reply_message_ != NULL); + AutomationMsg_WindowDrag::WriteReplyParams(reply_message_, true); + provider_->Send(reply_message_); } private: AutomationProvider* provider_; int routing_id_; + IPC::Message* reply_message_; DISALLOW_COPY_AND_ASSIGN(WindowDragResponseTask); }; @@ -1358,11 +1407,11 @@ void AutomationProvider::WindowSimulateClick(const IPC::Message& message, } } -void AutomationProvider::WindowSimulateDrag(const IPC::Message& message, - int handle, +void AutomationProvider::WindowSimulateDrag(int handle, std::vector<POINT> drag_path, int flags, - bool press_escape_en_route) { + bool press_escape_en_route, + IPC::Message* reply_message) { bool succeeded = false; if (browser_tracker_->ContainsHandle(handle) && (drag_path.size() > 1)) { succeeded = true; @@ -1425,9 +1474,11 @@ void AutomationProvider::WindowSimulateDrag(const IPC::Message& message, MessageLoop::current()->PostTask(FROM_HERE, new InvokeTaskLaterTask( - new WindowDragResponseTask(this, message.routing_id()))); + new WindowDragResponseTask(this, reply_message->routing_id(), + reply_message))); } else { - Send(new AutomationMsg_WindowDragResponse(message.routing_id(), true)); + AutomationMsg_WindowDrag::WriteReplyParams(reply_message, true); + Send(reply_message); } } @@ -1448,9 +1499,8 @@ void AutomationProvider::WindowSimulateKeyPress(const IPC::Message& message, views::Event::EF_ALT_DOWN)); } -void AutomationProvider::GetFocusedViewID(const IPC::Message& message, - int handle) { - int view_id = -1; +void AutomationProvider::GetFocusedViewID(int handle, int* view_id) { + *view_id = -1; if (window_tracker_->ContainsHandle(handle)) { HWND hwnd = window_tracker_->GetResource(handle); views::FocusManager* focus_manager = @@ -1458,35 +1508,30 @@ void AutomationProvider::GetFocusedViewID(const IPC::Message& message, DCHECK(focus_manager); views::View* focused_view = focus_manager->GetFocusedView(); if (focused_view) - view_id = focused_view->GetID(); + *view_id = focused_view->GetID(); } - Send(new AutomationMsg_GetFocusedViewIDResponse(message.routing_id(), - view_id)); } -void AutomationProvider::SetWindowVisible(const IPC::Message& message, - int handle, bool visible) { +void AutomationProvider::SetWindowVisible(int handle, bool visible, + bool* result) { if (window_tracker_->ContainsHandle(handle)) { HWND hwnd = window_tracker_->GetResource(handle); ::ShowWindow(hwnd, visible ? SW_SHOW : SW_HIDE); - Send(new AutomationMsg_SetWindowVisibleResponse(message.routing_id(), - true)); + *result = true; } else { - Send(new AutomationMsg_SetWindowVisibleResponse(message.routing_id(), - false)); + *result = false; } } -void AutomationProvider::IsWindowActive(const IPC::Message& message, - int handle) { +void AutomationProvider::IsWindowActive(int handle, bool* success, + bool* is_active) { if (window_tracker_->ContainsHandle(handle)) { HWND hwnd = window_tracker_->GetResource(handle); - bool is_active = ::GetForegroundWindow() == hwnd; - Send(new AutomationMsg_IsWindowActiveResponse( - message.routing_id(), true, is_active)); + *is_active = ::GetForegroundWindow() == hwnd; + *success = true; } else { - Send(new AutomationMsg_IsWindowActiveResponse(message.routing_id(), - false, false)); + *success = false; + *is_active = false; } } @@ -1497,44 +1542,37 @@ void AutomationProvider::ActivateWindow(const IPC::Message& message, } } -void AutomationProvider::GetTabCount(const IPC::Message& message, int handle) { - int tab_count = -1; // -1 is the error code +void AutomationProvider::GetTabCount(int handle, int* tab_count) { + *tab_count = -1; // -1 is the error code if (browser_tracker_->ContainsHandle(handle)) { Browser* browser = browser_tracker_->GetResource(handle); - tab_count = browser->tab_count(); + *tab_count = browser->tab_count(); } - - Send(new AutomationMsg_TabCountResponse(message.routing_id(), tab_count)); } -void AutomationProvider::GetTab(const IPC::Message& message, - int win_handle, int tab_index) { +void AutomationProvider::GetTab(int win_handle, int tab_index, + int* tab_handle) { void* iter = NULL; - int tab_handle = 0; + *tab_handle = 0; if (browser_tracker_->ContainsHandle(win_handle) && (tab_index >= 0)) { Browser* browser = browser_tracker_->GetResource(win_handle); if (tab_index < browser->tab_count()) { TabContents* tab_contents = browser->GetTabContentsAt(tab_index); - tab_handle = tab_tracker_->Add(tab_contents->controller()); + *tab_handle = tab_tracker_->Add(tab_contents->controller()); } } - - Send(new AutomationMsg_TabResponse(message.routing_id(), tab_handle)); } -void AutomationProvider::GetTabTitle(const IPC::Message& message, int handle) { - int title_string_size = -1; // -1 is the error code - std::wstring title; +void AutomationProvider::GetTabTitle(int handle, int* title_string_size, + std::wstring* title) { + *title_string_size = -1; // -1 is the error code if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); - title = tab->GetActiveEntry()->title(); - title_string_size = static_cast<int>(title.size()); + *title = tab->GetActiveEntry()->title(); + *title_string_size = static_cast<int>(title->size()); } - - Send(new AutomationMsg_TabTitleResponse(message.routing_id(), - title_string_size, title)); } void AutomationProvider::HandleUnused(const IPC::Message& message, int handle) { @@ -1555,24 +1593,22 @@ void AutomationProvider::OnRedirectQueryComplete( bool success, HistoryService::RedirectList* redirects) { DCHECK(request_handle == redirect_query_); + DCHECK(reply_message_ != NULL); - // Respond to the pending request for the redirect list. - IPC::Message* msg = new IPC::Message(redirect_query_routing_id_, - AutomationMsg_RedirectsFromResponse::ID, - IPC::Message::PRIORITY_NORMAL); std::vector<GURL> redirects_gurl; if (success) { - msg->WriteBool(true); + reply_message_->WriteBool(true); for (size_t i = 0; i < redirects->size(); i++) redirects_gurl.push_back(redirects->at(i)); } else { - msg->WriteInt(-1); // Negative count indicates failure. + reply_message_->WriteInt(-1); // Negative count indicates failure. } - IPC::ParamTraits<std::vector<GURL>>::Write(msg, redirects_gurl); + IPC::ParamTraits<std::vector<GURL>>::Write(reply_message_, redirects_gurl); - Send(msg); + Send(reply_message_); redirect_query_ = NULL; + reply_message_ = NULL; } bool AutomationProvider::Send(IPC::Message* msg) { @@ -1590,77 +1626,63 @@ Browser* AutomationProvider::FindAndActivateTab( return browser; } -void AutomationProvider::GetCookies(const IPC::Message& message, - const GURL& url, int handle) { - std::string value; - +void AutomationProvider::GetCookies(const GURL& url, int handle, + int* value_size, + std::string* value) { + *value_size = -1; if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); - value = + *value = tab->profile()->GetRequestContext()->cookie_store()->GetCookies(url); + *value_size = static_cast<int>(value->size()); } - - Send(new AutomationMsg_GetCookiesResponse(message.routing_id(), - static_cast<int>(value.size()), value)); } -void AutomationProvider::SetCookie(const IPC::Message& message, - const GURL& url, +void AutomationProvider::SetCookie(const GURL& url, const std::string value, - int handle) { - int response_value = -1; + int handle, + int* response_value) { + *response_value = -1; if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); URLRequestContext* context = tab->profile()->GetRequestContext(); if (context->cookie_store()->SetCookie(url, value)) - response_value = 1; + *response_value = 1; } - - Send(new AutomationMsg_SetCookieResponse(message.routing_id(), - response_value)); } -void AutomationProvider::GetTabURL(const IPC::Message& message, int handle) { - bool success = false; - GURL url; +void AutomationProvider::GetTabURL(int handle, bool* success, GURL* url) { + *success = false; if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); // Return what the user would see in the location bar. - url = tab->GetActiveEntry()->display_url(); - success = true; + *url = tab->GetActiveEntry()->display_url(); + *success = true; } - - Send(new AutomationMsg_TabURLResponse(message.routing_id(), success, url)); } -void AutomationProvider::GetTabHWND(const IPC::Message& message, int handle) { - HWND tab_hwnd = NULL; +void AutomationProvider::GetTabHWND(int handle, HWND* tab_hwnd) { + *tab_hwnd = NULL; if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); - tab_hwnd = tab->active_contents()->GetNativeView(); + *tab_hwnd = tab->active_contents()->GetNativeView(); } - - Send(new AutomationMsg_TabHWNDResponse(message.routing_id(), tab_hwnd)); } -void AutomationProvider::GetTabProcessID( - const IPC::Message& message, int handle) { - int process_id = -1; +void AutomationProvider::GetTabProcessID(int handle, int* process_id) { + *process_id = -1; if (tab_tracker_->ContainsHandle(handle)) { - process_id = 0; + *process_id = 0; NavigationController* tab = tab_tracker_->GetResource(handle); if (tab->active_contents()->AsWebContents()) { WebContents* web_contents = tab->active_contents()->AsWebContents(); if (web_contents->process()) - process_id = web_contents->process()->process().pid(); + *process_id = web_contents->process()->process().pid(); } } - - Send(new AutomationMsg_TabProcessIDResponse(message.routing_id(), - process_id)); } void AutomationProvider::ApplyAccelerator(int handle, int id) { @@ -1670,10 +1692,10 @@ void AutomationProvider::ApplyAccelerator(int handle, int id) { } } -void AutomationProvider::ExecuteJavascript(const IPC::Message& message, - int handle, +void AutomationProvider::ExecuteJavascript(int handle, const std::wstring& frame_xpath, - const std::wstring& script) { + const std::wstring& script, + IPC::Message* reply_message) { bool succeeded = false; WebContents* web_contents = GetWebContentsForHandle(handle, NULL); if (web_contents) { @@ -1684,7 +1706,10 @@ void AutomationProvider::ExecuteJavascript(const IPC::Message& message, std::wstring set_automation_id; SStringPrintf(&set_automation_id, L"window.domAutomationController.setAutomationId(%d);", - message.routing_id()); + reply_message->routing_id()); + + DCHECK(reply_message_ == NULL); + reply_message_ = reply_message; web_contents->render_view_host()->ExecuteJavascriptInWebFrame( frame_xpath, set_automation_id); @@ -1694,97 +1719,82 @@ void AutomationProvider::ExecuteJavascript(const IPC::Message& message, } if (!succeeded) { - Send(new AutomationMsg_DomOperationResponse(message.routing_id(), "")); + AutomationMsg_DomOperation::WriteReplyParams(reply_message, std::string()); + Send(reply_message); } } -void AutomationProvider::GetShelfVisibility(const IPC::Message& message, - int handle) { - bool visible = false; +void AutomationProvider::GetShelfVisibility(int handle, bool* visible) { + *visible = false; WebContents* web_contents = GetWebContentsForHandle(handle, NULL); if (web_contents) - visible = web_contents->IsDownloadShelfVisible(); - - Send(new AutomationMsg_ShelfVisibilityResponse(message.routing_id(), - visible)); + *visible = web_contents->IsDownloadShelfVisible(); } -void AutomationProvider::GetConstrainedWindowCount(const IPC::Message& message, - int handle) { - int count = -1; // -1 is the error code +void AutomationProvider::GetConstrainedWindowCount(int handle, int* count) { + *count = -1; // -1 is the error code if (tab_tracker_->ContainsHandle(handle)) { NavigationController* nav_controller = tab_tracker_->GetResource(handle); TabContents* tab_contents = nav_controller->active_contents(); if (tab_contents) { - count = static_cast<int>(tab_contents->child_windows_.size()); + *count = static_cast<int>(tab_contents->child_windows_.size()); } } - - Send(new AutomationMsg_ConstrainedWindowCountResponse(message.routing_id(), - count)); } -void AutomationProvider::GetConstrainedWindow(const IPC::Message& message, - int handle, int index) { - int cwindow_handle = 0; +void AutomationProvider::GetConstrainedWindow(int handle, int index, + int* cwindow_handle) { + *cwindow_handle = 0; if (tab_tracker_->ContainsHandle(handle) && index >= 0) { NavigationController* nav_controller = tab_tracker_->GetResource(handle); TabContents* tab = nav_controller->active_contents(); if (tab && index < static_cast<int>(tab->child_windows_.size())) { ConstrainedWindow* window = tab->child_windows_[index]; - cwindow_handle = cwindow_tracker_->Add(window); + *cwindow_handle = cwindow_tracker_->Add(window); } } - - Send(new AutomationMsg_ConstrainedWindowResponse(message.routing_id(), - cwindow_handle)); } -void AutomationProvider::GetConstrainedTitle(const IPC::Message& message, - int handle) { - int title_string_size = -1; // -1 is the error code - std::wstring title; +void AutomationProvider::GetConstrainedTitle(int handle, + int* title_string_size, + std::wstring* title) { + *title_string_size = -1; // -1 is the error code if (cwindow_tracker_->ContainsHandle(handle)) { ConstrainedWindow* window = cwindow_tracker_->GetResource(handle); - title = window->GetWindowTitle(); - title_string_size = static_cast<int>(title.size()); + *title = window->GetWindowTitle(); + *title_string_size = static_cast<int>(title->size()); } - - Send(new AutomationMsg_ConstrainedTitleResponse(message.routing_id(), - title_string_size, title)); } -void AutomationProvider::GetConstrainedWindowBounds(const IPC::Message& message, - int handle) { - bool exists = false; - gfx::Rect rect(0, 0, 0, 0); +void AutomationProvider::GetConstrainedWindowBounds(int handle, bool* exists, + gfx::Rect* rect) { + *rect = gfx::Rect(0, 0, 0, 0); if (cwindow_tracker_->ContainsHandle(handle)) { ConstrainedWindow* window = cwindow_tracker_->GetResource(handle); if (window) { - exists = true; - rect = window->GetCurrentBounds(); + *exists = true; + *rect = window->GetCurrentBounds(); } } - - Send(new AutomationMsg_ConstrainedWindowBoundsResponse(message.routing_id(), - exists, rect)); } void AutomationProvider::HandleFindInPageRequest( - const IPC::Message& message, int handle, const std::wstring& find_request, - int forward, int match_case) { + int handle, const std::wstring& find_request, + int forward, int match_case, int* active_ordinal, int* matches_found) { NOTREACHED() << "This function has been deprecated." << "Please use HandleFindRequest instead."; - Send(new AutomationMsg_FindInPageResponse2(message.routing_id(), -1, -1)); + *matches_found = -1; return; } -void AutomationProvider::HandleFindRequest(const IPC::Message& message, - int handle, const FindInPageRequest& request) { +void AutomationProvider::HandleFindRequest(int handle, + const FindInPageRequest& request, + IPC::Message* reply_message) { if (!tab_tracker_->ContainsHandle(handle)) { - Send(new AutomationMsg_FindInPageResponse2(message.routing_id(), -1, -1)); + AutomationMsg_FindInPage::WriteReplyParams(reply_message, -1, -1); + Send(reply_message); return; } @@ -1792,7 +1802,9 @@ void AutomationProvider::HandleFindRequest(const IPC::Message& message, TabContents* tab_contents = nav->active_contents(); find_in_page_observer_.reset(new - FindInPageNotificationObserver(this, tab_contents, message.routing_id())); + FindInPageNotificationObserver(this, tab_contents, + reply_message->routing_id(), + reply_message)); // The find in page dialog must be up for us to get the notification that the // find was complete. @@ -1819,35 +1831,30 @@ void AutomationProvider::HandleOpenFindInPageRequest( } } -void AutomationProvider::GetFindWindowVisibility(const IPC::Message& message, - int handle) { +void AutomationProvider::GetFindWindowVisibility(int handle, bool* visible) { gfx::Point position; - bool visible = false; + *visible = false; WebContents* web_contents = GetWebContentsForHandle(handle, NULL); if (web_contents) - web_contents->view()->GetFindBarWindowInfo(&position, &visible); - - Send(new AutomationMsg_FindWindowVisibilityResponse(message.routing_id(), - visible)); + web_contents->view()->GetFindBarWindowInfo(&position, visible); } -void AutomationProvider::HandleFindWindowLocationRequest( - const IPC::Message& message, int handle) { +void AutomationProvider::HandleFindWindowLocationRequest(int handle, int* x, + int* y) { gfx::Point position(0, 0); bool visible = false; WebContents* web_contents = GetWebContentsForHandle(handle, NULL); if (web_contents) web_contents->view()->GetFindBarWindowInfo(&position, &visible); - Send(new AutomationMsg_FindWindowLocationResponse(message.routing_id(), - position.x(), - position.y())); + *x = position.x(); + *y = position.y(); } -void AutomationProvider::GetBookmarkBarVisitility(const IPC::Message& message, - int handle) { - bool visible = false; - bool animating = false; +void AutomationProvider::GetBookmarkBarVisibility(int handle, bool* visible, + bool* animating) { + *visible = false; + *animating = false; void* iter = NULL; if (browser_tracker_->ContainsHandle(handle)) { @@ -1857,30 +1864,34 @@ void AutomationProvider::GetBookmarkBarVisitility(const IPC::Message& message, browser->window()->GetBrowserWindowTesting(); BookmarkBarView* bookmark_bar = testing->GetBookmarkBarView(); if (bookmark_bar) { - animating = bookmark_bar->IsAnimating(); - visible = browser->window()->IsBookmarkBarVisible(); + *animating = bookmark_bar->IsAnimating(); + *visible = browser->window()->IsBookmarkBarVisible(); } } } - - Send(new AutomationMsg_BookmarkBarVisibilityResponse(message.routing_id(), - visible, animating)); } void AutomationProvider::HandleInspectElementRequest( - const IPC::Message& message, int handle, int x, int y) { + int handle, int x, int y, IPC::Message* reply_message) { WebContents* web_contents = GetWebContentsForHandle(handle, NULL); if (web_contents) { + DCHECK(reply_message_ == NULL); + reply_message_ = reply_message; + web_contents->render_view_host()->InspectElementAt(x, y); - inspect_element_routing_id_ = message.routing_id(); + inspect_element_routing_id_ = reply_message->routing_id(); } else { - Send(new AutomationMsg_InspectElementResponse(message.routing_id(), -1)); + AutomationMsg_InspectElement::WriteReplyParams(reply_message, -1); + Send(reply_message); } } void AutomationProvider::ReceivedInspectElementResponse(int num_resources) { - Send(new AutomationMsg_InspectElementResponse(inspect_element_routing_id_, - num_resources)); + DCHECK(reply_message_ != NULL); + AutomationMsg_InspectElement::WriteReplyParams(reply_message_, + num_resources); + Send(reply_message_); + reply_message_ = NULL; } // Helper class for making changes to the URLRequest ProtocolFactory on the @@ -1915,19 +1926,15 @@ void AutomationProvider::SetFilteredInet(const IPC::Message& message, new SetFilteredInetTask(enabled)); } -void AutomationProvider::GetDownloadDirectory(const IPC::Message& message, - int handle) { +void AutomationProvider::GetDownloadDirectory(int handle, + std::wstring* download_directory) { DLOG(INFO) << "Handling download directory request"; - std::wstring download_directory; if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); DownloadManager* dlm = tab->profile()->GetDownloadManager(); DCHECK(dlm); - download_directory = dlm->download_path().ToWStringHack(); + *download_directory = dlm->download_path().ToWStringHack(); } - - Send(new AutomationMsg_DownloadDirectoryResponse(message.routing_id(), - download_directory)); } void AutomationProvider::OpenNewBrowserWindow(int show_command) { @@ -1939,27 +1946,27 @@ void AutomationProvider::OpenNewBrowserWindow(int show_command) { browser->window()->Show(); } -void AutomationProvider::GetWindowForBrowser(const IPC::Message& message, - int browser_handle) { - bool success = false; - int window_handle = 0; +void AutomationProvider::GetWindowForBrowser(int browser_handle, + bool* success, + int* handle) { + *success = false; + *handle = 0; if (browser_tracker_->ContainsHandle(browser_handle)) { Browser* browser = browser_tracker_->GetResource(browser_handle); HWND hwnd = reinterpret_cast<HWND>(browser->window()->GetNativeHandle()); // Add() returns the existing handle for the resource if any. - window_handle = window_tracker_->Add(hwnd); - success = true; + *handle = window_tracker_->Add(hwnd); + *success = true; } - Send(new AutomationMsg_WindowForBrowserResponse(message.routing_id(), - success, window_handle)); } void AutomationProvider::GetAutocompleteEditForBrowser( - const IPC::Message& message, - int browser_handle) { - bool success = false; - int autocomplete_edit_handle = 0; + int browser_handle, + bool* success, + int* autocomplete_edit_handle) { + *success = false; + *autocomplete_edit_handle = 0; if (browser_tracker_->ContainsHandle(browser_handle)) { Browser* browser = browser_tracker_->GetResource(browser_handle); @@ -1968,17 +1975,16 @@ void AutomationProvider::GetAutocompleteEditForBrowser( LocationBarView* loc_bar_view = testing_interface->GetLocationBarView(); AutocompleteEditView* edit_view = loc_bar_view->location_entry(); // Add() returns the existing handle for the resource if any. - autocomplete_edit_handle = autocomplete_edit_tracker_->Add(edit_view); - success = true; + *autocomplete_edit_handle = autocomplete_edit_tracker_->Add(edit_view); + *success = true; } - Send(new AutomationMsg_AutocompleteEditForBrowserResponse( - message.routing_id(), success, autocomplete_edit_handle)); } -void AutomationProvider::GetBrowserForWindow(const IPC::Message& message, - int window_handle) { - bool success = false; - int browser_handle = 0; +void AutomationProvider::GetBrowserForWindow(int window_handle, + bool* success, + int* browser_handle) { + *success = false; + *browser_handle = 0; if (window_tracker_->ContainsHandle(window_handle)) { HWND window = window_tracker_->GetResource(window_handle); @@ -1993,25 +1999,21 @@ void AutomationProvider::GetBrowserForWindow(const IPC::Message& message, } if (browser) { // Add() returns the existing handle for the resource if any. - browser_handle = browser_tracker_->Add(browser); - success = true; + *browser_handle = browser_tracker_->Add(browser); + *success = true; } } - Send(new AutomationMsg_BrowserForWindowResponse(message.routing_id(), - success, browser_handle)); } -void AutomationProvider::ShowInterstitialPage(const IPC::Message& message, - int tab_handle, - const std::string& html_text) { +void AutomationProvider::ShowInterstitialPage(int tab_handle, + const std::string& html_text, + IPC::Message* reply_message) { if (tab_tracker_->ContainsHandle(tab_handle)) { NavigationController* controller = tab_tracker_->GetResource(tab_handle); TabContents* tab_contents = controller->active_contents(); if (tab_contents->type() == TAB_CONTENTS_WEB) { - AddNavigationStatusListener(controller, - new AutomationMsg_ShowInterstitialPageResponse(message.routing_id(), - true), - NULL); + AddNavigationStatusListener<bool>(controller, reply_message, true, + false, false); WebContents* web_contents = tab_contents->AsWebContents(); AutomationInterstitialPage* interstitial = new AutomationInterstitialPage(web_contents, @@ -2021,99 +2023,103 @@ void AutomationProvider::ShowInterstitialPage(const IPC::Message& message, return; } } - Send(new AutomationMsg_ShowInterstitialPageResponse(message.routing_id(), - false)); + + AutomationMsg_ShowInterstitialPage::WriteReplyParams(reply_message, false); + Send(reply_message); } -void AutomationProvider::HideInterstitialPage(const IPC::Message& message, - int tab_handle) { +void AutomationProvider::HideInterstitialPage(int tab_handle, + bool* success) { + *success = false; WebContents* web_contents = GetWebContentsForHandle(tab_handle, NULL); if (web_contents && web_contents->interstitial_page()) { web_contents->interstitial_page()->DontProceed(); - Send(new AutomationMsg_HideInterstitialPageResponse(message.routing_id(), - true)); - return; + *success = true; } - Send(new AutomationMsg_HideInterstitialPageResponse(message.routing_id(), - false)); } -void AutomationProvider::CloseTab(const IPC::Message& message, - int tab_handle, - bool wait_until_closed) { +void AutomationProvider::CloseTab(int tab_handle, + bool wait_until_closed, + IPC::Message* reply_message) { if (tab_tracker_->ContainsHandle(tab_handle)) { NavigationController* controller = tab_tracker_->GetResource(tab_handle); int index; Browser* browser = Browser::GetBrowserForController(controller, &index); DCHECK(browser); TabClosedNotificationObserver* observer = - new TabClosedNotificationObserver(browser, this, message.routing_id(), - wait_until_closed); + new TabClosedNotificationObserver(browser, this, + reply_message->routing_id(), + wait_until_closed, reply_message); browser->CloseContents(controller->active_contents()); } else { - Send(new AutomationMsg_CloseTabResponse(message.routing_id(), false)); + AutomationMsg_CloseTab::WriteReplyParams(reply_message, false); } } -void AutomationProvider::CloseBrowser(const IPC::Message& message, - int browser_handle) { +void AutomationProvider::CloseBrowser(int browser_handle, + IPC::Message* reply_message) { if (browser_tracker_->ContainsHandle(browser_handle)) { Browser* browser = browser_tracker_->GetResource(browser_handle); - new BrowserClosedNotificationObserver(browser, this, message.routing_id()); + new BrowserClosedNotificationObserver(browser, this, + reply_message->routing_id(), + reply_message); browser->window()->Close(); } else { NOTREACHED(); } } -void AutomationProvider::CreateExternalTab(const IPC::Message& message, - HWND parent, +void AutomationProvider::CloseBrowserAsync(int browser_handle) { + if (browser_tracker_->ContainsHandle(browser_handle)) { + Browser* browser = browser_tracker_->GetResource(browser_handle); + browser->window()->Close(); + } else { + NOTREACHED(); + } +} + +void AutomationProvider::CreateExternalTab(HWND parent, const gfx::Rect& dimensions, - unsigned int style) { - int tab_handle = 0; - HWND tab_container_window = NULL; + unsigned int style, + HWND* tab_container_window, + int* tab_handle) { + *tab_handle = 0; + *tab_container_window = NULL; ExternalTabContainer *external_tab_container = new ExternalTabContainer(this); external_tab_container->Init(profile_, parent, dimensions, style); TabContents* tab_contents = external_tab_container->tab_contents(); if (tab_contents) { - tab_handle = tab_tracker_->Add(tab_contents->controller()); - tab_container_window = *external_tab_container; + *tab_handle = tab_tracker_->Add(tab_contents->controller()); + *tab_container_window = *external_tab_container; } else { delete external_tab_container; } - - Send(new AutomationMsg_CreateExternalTabResponse(message.routing_id(), - tab_container_window, - tab_handle)); } -void AutomationProvider::NavigateInExternalTab(const IPC::Message& message, - int handle, const GURL& url) { - AutomationMsg_NavigationResponseValues rv = AUTOMATION_MSG_NAVIGATION_ERROR; +void AutomationProvider::NavigateInExternalTab( + int handle, const GURL& url, + AutomationMsg_NavigationResponseValues* status) { + *status = AUTOMATION_MSG_NAVIGATION_ERROR; if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); tab->LoadURL(url, GURL(), PageTransition::TYPED); - rv = AUTOMATION_MSG_NAVIGATION_SUCCESS; + *status = AUTOMATION_MSG_NAVIGATION_SUCCESS; } - - Send(new AutomationMsg_NavigateInExternalTabResponse(message.routing_id(), - rv)); } -void AutomationProvider::SetAcceleratorsForTab(const IPC::Message& message, - int handle, +void AutomationProvider::SetAcceleratorsForTab(int handle, HACCEL accel_table, - int accel_entry_count) { - bool status = false; + int accel_entry_count, + bool* status) { + *status = false; + ExternalTabContainer* external_tab = GetExternalTabForHandle(handle); if (external_tab) { external_tab->SetAccelerators(accel_table, accel_entry_count); - status = true; + *status = true; } - Send(new AutomationMsg_SetAcceleratorsForTabResponse(message.routing_id(), - status)); } void AutomationProvider::ProcessUnhandledAccelerator( @@ -2125,6 +2131,17 @@ void AutomationProvider::ProcessUnhandledAccelerator( // This message expects no response. } +void AutomationProvider::WaitForTabToBeRestored(int tab_handle, + IPC::Message* reply_message) { + if (tab_tracker_->ContainsHandle(tab_handle)) { + NavigationController* tab = tab_tracker_->GetResource(tab_handle); + restore_tracker_.reset( + new NavigationControllerRestoredObserver(this, tab, + reply_message->routing_id(), + reply_message)); + } +} + void AutomationProvider::SetInitialFocus(const IPC::Message& message, int handle, bool reverse) { ExternalTabContainer* external_tab = GetExternalTabForHandle(handle); @@ -2134,54 +2151,46 @@ void AutomationProvider::SetInitialFocus(const IPC::Message& message, // This message expects no response. } -void AutomationProvider::WaitForTabToBeRestored( - const IPC::Message& message, - int tab_handle) { - if (tab_tracker_->ContainsHandle(tab_handle)) { - NavigationController* tab = tab_tracker_->GetResource(tab_handle); - restore_tracker_.reset( - new NavigationControllerRestoredObserver(this, tab, - message.routing_id())); - } -} - -void AutomationProvider::GetSecurityState(const IPC::Message& message, - int handle) { +void AutomationProvider::GetSecurityState(int handle, bool* success, + SecurityStyle* security_style, + int* ssl_cert_status, + int* mixed_content_status) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); NavigationEntry* entry = tab->GetActiveEntry(); - Send(new AutomationMsg_GetSecurityStateResponse(message.routing_id(), true, - entry->ssl().security_style(), entry->ssl().cert_status(), - entry->ssl().content_status())); + *success = true; + *security_style = entry->ssl().security_style(); + *ssl_cert_status = entry->ssl().cert_status(); + *mixed_content_status = entry->ssl().content_status(); } else { - Send(new AutomationMsg_GetSecurityStateResponse(message.routing_id(), false, - SECURITY_STYLE_UNKNOWN, - 0, 0)); + *success = false; + *security_style = SECURITY_STYLE_UNKNOWN; + *ssl_cert_status = 0; + *mixed_content_status = 0; } } -void AutomationProvider::GetPageType(const IPC::Message& message, int handle) { +void AutomationProvider::GetPageType(int handle, bool* success, + NavigationEntry::PageType* page_type) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); NavigationEntry* entry = tab->GetActiveEntry(); - NavigationEntry::PageType page_type = entry->page_type(); + *page_type = entry->page_type(); + *success = true; // In order to return the proper result when an interstitial is shown and // no navigation entry were created for it we need to ask the WebContents. - if (page_type == NavigationEntry::NORMAL_PAGE && + if (*page_type == NavigationEntry::NORMAL_PAGE && tab->active_contents()->AsWebContents() && tab->active_contents()->AsWebContents()->showing_interstitial_page()) - page_type = NavigationEntry::INTERSTITIAL_PAGE; - - Send(new AutomationMsg_GetPageTypeResponse(message.routing_id(), true, - page_type)); + *page_type = NavigationEntry::INTERSTITIAL_PAGE; } else { - Send(new AutomationMsg_GetPageTypeResponse(message.routing_id(), false, - NavigationEntry::NORMAL_PAGE)); + *success = false; + *page_type = NavigationEntry::NORMAL_PAGE; } } -void AutomationProvider::ActionOnSSLBlockingPage(const IPC::Message& message, - int handle, bool proceed) { +void AutomationProvider::ActionOnSSLBlockingPage(int handle, bool proceed, + IPC::Message* reply_message) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); NavigationEntry* entry = tab->GetActiveEntry(); @@ -2191,74 +2200,72 @@ void AutomationProvider::ActionOnSSLBlockingPage(const IPC::Message& message, InterstitialPage::GetInterstitialPage(tab_contents->AsWebContents()); if (ssl_blocking_page) { if (proceed) { - AddNavigationStatusListener(tab, - new AutomationMsg_ActionOnSSLBlockingPageResponse( - message.routing_id(), true), - new AutomationMsg_ActionOnSSLBlockingPageResponse( - message.routing_id(), true)); - ssl_blocking_page->Proceed(); + AddNavigationStatusListener<bool>(tab, reply_message, true, true, + false); + ssl_blocking_page->Proceed(); return; } ssl_blocking_page->DontProceed(); - Send(new AutomationMsg_ActionOnSSLBlockingPageResponse( - message.routing_id(), true)); + AutomationMsg_ActionOnSSLBlockingPage::WriteReplyParams(reply_message, + true); + Send(reply_message); return; } } } // We failed. - Send(new AutomationMsg_ActionOnSSLBlockingPageResponse(message.routing_id(), - false)); + AutomationMsg_ActionOnSSLBlockingPage::WriteReplyParams(reply_message, + false); + Send(reply_message); } -void AutomationProvider::BringBrowserToFront(const IPC::Message& message, - int browser_handle) { +void AutomationProvider::BringBrowserToFront(int browser_handle, + bool* success) { if (browser_tracker_->ContainsHandle(browser_handle)) { Browser* browser = browser_tracker_->GetResource(browser_handle); browser->window()->Activate(); - Send(new AutomationMsg_BringBrowserToFrontResponse(message.routing_id(), - true)); + *success = true; } else { - Send(new AutomationMsg_BringBrowserToFrontResponse(message.routing_id(), - false)); + *success = false; } } -void AutomationProvider::IsPageMenuCommandEnabled(const IPC::Message& message, - int browser_handle, - int message_num) { +void AutomationProvider::IsPageMenuCommandEnabled(int browser_handle, + int message_num, + bool* menu_item_enabled) { if (browser_tracker_->ContainsHandle(browser_handle)) { Browser* browser = browser_tracker_->GetResource(browser_handle); - bool menu_item_enabled = + *menu_item_enabled = browser->command_updater()->IsCommandEnabled(message_num); - Send(new AutomationMsg_IsPageMenuCommandEnabledResponse( - message.routing_id(), menu_item_enabled)); } else { - Send(new AutomationMsg_IsPageMenuCommandEnabledResponse( - message.routing_id(), false)); + *menu_item_enabled = false; } } -void AutomationProvider::PrintNow(const IPC::Message& message, int tab_handle) { +void AutomationProvider::PrintNow(int tab_handle, + IPC::Message* reply_message) { NavigationController* tab = NULL; WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); if (web_contents) { FindAndActivateTab(tab); notification_observer_list_.AddObserver( - new DocumentPrintedNotificationObserver(this, message.routing_id())); + new DocumentPrintedNotificationObserver(this, + reply_message->routing_id(), + reply_message)); if (web_contents->PrintNow()) return; } - Send(new AutomationMsg_PrintNowResponse(message.routing_id(), false)); + AutomationMsg_PrintNow::WriteReplyParams(reply_message, false); + Send(reply_message); } -void AutomationProvider::SavePage(const IPC::Message& message, - int tab_handle, +void AutomationProvider::SavePage(int tab_handle, const std::wstring& file_name, const std::wstring& dir_path, - int type) { + int type, + bool* success) { if (!tab_tracker_->ContainsHandle(tab_handle)) { - Send(new AutomationMsg_SavePageResponse(message.routing_id(), false)); + *success = false; return; } @@ -2266,13 +2273,13 @@ void AutomationProvider::SavePage(const IPC::Message& message, Browser* browser = FindAndActivateTab(nav); DCHECK(browser); if (!browser->command_updater()->IsCommandEnabled(IDC_SAVE_PAGE)) { - Send(new AutomationMsg_SavePageResponse(message.routing_id(), false)); + *success = false; return; } TabContents* tab_contents = nav->active_contents(); if (tab_contents->type() != TAB_CONTENTS_WEB) { - Send(new AutomationMsg_SavePageResponse(message.routing_id(), false)); + *success = false; return; } @@ -2282,65 +2289,57 @@ void AutomationProvider::SavePage(const IPC::Message& message, save_type <= SavePackage::SAVE_AS_COMPLETE_HTML); tab_contents->AsWebContents()->SavePage(file_name, dir_path, save_type); - Send(new AutomationMsg_SavePageResponse( - message.routing_id(), true)); + *success = true; } -void AutomationProvider::GetAutocompleteEditText(const IPC::Message& message, - int autocomplete_edit_handle) { - bool success = false; - std::wstring text; +void AutomationProvider::GetAutocompleteEditText(int autocomplete_edit_handle, + bool* success, + std::wstring* text) { + *success = false; if (autocomplete_edit_tracker_->ContainsHandle(autocomplete_edit_handle)) { - text = autocomplete_edit_tracker_->GetResource(autocomplete_edit_handle)-> + *text = autocomplete_edit_tracker_->GetResource(autocomplete_edit_handle)-> GetText(); - success = true; + *success = true; } - Send(new AutomationMsg_AutocompleteEditGetTextResponse(message.routing_id(), - success, text)); } -void AutomationProvider::SetAutocompleteEditText(const IPC::Message& message, - int autocomplete_edit_handle, - const std::wstring& text) { - bool success = false; +void AutomationProvider::SetAutocompleteEditText(int autocomplete_edit_handle, + const std::wstring& text, + bool* success) { + *success = false; if (autocomplete_edit_tracker_->ContainsHandle(autocomplete_edit_handle)) { autocomplete_edit_tracker_->GetResource(autocomplete_edit_handle)-> SetUserText(text); - success = true; + *success = true; } - Send(new AutomationMsg_AutocompleteEditSetTextResponse( - message.routing_id(), success)); } void AutomationProvider::AutocompleteEditGetMatches( - const IPC::Message& message, - int autocomplete_edit_handle) { - bool success = false; - std::vector<AutocompleteMatchData> matches; + int autocomplete_edit_handle, + bool* success, + std::vector<AutocompleteMatchData>* matches) { + *success = false; if (autocomplete_edit_tracker_->ContainsHandle(autocomplete_edit_handle)) { const AutocompleteResult& result = autocomplete_edit_tracker_-> GetResource(autocomplete_edit_handle)->model()->result(); for (AutocompleteResult::const_iterator i = result.begin(); i != result.end(); ++i) - matches.push_back(AutocompleteMatchData(*i)); - success = true; + matches->push_back(AutocompleteMatchData(*i)); + *success = true; } - Send(new AutomationMsg_AutocompleteEditGetMatchesResponse( - message.routing_id(), success, matches)); } void AutomationProvider::AutocompleteEditIsQueryInProgress( - const IPC::Message& message, - int autocomplete_edit_handle) { - bool success = false; - bool query_in_progress = false; + int autocomplete_edit_handle, + bool* success, + bool* query_in_progress) { + *success = false; + *query_in_progress = false; if (autocomplete_edit_tracker_->ContainsHandle(autocomplete_edit_handle)) { - query_in_progress = autocomplete_edit_tracker_-> + *query_in_progress = autocomplete_edit_tracker_-> GetResource(autocomplete_edit_handle)->model()->query_in_progress(); - success = true; + *success = true; } - Send(new AutomationMsg_AutocompleteEditIsQueryInProgressResponse( - message.routing_id(), success, query_in_progress)); } void AutomationProvider::OnMessageFromExternalHost( @@ -2448,22 +2447,19 @@ void TestingAutomationProvider::OnRemoveProvider() { AutomationProviderList::GetInstance()->RemoveProvider(this); } -void AutomationProvider::GetSSLInfoBarCount(const IPC::Message& message, - int handle) { - int count = -1; // -1 means error. +void AutomationProvider::GetSSLInfoBarCount(int handle, int* count) { + *count = -1; // -1 means error. if (tab_tracker_->ContainsHandle(handle)) { NavigationController* nav_controller = tab_tracker_->GetResource(handle); if (nav_controller) - count = nav_controller->active_contents()->infobar_delegate_count(); + *count = nav_controller->active_contents()->infobar_delegate_count(); } - Send(new AutomationMsg_GetSSLInfoBarCountResponse(message.routing_id(), - count)); } -void AutomationProvider::ClickSSLInfoBarLink(const IPC::Message& message, - int handle, +void AutomationProvider::ClickSSLInfoBarLink(int handle, int info_bar_index, - bool wait_for_navigation) { + bool wait_for_navigation, + IPC::Message* reply_message) { bool success = false; if (tab_tracker_->ContainsHandle(handle)) { NavigationController* nav_controller = tab_tracker_->GetResource(handle); @@ -2471,11 +2467,8 @@ void AutomationProvider::ClickSSLInfoBarLink(const IPC::Message& message, int count = nav_controller->active_contents()->infobar_delegate_count(); if (info_bar_index >= 0 && info_bar_index < count) { if (wait_for_navigation) { - AddNavigationStatusListener(nav_controller, - new AutomationMsg_ClickSSLInfoBarLinkResponse( - message.routing_id(), true), - new AutomationMsg_ClickSSLInfoBarLinkResponse( - message.routing_id(), true)); + AddNavigationStatusListener<bool>(nav_controller, reply_message, + true, true, false); } InfoBarDelegate* delegate = nav_controller->active_contents()->GetInfoBarDelegateAt( @@ -2487,98 +2480,86 @@ void AutomationProvider::ClickSSLInfoBarLink(const IPC::Message& message, } } if (!wait_for_navigation || !success) - Send(new AutomationMsg_ClickSSLInfoBarLinkResponse(message.routing_id(), - success)); + AutomationMsg_ClickSSLInfoBarLink::WriteReplyParams(reply_message, + success); } -void AutomationProvider::GetLastNavigationTime(const IPC::Message& message, - int handle) { +void AutomationProvider::GetLastNavigationTime(int handle, + int64* last_navigation_time) { Time time = tab_tracker_->GetLastNavigationTime(handle); - Send(new AutomationMsg_GetLastNavigationTimeResponse(message.routing_id(), - time.ToInternalValue())); + *last_navigation_time = time.ToInternalValue(); } -void AutomationProvider::WaitForNavigation(const IPC::Message& message, - int handle, - int64 last_navigation_time) { +void AutomationProvider::WaitForNavigation(int handle, + int64 last_navigation_time, + IPC::Message* reply_message) { NavigationController* controller = NULL; if (tab_tracker_->ContainsHandle(handle)) controller = tab_tracker_->GetResource(handle); Time time = tab_tracker_->GetLastNavigationTime(handle); if (time.ToInternalValue() > last_navigation_time || !controller) { - Send(new AutomationMsg_WaitForNavigationResponse(message.routing_id(), - controller != NULL)); + AutomationMsg_WaitForNavigation::WriteReplyParams(reply_message, + controller != NULL); return; } - AddNavigationStatusListener(controller, - new AutomationMsg_WaitForNavigationResponse(message.routing_id(), - true), - new AutomationMsg_WaitForNavigationResponse(message.routing_id(), - true)); + AddNavigationStatusListener<bool>(controller, reply_message, true, true, + false); } -void AutomationProvider::SetIntPreference(const IPC::Message& message, - int handle, +void AutomationProvider::SetIntPreference(int handle, const std::wstring& name, - int value) { - bool success = false; + int value, + bool* success) { + *success = false; if (browser_tracker_->ContainsHandle(handle)) { Browser* browser = browser_tracker_->GetResource(handle); browser->profile()->GetPrefs()->SetInteger(name.c_str(), value); - success = true; + *success = true; } - Send(new AutomationMsg_SetIntPreferenceResponse(message.routing_id(), - success)); } -void AutomationProvider::SetStringPreference(const IPC::Message& message, - int handle, +void AutomationProvider::SetStringPreference(int handle, const std::wstring& name, - const std::wstring& value) { - bool success = false; + const std::wstring& value, + bool* success) { + *success = false; if (browser_tracker_->ContainsHandle(handle)) { Browser* browser = browser_tracker_->GetResource(handle); browser->profile()->GetPrefs()->SetString(name.c_str(), value); - success = true; + *success = true; } - Send(new AutomationMsg_SetStringPreferenceResponse(message.routing_id(), - success)); } -void AutomationProvider::GetBooleanPreference(const IPC::Message& message, - int handle, - const std::wstring& name) { - bool success = false; - bool value = false; +void AutomationProvider::GetBooleanPreference(int handle, + const std::wstring& name, + bool* success, + bool* value) { + *success = false; + *value = false; if (browser_tracker_->ContainsHandle(handle)) { Browser* browser = browser_tracker_->GetResource(handle); - value = browser->profile()->GetPrefs()->GetBoolean(name.c_str()); - success = true; + *value = browser->profile()->GetPrefs()->GetBoolean(name.c_str()); + *success = true; } - Send(new AutomationMsg_GetBooleanPreferenceResponse(message.routing_id(), - success, value)); } -void AutomationProvider::SetBooleanPreference(const IPC::Message& message, - int handle, +void AutomationProvider::SetBooleanPreference(int handle, const std::wstring& name, - bool value) { - bool success = false; + bool value, + bool* success) { + *success = false; if (browser_tracker_->ContainsHandle(handle)) { Browser* browser = browser_tracker_->GetResource(handle); browser->profile()->GetPrefs()->SetBoolean(name.c_str(), value); - success = true; + *success = true; } - Send(new AutomationMsg_SetBooleanPreferenceResponse(message.routing_id(), - success)); } // Gets the current used encoding name of the page in the specified tab. -void AutomationProvider::GetPageCurrentEncoding(const IPC::Message& message, - int tab_handle) { - std::wstring current_encoding; +void AutomationProvider::GetPageCurrentEncoding( + int tab_handle, std::wstring* current_encoding) { if (tab_tracker_->ContainsHandle(tab_handle)) { NavigationController* nav = tab_tracker_->GetResource(tab_handle); Browser* browser = FindAndActivateTab(nav); @@ -2587,18 +2568,16 @@ void AutomationProvider::GetPageCurrentEncoding(const IPC::Message& message, if (browser->command_updater()->IsCommandEnabled(IDC_ENCODING_MENU)) { TabContents* tab_contents = nav->active_contents(); DCHECK(tab_contents->type() == TAB_CONTENTS_WEB); - current_encoding = tab_contents->AsWebContents()->encoding(); + *current_encoding = tab_contents->AsWebContents()->encoding(); } } - Send(new AutomationMsg_GetPageCurrentEncodingResponse(message.routing_id(), - current_encoding)); } // Gets the current used encoding name of the page in the specified tab. -void AutomationProvider::OverrideEncoding(const IPC::Message& message, - int tab_handle, - const std::wstring& encoding_name) { - bool succeed = false; +void AutomationProvider::OverrideEncoding(int tab_handle, + const std::wstring& encoding_name, + bool* success) { + *success = false; if (tab_tracker_->ContainsHandle(tab_handle)) { NavigationController* nav = tab_tracker_->GetResource(tab_handle); Browser* browser = FindAndActivateTab(nav); @@ -2611,12 +2590,10 @@ void AutomationProvider::OverrideEncoding(const IPC::Message& message, CharacterEncoding::GetCommandIdByCanonicalEncodingName(encoding_name); if (selected_encoding_id) { browser->OverrideEncoding(selected_encoding_id); - succeed = true; + *success = true; } } } - Send(new AutomationMsg_OverrideEncodingResponse(message.routing_id(), - succeed)); } void AutomationProvider::SavePackageShouldPromptUser( diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index a8ca47f..8597b99 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -22,8 +22,9 @@ #include "chrome/browser/automation/automation_autocomplete_edit_tracker.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/history/history.h" -#include "chrome/common/ipc_channel_proxy.h" +#include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/common/ipc_message.h" +#include "chrome/common/ipc_sync_channel.h" #include "chrome/common/notification_observer.h" #include "chrome/views/event.h" #include "webkit/glue/find_in_page_request.h" @@ -31,6 +32,8 @@ class LoginHandler; class NavigationControllerRestoredObserver; class ExternalTabContainer; +enum AutomationMsg_NavigationResponseValues; +struct AutocompleteMatchData; class AutomationProvider : public base::RefCounted<AutomationProvider>, public IPC::Channel::Listener, @@ -55,9 +58,17 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // navigation observer is returned. This object should NOT be deleted and // should be released by calling the corresponding // RemoveNavigationStatusListener method. + // The template argument NavigationCodeType facilitate the creation of the + // approriate NavigationNotificationObserver instance, which subscribes to + // the events published by the NotificationService and sends out a response + // to the IPC message. + template<class NavigationCodeType> NotificationObserver* AddNavigationStatusListener( - NavigationController* tab, IPC::Message* completed_response, - IPC::Message* auth_needed_response); + NavigationController* tab, IPC::Message* reply_message, + NavigationCodeType success_code, + NavigationCodeType auth_needed_code, + NavigationCodeType failed_code); + void RemoveNavigationStatusListener(NotificationObserver* obs); // Add an observer for the TabStrip. Currently only Tab append is observed. A @@ -66,7 +77,8 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // NOT be deleted and should be released by calling the corresponding // RemoveTabStripObserver method. NotificationObserver* AddTabStripObserver(Browser* parent, - int32 routing_id); + int32 routing_id, + IPC::Message* reply_message); void RemoveTabStripObserver(NotificationObserver* obs); // Get the index of a particular NavigationController object @@ -92,41 +104,43 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // Received response from inspector controller void ReceivedInspectElementResponse(int num_resources); + IPC::Message* reply_message_release() { + IPC::Message* reply_message = reply_message_; + reply_message_ = NULL; + return reply_message; + } + private: // IPC Message callbacks. - void CloseBrowser(const IPC::Message& message, int handle); - void ActivateTab(const IPC::Message& message, int handle, int at_index); - void AppendTab(const IPC::Message& message, int handle, const GURL& url); - void CloseTab(const IPC::Message& message, - int tab_handle, - bool wait_until_closed); - - void GetActiveTabIndex(const IPC::Message& message, int handle); - void GetCookies(const IPC::Message& message, const GURL& url, int handle); - void SetCookie(const IPC::Message& message, - const GURL& url, + void CloseBrowser(int handle, IPC::Message* reply_message); + void CloseBrowserAsync(int browser_handle); + void ActivateTab(int handle, int at_index, int* status); + void AppendTab(int handle, const GURL& url, IPC::Message* reply_message); + void CloseTab(int tab_handle, bool wait_until_closed, + IPC::Message* reply_message); + + void GetActiveTabIndex(int handle, int* active_tab_index); + void GetCookies(const GURL& url, int handle, int* value_size, + std::string* value); + void SetCookie(const GURL& url, const std::string value, - int handle); - void GetBrowserWindowCount(const IPC::Message& message); - void GetShowingAppModalDialog(const IPC::Message& message); - void ClickAppModalDialogButton(const IPC::Message& message, - int button); - void GetBrowserWindow(const IPC::Message& message, int index); - void GetLastActiveBrowserWindow(const IPC::Message& message); - void GetActiveWindow(const IPC::Message& message); - void GetWindowHWND(const IPC::Message& message, int handle); - void ExecuteBrowserCommand(const IPC::Message& message, - int handle, - int command); - void WindowGetViewBounds(const IPC::Message& message, - int handle, - int view_id, - bool screen_coordinates); - void WindowSimulateDrag(const IPC::Message& message, - int handle, + int handle, + int* response_value); + void GetBrowserWindowCount(int* window_count); + void GetShowingAppModalDialog(bool* showing_dialog, int* dialog_button); + void ClickAppModalDialogButton(int button, bool* success); + void GetBrowserWindow(int index, int* handle); + void GetLastActiveBrowserWindow(int* handle); + void GetActiveWindow(int* handle); + void GetWindowHWND(int handle, HWND* win32_handle); + void ExecuteBrowserCommand(int handle, int command, bool* success); + void WindowGetViewBounds(int handle, int view_id, bool screen_coordinates, + bool* success, gfx::Rect* bounds); + void WindowSimulateDrag(int handle, std::vector<POINT> drag_path, int flags, - bool press_escape_en_route); + bool press_escape_en_route, + IPC::Message* reply_message); void WindowSimulateClick(const IPC::Message& message, int handle, POINT click, @@ -135,43 +149,41 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, int handle, wchar_t key, int flags); - void SetWindowVisible(const IPC::Message& message, int handle, bool visible); - void IsWindowActive(const IPC::Message& message, int handle); + void SetWindowVisible(int handle, bool visible, bool* result); + void IsWindowActive(int handle, bool* success, bool* is_active); void ActivateWindow(const IPC::Message& message, int handle); - void GetTabCount(const IPC::Message& message, int handle); - void GetTab(const IPC::Message& message, int win_handle, int tab_index); - void GetTabHWND(const IPC::Message& message, int handle); - void GetTabProcessID(const IPC::Message& message, int handle); - void GetTabTitle(const IPC::Message& message, int handle); - void GetTabURL(const IPC::Message& message, int handle); + void GetTabCount(int handle, int* tab_count); + void GetTab(int win_handle, int tab_index, int* tab_handle); + void GetTabHWND(int handle, HWND* tab_hwnd); + void GetTabProcessID(int handle, int* process_id); + void GetTabTitle(int handle, int* title_string_size, std::wstring* title); + void GetTabURL(int handle, bool* success, GURL* url); void HandleUnused(const IPC::Message& message, int handle); - void NavigateToURL(const IPC::Message& message, int handle, const GURL& url); - void NavigationAsync(const IPC::Message& message, - int handle, - const GURL& url); - void GoBack(const IPC::Message& message, int handle); - void GoForward(const IPC::Message& message, int handle); - void Reload(const IPC::Message& message, int handle); - void SetAuth(const IPC::Message& message, int tab_handle, - const std::wstring& username, const std::wstring& password); - void CancelAuth(const IPC::Message& message, int tab_handle); - void NeedsAuth(const IPC::Message& message, int tab_handle); - void GetRedirectsFrom(const IPC::Message& message, - int tab_handle, - const GURL& source_url); - void ExecuteJavascript(const IPC::Message& message, - int handle, + void NavigateToURL(int handle, const GURL& url, IPC::Message* reply_message); + void NavigationAsync(int handle, const GURL& url, bool* status); + void GoBack(int handle, IPC::Message* reply_message); + void GoForward(int handle, IPC::Message* reply_message); + void Reload(int handle, IPC::Message* reply_message); + void SetAuth(int tab_handle, const std::wstring& username, + const std::wstring& password, IPC::Message* reply_message); + void CancelAuth(int tab_handle, IPC::Message* reply_message); + void NeedsAuth(int tab_handle, bool* needs_auth); + void GetRedirectsFrom(int tab_handle, + const GURL& source_url, + IPC::Message* reply_message); + void ExecuteJavascript(int handle, const std::wstring& frame_xpath, - const std::wstring& script); - void GetShelfVisibility(const IPC::Message& message, int handle); + const std::wstring& script, + IPC::Message* reply_message); + void GetShelfVisibility(int handle, bool* visible); void SetFilteredInet(const IPC::Message& message, bool enabled); void ScheduleMouseEvent(views::View* view, views::Event::EventType type, POINT point, int flags); - void GetFocusedViewID(const IPC::Message& message, int handle); + void GetFocusedViewID(int handle, int* view_id); // Helper function to find the browser window that contains a given // NavigationController and activate that tab. @@ -182,67 +194,72 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // to the Browser with given handle. void ApplyAccelerator(int handle, int id); - void GetConstrainedWindowCount(const IPC::Message& message, - int handle); - void GetConstrainedWindow(const IPC::Message& message, int handle, int index); + void GetConstrainedWindowCount(int handle, int* count); + void GetConstrainedWindow(int handle, int index, int* cwindow_handle); - void GetConstrainedTitle(const IPC::Message& message, int handle); + void GetConstrainedTitle(int handle, int* title, + std::wstring* title_string_size); - void GetConstrainedWindowBounds(const IPC::Message& message, - int handle); + void GetConstrainedWindowBounds(int handle, bool* exists, + gfx::Rect* rect); // This function has been deprecated, please use HandleFindRequest. - void HandleFindInPageRequest(const IPC::Message& message, - int handle, + void HandleFindInPageRequest(int handle, const std::wstring& find_request, int forward, - int match_case); + int match_case, + int* active_ordinal, + int* matches_found); // Responds to the FindInPage request, retrieves the search query parameters, // launches an observer to listen for results and issues a StartFind request. - void HandleFindRequest(const IPC::Message& message, - int handle, - const FindInPageRequest& request); + void HandleFindRequest(int handle, + const FindInPageRequest& request, + IPC::Message* reply_message); // Responds to requests to open the FindInPage window. void HandleOpenFindInPageRequest(const IPC::Message& message, int handle); // Get the visibility state of the Find window. - void GetFindWindowVisibility(const IPC::Message& message, int handle); + void GetFindWindowVisibility(int handle, bool* visible); // Responds to requests to find the location of the Find window. - void HandleFindWindowLocationRequest(const IPC::Message& message, int handle); + void HandleFindWindowLocationRequest(int handle, int* x, int* y); // Get the visibility state of the Bookmark bar. - void GetBookmarkBarVisitility(const IPC::Message& message, int handle); + void GetBookmarkBarVisibility(int handle, bool* visible, bool* animating); // Responds to InspectElement request - void HandleInspectElementRequest(const IPC::Message& message, - int handle, + void HandleInspectElementRequest(int handle, int x, - int y); + int y, + IPC::Message* reply_message); - void GetDownloadDirectory(const IPC::Message& message, int handle); + void GetDownloadDirectory(int handle, + std::wstring* download_directory); // Retrieves a Browser from a Window and vice-versa. - void GetWindowForBrowser(const IPC::Message& message, int window_handle); - void GetBrowserForWindow(const IPC::Message& message, int browser_handle); + void GetWindowForBrowser(int window_handle, bool* success, int* handle); + void GetBrowserForWindow(int window_handle, bool* success, + int* browser_handle); - void GetAutocompleteEditForBrowser(const IPC::Message& message, - int browser_handle); + void GetAutocompleteEditForBrowser(int browser_handle, bool* success, + int* autocomplete_edit_handle); void OpenNewBrowserWindow(int show_command); - void ShowInterstitialPage(const IPC::Message& message, - int tab_handle, - const std::string& html_text); - void HideInterstitialPage(const IPC::Message& message, int tab_handle); - - void CreateExternalTab(const IPC::Message& message, HWND parent, - const gfx::Rect& dimensions, unsigned int style); - void NavigateInExternalTab(const IPC::Message& message, int handle, - const GURL& url); + void ShowInterstitialPage(int tab_handle, + const std::string& html_text, + IPC::Message* reply_message); + void HideInterstitialPage(int tab_handle, bool* success); + + void CreateExternalTab(HWND parent, const gfx::Rect& dimensions, + unsigned int style, HWND* tab_container_window, + int* tab_handle); + void NavigateInExternalTab( + int handle, const GURL& url, + AutomationMsg_NavigationResponseValues* status); // The container of an externally hosted tab calls this to reflect any // accelerator keys that it did not process. This gives the tab a chance // to handle the keys @@ -252,118 +269,123 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, void SetInitialFocus(const IPC::Message& message, int handle, bool reverse); // See comment in AutomationMsg_WaitForTabToBeRestored. - void WaitForTabToBeRestored(const IPC::Message& message, int tab_handle); + void WaitForTabToBeRestored(int tab_handle, IPC::Message* reply_message); // This sets the keyboard accelerators to be used by an externally // hosted tab. This call is not valid on a regular tab hosted within // Chrome. - void SetAcceleratorsForTab(const IPC::Message& message, int handle, - HACCEL accel_table, int accel_entry_count); + void SetAcceleratorsForTab(int handle, HACCEL accel_table, + int accel_entry_count, bool* status); // Gets the security state for the tab associated to the specified |handle|. - void GetSecurityState(const IPC::Message& message, int handle); + void GetSecurityState(int handle, bool* success, + SecurityStyle* security_style, int* ssl_cert_status, + int* mixed_content_status); // Gets the page type for the tab associated to the specified |handle|. - void GetPageType(const IPC::Message& message, int handle); + void GetPageType(int handle, bool* success, + NavigationEntry::PageType* page_type); // Simulates an action on the SSL blocking page at the tab specified by // |handle|. If |proceed| is true, it is equivalent to the user pressing the // 'Proceed' button, if false the 'Get me out of there button'. // Not that this fails if the tab is not displaying a SSL blocking page. - void ActionOnSSLBlockingPage(const IPC::Message& message, - int handle, - bool proceed); + void ActionOnSSLBlockingPage(int handle, + bool proceed, + IPC::Message* reply_message); // Brings the browser window to the front and activates it. - void BringBrowserToFront(const IPC::Message& message, int browser_handle); + void BringBrowserToFront(int browser_handle, bool* success); // Checks to see if a command on the browser's CommandController is enabled. - void IsPageMenuCommandEnabled(const IPC::Message& message, - int browser_handle, - int message_num); + void IsPageMenuCommandEnabled(int browser_handle, + int message_num, + bool* menu_item_enabled); // Prints the current tab immediately. - void PrintNow(const IPC::Message& message, int tab_handle); + void PrintNow(int tab_handle, IPC::Message* reply_message); // Save the current web page. - void SavePage(const IPC::Message& message, - int tab_handle, + void SavePage(int tab_handle, const std::wstring& file_name, const std::wstring& dir_path, - int type); + int type, + bool* success); // Retrieves the visible text from the autocomplete edit. - void GetAutocompleteEditText(const IPC::Message& message, - int autocomplete_edit_handle); + void GetAutocompleteEditText(int autocomplete_edit_handle, + bool* success, std::wstring* text); // Sets the visible text from the autocomplete edit. - void SetAutocompleteEditText(const IPC::Message& message, - int autocomplete_edit_handle, - const std::wstring& text); + void SetAutocompleteEditText(int autocomplete_edit_handle, + const std::wstring& text, + bool* success); // Retrieves if a query to an autocomplete provider is in progress. - void AutocompleteEditIsQueryInProgress(const IPC::Message& message, - int autocomplete_edit_handle); + void AutocompleteEditIsQueryInProgress(int autocomplete_edit_handle, + bool* success, + bool* query_in_progress); // Retrieves the individual autocomplete matches displayed by the popup. - void AutocompleteEditGetMatches(const IPC::Message& message, - int autocomplete_edit_handle); + void AutocompleteEditGetMatches(int autocomplete_edit_handle, + bool* success, + std::vector<AutocompleteMatchData>* matches); // Handler for a message sent by the automation client. void OnMessageFromExternalHost(int handle, const std::string& target, const std::string& message); // Retrieves the number of SSL related info-bars currently showing in |count|. - void GetSSLInfoBarCount(const IPC::Message& message, int handle); + void GetSSLInfoBarCount(int handle, int* count); // Causes a click on the link of the info-bar at |info_bar_index|. If // |wait_for_navigation| is true, it sends the reply after a navigation has // occurred. - void ClickSSLInfoBarLink(const IPC::Message& message, - int handle, - int info_bar_index, - bool wait_for_navigation); + void ClickSSLInfoBarLink(int handle, int info_bar_index, + bool wait_for_navigation, + IPC::Message* reply_message); // Retrieves the last time a navigation occurred for the tab. - void GetLastNavigationTime(const IPC::Message& message, int handle); + void GetLastNavigationTime(int handle, int64* last_navigation_time); // Waits for a new navigation in the tab if none has happened since // |last_navigation_time|. - void WaitForNavigation(const IPC::Message& message, - int handle, - int64 last_navigation_time); + void WaitForNavigation(int handle, + int64 last_navigation_time, + IPC::Message* reply_message); // Sets the int value for preference with name |name|. - void SetIntPreference(const IPC::Message& message, - int handle, + void SetIntPreference(int handle, const std::wstring& name, - int value); + int value, + bool* success); // Sets the string value for preference with name |name|. - void SetStringPreference(const IPC::Message& message, - int handle, + void SetStringPreference(int handle, const std::wstring& name, - const std::wstring& value); + const std::wstring& value, + bool* success); // Gets the bool value for preference with name |name|. - void GetBooleanPreference(const IPC::Message& message, - int handle, - const std::wstring& name); + void GetBooleanPreference(int handle, + const std::wstring& name, + bool* success, + bool* value); // Sets the bool value for preference with name |name|. - void SetBooleanPreference(const IPC::Message& message, - int handle, + void SetBooleanPreference(int handle, const std::wstring& name, - bool value); + bool value, + bool* success); // Gets the current used encoding name of the page in the specified tab. - void GetPageCurrentEncoding(const IPC::Message& message, int tab_handle); + void GetPageCurrentEncoding(int tab_handle, std::wstring* current_encoding); // Uses the specified encoding to override the encoding of the page in the // specified tab. - void OverrideEncoding(const IPC::Message& message, - int tab_handle, - const std::wstring& encoding_name); + void OverrideEncoding(int tab_handle, + const std::wstring& encoding_name, + bool* success); void SavePackageShouldPromptUser(const IPC::Message& message, bool should_prompt); @@ -417,6 +439,8 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, Profile* profile_; + IPC::Message* reply_message_; + DISALLOW_COPY_AND_ASSIGN(AutomationProvider); }; diff --git a/chrome/common/ipc_message_macros.h b/chrome/common/ipc_message_macros.h index 411752f..cd8ed9b 100644 --- a/chrome/common/ipc_message_macros.h +++ b/chrome/common/ipc_message_macros.h @@ -109,6 +109,7 @@ #undef IPC_SYNC_MESSAGE_ROUTED1_1 #undef IPC_SYNC_MESSAGE_ROUTED1_2 #undef IPC_SYNC_MESSAGE_ROUTED1_3 +#undef IPC_SYNC_MESSAGE_ROUTED1_4 #undef IPC_SYNC_MESSAGE_ROUTED2_0 #undef IPC_SYNC_MESSAGE_ROUTED2_1 #undef IPC_SYNC_MESSAGE_ROUTED2_2 @@ -119,6 +120,7 @@ #undef IPC_SYNC_MESSAGE_ROUTED3_3 #undef IPC_SYNC_MESSAGE_ROUTED4_0 #undef IPC_SYNC_MESSAGE_ROUTED4_1 +#undef IPC_SYNC_MESSAGE_ROUTED4_2 #if defined(IPC_MESSAGE_MACROS_ENUMS) #undef IPC_MESSAGE_MACROS_ENUMS @@ -252,6 +254,9 @@ #define IPC_SYNC_MESSAGE_ROUTED1_3(msg_class, type1_in, type1_out, type2_out, type3_out) \ msg_class##__ID, +#define IPC_SYNC_MESSAGE_ROUTED1_4(msg_class, type1_in, type1_out, type2_out, type3_out, type4_out) \ + msg_class##__ID, + #define IPC_SYNC_MESSAGE_ROUTED2_0(msg_class, type1_in, type2_in) \ msg_class##__ID, @@ -282,6 +287,9 @@ #define IPC_SYNC_MESSAGE_ROUTED4_1(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out) \ msg_class##__ID, +#define IPC_SYNC_MESSAGE_ROUTED4_2(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out, type2_out) \ + msg_class##__ID, + // Message crackers and handlers. // Prefer to use the IPC_BEGIN_MESSAGE_MAP_EX to the older macros since they // allow you to detect when a message could not be de-serialized. Usage: @@ -516,6 +524,9 @@ LogFunction g_log_function_mapping[LastMsgIndex]; #define IPC_SYNC_MESSAGE_ROUTED1_3(msg_class, type1_in, type1_out, type2_out, type3_out) \ IPC_MESSAGE_LOG(msg_class) +#define IPC_SYNC_MESSAGE_ROUTED1_4(msg_class, type1_in, type1_out, type2_out, type3_out, type4_out) \ + IPC_MESSAGE_LOG(msg_class) + #define IPC_SYNC_MESSAGE_ROUTED2_0(msg_class, type1_in, type2_in) \ IPC_MESSAGE_LOG(msg_class) @@ -546,6 +557,9 @@ LogFunction g_log_function_mapping[LastMsgIndex]; #define IPC_SYNC_MESSAGE_ROUTED4_1(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out) \ IPC_MESSAGE_LOG(msg_class) +#define IPC_SYNC_MESSAGE_ROUTED4_2(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out, type2_out) \ + IPC_MESSAGE_LOG(msg_class) + #elif defined(IPC_MESSAGE_MACROS_CLASSES) #undef IPC_MESSAGE_MACROS_CLASSES @@ -982,6 +996,18 @@ LogFunction g_log_function_mapping[LastMsgIndex]; arg1, MakeRefTuple(*arg2, *arg3, *arg4)) {} \ }; +#define IPC_SYNC_MESSAGE_ROUTED1_4(msg_class, type1_in, type1_out, type2_out, type3_out, type4_out) \ + class msg_class : \ + public IPC::MessageWithReply<type1_in, \ + Tuple4<type1_out&, type2_out&, type3_out&, type4_out&> >{ \ + public: \ + enum { ID = msg_class##__ID }; \ + msg_class(int routing_id, const type1_in& arg1, type1_out* arg2, type2_out* arg3, type3_out* arg4, type4_out* arg5) \ + : IPC::MessageWithReply<type1_in, \ + Tuple4<type1_out&, type2_out&, type3_out&, type4_out&> >(routing_id, ID, \ + arg1, MakeRefTuple(*arg2, *arg3, *arg4, *arg5)) {} \ + }; + #define IPC_SYNC_MESSAGE_ROUTED2_0(msg_class, type1_in, type2_in) \ class msg_class : \ public IPC::MessageWithReply<Tuple2<type1_in, type2_in>, Tuple0 > { \ @@ -1099,5 +1125,17 @@ LogFunction g_log_function_mapping[LastMsgIndex]; MakeTuple(arg1, arg2, arg3, arg4), MakeRefTuple(*arg6)) {} \ }; +#define IPC_SYNC_MESSAGE_ROUTED4_2(msg_class, type1_in, type2_in, type3_in, type4_in, type1_out, type2_out) \ + class msg_class : \ + public IPC::MessageWithReply<Tuple4<type1_in, type2_in, type3_in, type4_in>, \ + Tuple2<type1_out&, type2_out&> > { \ + public: \ + enum { ID = msg_class##__ID }; \ + msg_class(int routing_id, const type1_in& arg1, const type2_in& arg2, const type3_in& arg3, const type4_in& arg4, type1_out* arg5, type2_out* arg6) \ + : IPC::MessageWithReply<Tuple4<type1_in, type2_in, type3_in, type4_in>, \ + Tuple2<type1_out&, type2_out&> >(routing_id, ID, \ + MakeTuple(arg1, arg2, arg3, arg4), MakeRefTuple(*arg5, *arg6)) {} \ + }; + #endif // #if defined() diff --git a/chrome/test/automation/autocomplete_edit_proxy.cc b/chrome/test/automation/autocomplete_edit_proxy.cc index 3758c74..f7f23f2e 100644 --- a/chrome/test/automation/autocomplete_edit_proxy.cc +++ b/chrome/test/automation/autocomplete_edit_proxy.cc @@ -21,34 +21,23 @@ bool AutocompleteEditProxy::GetText(std::wstring* text) const { return false; } - IPC::Message* response = NULL; - if (!sender_->SendAndWaitForResponse( - new AutomationMsg_AutocompleteEditGetTextRequest(0, handle_), &response, - AutomationMsg_AutocompleteEditGetTextResponse::ID)) - return false; - scoped_ptr<IPC::Message> response_deleter(response); + bool result = false; - Tuple2<bool, std::wstring> returned_result; - if (!AutomationMsg_AutocompleteEditGetTextResponse::Read(response, - &returned_result) || !returned_result.a) - return false; + sender_->Send(new AutomationMsg_AutocompleteEditGetText(0, handle_, &result, + text)); - text->swap(returned_result.b); - return true; + return result; } bool AutocompleteEditProxy::SetText(const std::wstring& text) { if (!is_valid()) return false; - IPC::Message* response = NULL; - if (!sender_->SendAndWaitForResponse( - new AutomationMsg_AutocompleteEditSetTextRequest(0, handle_, text), - &response, AutomationMsg_AutocompleteEditSetTextResponse::ID)) - return false; + bool result = false; - delete response; - return true; + sender_->Send(new AutomationMsg_AutocompleteEditSetText(0, handle_, text, + &result)); + return result; } bool AutocompleteEditProxy::IsQueryInProgress(bool* query_in_progress) const { @@ -59,20 +48,13 @@ bool AutocompleteEditProxy::IsQueryInProgress(bool* query_in_progress) const { return false; } - IPC::Message* response = NULL; - if (!sender_->SendAndWaitForResponse( - new AutomationMsg_AutocompleteEditIsQueryInProgressRequest(0, handle_), - &response, AutomationMsg_AutocompleteEditIsQueryInProgressResponse::ID)) - return false; - scoped_ptr<IPC::Message> response_deleter(response); + bool edit_exists = false; - Tuple2<bool, bool> returned_result; - if (!AutomationMsg_AutocompleteEditIsQueryInProgressResponse::Read( - response, &returned_result) || !returned_result.a) - return false; + sender_->Send( + new AutomationMsg_AutocompleteEditIsQueryInProgress( + 0, handle_, &edit_exists, query_in_progress)); - *query_in_progress = returned_result.b; - return true; + return edit_exists; } @@ -97,19 +79,10 @@ bool AutocompleteEditProxy::GetAutocompleteMatches(Matches* matches) const { return false; } - IPC::Message* response = NULL; - if (!sender_->SendAndWaitForResponse( - new AutomationMsg_AutocompleteEditGetMatchesRequest(0, handle_), - &response, AutomationMsg_AutocompleteEditGetMatchesResponse::ID)) - return false; - scoped_ptr<IPC::Message> response_deleter(response); + bool edit_exists = false; - Tuple2<bool, Matches> returned_result; - if (!AutomationMsg_AutocompleteEditGetMatchesResponse::Read( - response, &returned_result) || !returned_result.a) - return false; + sender_->Send(new AutomationMsg_AutocompleteEditGetMatches( + 0, handle_, &edit_exists, matches)); - *matches = returned_result.b; - return true; + return edit_exists; } - diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 9b31477..f73c252 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -40,130 +40,123 @@ IPC_BEGIN_MESSAGES(Automation) // This message is fired when the initial tab(s) are finished loading. IPC_MESSAGE_ROUTED0(AutomationMsg_InitialLoadsComplete) - // This message notifies the AutomationProvider to append a new tab the window - // with the given handle. The response contains the index of the new tab, or - // -1 if the request failed. + // This message notifies the AutomationProvider to append a new tab the + // window with the given handle. The return value contains the index of + // the new tab, or -1 if the request failed. // The second parameter is the url to be loaded in the new tab. - IPC_MESSAGE_ROUTED2(AutomationMsg_AppendTabRequest, int, GURL) - IPC_MESSAGE_ROUTED1(AutomationMsg_AppendTabResponse, int) + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_AppendTab, int, GURL, int) // This message requests the (zero-based) index for the currently - // active tab in the window with the given handle. The response contains + // active tab in the window with the given handle. The return value contains // the index of the active tab, or -1 if the request failed. - IPC_MESSAGE_ROUTED1(AutomationMsg_ActiveTabIndexRequest, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_ActiveTabIndexResponse, int) + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_ActiveTabIndex, int, int) // This message notifies the AutomationProvider to active the tab. // The first parameter is the handle to window resource. // The second parameter is the (zero-based) index to be activated - IPC_MESSAGE_ROUTED2(AutomationMsg_ActivateTabRequest, int, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_ActivateTabResponse, int) + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_ActivateTab, int, int, int) // This message requests the cookie value for given url in the // profile of the tab identified by the second parameter. The first - // parameter is the URL string. The response contains the length of the cookie - // value string. On failure, this length = -1. - IPC_MESSAGE_ROUTED2(AutomationMsg_GetCookiesRequest, GURL, int) - IPC_MESSAGE_ROUTED2(AutomationMsg_GetCookiesResponse, int, std::string) + // parameter is the URL string. The response contains the length of the + // cookie value string. On failure, this length = -1. + IPC_SYNC_MESSAGE_ROUTED2_2(AutomationMsg_GetCookies, GURL, int, + int, std::string) // This message notifies the AutomationProvider to set and broadcast a cookie // with given name and value for the given url in the profile of the tab // identified by the third parameter. The first parameter is the URL // string, and the second parameter is the cookie name and value to be set. - // The response returns a non-negative value on success. - IPC_MESSAGE_ROUTED3(AutomationMsg_SetCookieRequest, GURL, std::string, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_SetCookieResponse, int) - - // This message notifies the AutomationProvider to navigate to a specified url - // in the tab with given handle. The first parameter is the handle to the tab - // resource. The second parameter is the target url. The response contains a - // status code which is nonnegative on success. - IPC_MESSAGE_ROUTED2(AutomationMsg_NavigateToURLRequest, int, GURL) - IPC_MESSAGE_ROUTED1(AutomationMsg_NavigateToURLResponse, - AutomationMsg_NavigationResponseValues) + // The return value is a non-negative value on success. + IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_SetCookie, GURL, std::string, + int, int) + + // This message notifies the AutomationProvider to navigate to a specified + // url in the tab with given handle. The first parameter is the handle to + // the tab resource. The second parameter is the target url. The return + // value contains a status code which is nonnegative on success. + // See AutomationMsg_NavigationResponseValues for the return value. + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_NavigateToURL, int, GURL, + AutomationMsg_NavigationResponseValues) // This message is used to implement the asynchronous version of // NavigateToURL. - IPC_MESSAGE_ROUTED2(AutomationMsg_NavigationAsyncRequest, - int /* tab handle */, - GURL) - IPC_MESSAGE_ROUTED1(AutomationMsg_NavigationAsyncResponse, - bool /* error value */) + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_NavigationAsync, + int /* tab handle */, + GURL, + bool /* result */) // This message notifies the AutomationProvider to navigate back in session // history in the tab with given handle. The first parameter is the handle - // to the tab resource. The response contains a status code which is + // to the tab resource. The return value contains a status code which is // nonnegative on success. - IPC_MESSAGE_ROUTED1(AutomationMsg_GoBackRequest, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_GoBackResponse, - AutomationMsg_NavigationResponseValues) + // see AutomationMsg_NavigationResponseValues for the navigation response + // values. + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_GoBack, int, + AutomationMsg_NavigationResponseValues) // This message notifies the AutomationProvider to navigate forward in session // history in the tab with given handle. The first parameter is the handle // to the tab resource. The response contains a status code which is // nonnegative on success. - IPC_MESSAGE_ROUTED1(AutomationMsg_GoForwardRequest, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_GoForwardResponse, - AutomationMsg_NavigationResponseValues) + // see AutomationMsg_NavigationResponseValues for the navigation response + // values. + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_GoForward, int, + AutomationMsg_NavigationResponseValues) // This message requests the number of browser windows that the app currently - // has open. The parameter in the response is the number of windows. - IPC_MESSAGE_ROUTED0(AutomationMsg_BrowserWindowCountRequest) - IPC_MESSAGE_ROUTED1(AutomationMsg_BrowserWindowCountResponse, int) + // has open. The return value is the number of windows. + IPC_SYNC_MESSAGE_ROUTED0_1(AutomationMsg_BrowserWindowCount, int) // This message requests the handle (int64 app-unique identifier) of the // window with the given (zero-based) index. On error, the returned handle // value is 0. - IPC_MESSAGE_ROUTED1(AutomationMsg_BrowserWindowRequest, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_BrowserWindowResponse, int) + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_BrowserWindow, int, int) // This message requests the number of tabs in the window with the given - // handle. The response contains the number of tabs, or -1 if the request - // failed. - IPC_MESSAGE_ROUTED1(AutomationMsg_TabCountRequest, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_TabCountResponse, int) + // handle. The return value contains the number of tabs, or -1 if the + // request failed. + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_TabCount, int, int) // This message requests the handle of the tab with the given (zero-based) // index in the given app window. First parameter specifies the given window // handle, second specifies the given tab_index. On error, the returned handle // value is 0. - IPC_MESSAGE_ROUTED2(AutomationMsg_TabRequest, int, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_TabResponse, int) + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_Tab, int, int, int) // This message requests the the title of the tab with the given handle. - // The response contains the size of the title string. On error, this value - // should be -1 and empty string. Note that the title can be empty in which - // case the size would be 0. - IPC_MESSAGE_ROUTED1(AutomationMsg_TabTitleRequest, int) - IPC_MESSAGE_ROUTED2(AutomationMsg_TabTitleResponse, int, std::wstring) + // The return value contains the size of the title string. On error, this + // value should be -1 and empty string. Note that the title can be empty in + // which case the size would be 0. + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_TabTitle, + int, + int, + std::wstring) // This message requests the url of the tab with the given handle. - // The response contains a success flag and the URL string. The URL will + // The return value contains a success flag and the URL string. The URL will // be empty on failure, and it still may be empty on success. - IPC_MESSAGE_ROUTED1(AutomationMsg_TabURLRequest, - int /* tab handle */) - IPC_MESSAGE_ROUTED2(AutomationMsg_TabURLResponse, - bool /* success flag*/, - GURL) + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_TabURL, + int /* tab handle */, + bool /* success flag */, + GURL) #if defined(OS_WIN) // TODO(port): Port these messages. // // This message requests the HWND of the top-level window that corresponds // to the given automation handle. - // The response contains the HWND value, which is 0 if the call fails. - IPC_MESSAGE_ROUTED1(AutomationMsg_WindowHWNDRequest, - int /* automation handle */) - IPC_MESSAGE_ROUTED1(AutomationMsg_WindowHWNDResponse, - HWND /* Win32 handle */) + // The return value contains the HWND value, which is 0 if the call fails. + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_WindowHWND, + int /* automation handle */, + HWND /* Win32 handle */ ) // This message requests the HWND of the tab that corresponds // to the given automation handle. - // The response contains the HWND value, which is 0 if the call fails. - IPC_MESSAGE_ROUTED1(AutomationMsg_TabHWNDRequest, - int /* tab_handle */) - IPC_MESSAGE_ROUTED1(AutomationMsg_TabHWNDResponse, - HWND /* win32 Window Handle*/) + // The return value contains the HWND value, which is 0 if the call fails. + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_TabHWND, + int /* tab_handle */, + HWND /* win32 Window Handle */) #endif // defined(OS_WIN) // This message notifies the AutomationProxy that a handle that it has @@ -181,100 +174,86 @@ IPC_BEGIN_MESSAGES(Automation) // authentication data to the specified tab, in response to an HTTP/FTP // authentication challenge. // The response status will be negative on error. - IPC_MESSAGE_ROUTED3(AutomationMsg_SetAuthRequest, - int, // tab handle - std::wstring, // username - std::wstring) // password - IPC_MESSAGE_ROUTED1(AutomationMsg_SetAuthResponse, - int) // status + IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_SetAuth, + int, // tab handle + std::wstring, // username + std::wstring, // password + int) // status // This message tells the AutomationProvider to cancel the login in the // specified tab. // The response status will be negative on error. - IPC_MESSAGE_ROUTED1(AutomationMsg_CancelAuthRequest, - int) // tab handle - IPC_MESSAGE_ROUTED1(AutomationMsg_CancelAuthResponse, - int) // status + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_CancelAuth, + int, // tab handle + int) // status // Requests that the automation provider ask history for the most recent // chain of redirects coming from the given URL. The response must be // decoded by the caller manually; it contains an integer indicating the // number of URLs, followed by that many wstrings indicating a chain of // redirects. On failure, the count will be negative. - IPC_MESSAGE_ROUTED2(AutomationMsg_RedirectsFromRequest, - int, // tab handle - GURL) // source URL - IPC_MESSAGE_ROUTED2(AutomationMsg_RedirectsFromResponse, - bool /* succeeded */, - std::vector<GURL> /* redirects */) + IPC_SYNC_MESSAGE_ROUTED2_2(AutomationMsg_RedirectsFrom, + int, // tab handle + GURL, // source URL + bool /* succeeded */, + std::vector<GURL> /* redirects */) // This message asks the AutomationProvider whether a tab is waiting for // login info. - IPC_MESSAGE_ROUTED1(AutomationMsg_NeedsAuthRequest, - int) // tab handle - IPC_MESSAGE_ROUTED1(AutomationMsg_NeedsAuthResponse, - bool) // status + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_NeedsAuth, + int, // tab handle + bool) // status // This message requests the AutomationProvider to apply a certain // accelerator. It is completely asynchronous with the resulting accelerator // action. - IPC_MESSAGE_ROUTED2(AutomationMsg_ApplyAcceleratorRequest, - int, // window handle - int) // accelerator id like (IDC_BACK, IDC_FORWARD ...) - // The list can be found at - // chrome/app/chrome_dll_resource.h + IPC_SYNC_MESSAGE_ROUTED2_0(AutomationMsg_ApplyAccelerator, + int, // window handle + int) // accelerator id like (IDC_BACK, + // IDC_FORWARD, etc) + // The list can be found at + // chrome/app/chrome_dll_resource.h // This message requests that the AutomationProvider executes a JavaScript, // which is sent embedded in a 'javascript:' URL. // The javascript is executed in context of child frame whose xpath // is passed as parameter (context_frame). The execution results in // a serialized JSON string response. - IPC_MESSAGE_ROUTED3(AutomationMsg_DomOperationRequest, - int, // tab handle - std::wstring, // context_frame - std::wstring) // the javascript to be executed - - // This message is used to communicate the values received by the - // callback binding the JS to Cpp. This message forms the second leg in - // the communication channel. The values are originally received in the - // renderer which are then sent to the app (wrapped as json) using - // corresponding message in render_messages_internal.h - // This message simply relays the json string. - IPC_MESSAGE_ROUTED1(AutomationMsg_DomOperationResponse, - std::string) // the serialized json string containing - // the result of a javascript execution + IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_DomOperation, + int, // tab handle + std::wstring, // context_frame + std::wstring, // the javascript to be executed + std::string) // the serialized json string + // containing the result of a + // javascript execution // Is the Download Shelf visible for the specified tab? - IPC_MESSAGE_ROUTED1(AutomationMsg_ShelfVisibilityRequest, - int /* tab_handle */) - IPC_MESSAGE_ROUTED1(AutomationMsg_ShelfVisibilityResponse, - bool /* is_visible */) + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_ShelfVisibility, + int /* tab_handle */, + bool /* is_visible */) // This message requests the number of constrained windows in the tab with - // the given handle. The response contains the number of constrained windows, - // or -1 if the request failed. - IPC_MESSAGE_ROUTED1(AutomationMsg_ConstrainedWindowCountRequest, - int /* tab_handle */) - IPC_MESSAGE_ROUTED1(AutomationMsg_ConstrainedWindowCountResponse, - int /* constrained_window_count */) + // the given handle. The return value contains the number of constrained + // windows, or -1 if the request failed. + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_ConstrainedWindowCount, + int /* tab_handle */, + int /* constrained_window_count */) // This message requests the handle of the constrained window with the given // (zero-based) index in the given tab. First parameter specifies the given // tab handle, second specifies the given child_index. On error, the returned // handle value is 0. - IPC_MESSAGE_ROUTED2(AutomationMsg_ConstrainedWindowRequest, - int, /* window_handle */ - int) /* child_index */ - - IPC_MESSAGE_ROUTED1(AutomationMsg_ConstrainedWindowResponse, - int) /* constrained_handle */ + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_ConstrainedWindow, + int, /* window_handle */ + int, /* child_index */ + int) /* constrained_handle */ // This message requests the the title of the constrained window with the - // given handle. The response contains the size of the title string and title - // string. On error, this value should be -1 and empty string. Note that the - // title can be empty in which case the size would be 0. - IPC_MESSAGE_ROUTED1(AutomationMsg_ConstrainedTitleRequest, int) - IPC_MESSAGE_ROUTED2(AutomationMsg_ConstrainedTitleResponse, int, std::wstring) + // given handle. The return value contains the size of the title string and + // title string. On error, this value should be -1 and empty string. Note + // that the title can be empty in which case the size would be 0. + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_ConstrainedTitle, int, + int, std::wstring) // This message requests the bounds of the specified View element in // window coordinates. @@ -286,8 +265,8 @@ IPC_BEGIN_MESSAGES(Automation) // Response: // bool - true if the view was found // gfx::Rect - the bounds of the view, in window coordinates - IPC_MESSAGE_ROUTED3(AutomationMsg_WindowViewBoundsRequest, int, int, bool) - IPC_MESSAGE_ROUTED2(AutomationMsg_WindowViewBoundsResponse, bool, gfx::Rect) + IPC_SYNC_MESSAGE_ROUTED3_2(AutomationMsg_WindowViewBounds, int, int, + bool, bool, gfx::Rect) #if defined(OS_WIN) // TODO(port): Port these messages. @@ -301,9 +280,8 @@ IPC_BEGIN_MESSAGES(Automation) // defined in chrome/views/event.h // Response: // bool - true if the drag could be performed - IPC_MESSAGE_ROUTED4(AutomationMsg_WindowDragRequest, - int, std::vector<POINT>, int, bool) - IPC_MESSAGE_ROUTED1(AutomationMsg_WindowDragResponse, bool) + IPC_SYNC_MESSAGE_ROUTED4_1(AutomationMsg_WindowDrag, + int, std::vector<POINT>, int, bool, bool) #endif // defined(OS_WIN) // Similar to AutomationMsg_InitialLoadsComplete, this indicates that the @@ -313,70 +291,68 @@ IPC_BEGIN_MESSAGES(Automation) int /* time */) // This message starts a find within a tab corresponding to the supplied - // tab handle. The response contains the number of matches found on the page - // within the tab specified. The parameter 'search_string' specifies what - // string to search for, 'forward' specifies whether to search in forward - // direction (1=forward, 0=back), 'match_case' specifies case sensitivity + // tab handle. The return value contains the number of matches found on the + // page within the tab specified. The parameter 'search_string' specifies + // what string to search for, 'forward' specifies whether to search in + // forward direction (1=forward, 0=back), 'match_case' specifies case + // sensitivity // (1=case sensitive, 0=case insensitive). If an error occurs, matches_found // will be -1. // // NOTE: These two messages have been deprecated, please use the new messages // AutomationMsg_FindRequest and AutomationMsg_FindInPageResponse2 below. // - IPC_MESSAGE_ROUTED4(AutomationMsg_FindInPageRequest, // DEPRECATED. - int, /* tab_handle */ - std::wstring, /* find_request */ - int, /* forward */ - int /* match_case */) - IPC_MESSAGE_ROUTED1(AutomationMsg_FindInPageResponse, // DEPRECATED. - int /* matches_found */) + IPC_SYNC_MESSAGE_ROUTED4_2(AutomationMsg_FindInPage, // DEPRECATED. + int, /* tab_handle */ + std::wstring, /* find_request */ + int, /* forward */ + int /* match_case */, + int /* active_ordinal */, + int /* matches_found */) // This message sends a inspect element request for a given tab. The response // contains the number of resources loaded by the inspector controller. - IPC_MESSAGE_ROUTED3(AutomationMsg_InspectElementRequest, - int, /* tab_handle */ - int, /* x */ - int /* y */) - IPC_MESSAGE_ROUTED1(AutomationMsg_InspectElementResponse, int) + IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_InspectElement, + int, /* tab_handle */ + int, /* x */ + int /* y */, + int) // This message requests the process ID of the tab that corresponds // to the given automation handle. - // The response has an integer corresponding to the PID of the tab's + // The return value has an integer corresponding to the PID of the tab's // renderer, 0 if the tab currently has no renderer process, or -1 on error. - IPC_MESSAGE_ROUTED1(AutomationMsg_TabProcessIDRequest, - int /* tab_handle */) - IPC_MESSAGE_ROUTED1(AutomationMsg_TabProcessIDResponse, - int /* process ID */) + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_TabProcessID, + int /* tab_handle */, + int /* process ID */) // This tells the browser to enable or disable the filtered network layer. IPC_MESSAGE_ROUTED1(AutomationMsg_SetFilteredInet, bool /* enabled */) // Gets the directory that downloads will occur in for the active profile. - IPC_MESSAGE_ROUTED1(AutomationMsg_DownloadDirectoryRequest, - int /* tab_handle */) - IPC_MESSAGE_ROUTED1(AutomationMsg_DownloadDirectoryResponse, - std::wstring /* directory */) + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_DownloadDirectory, + int /* tab_handle */, + std::wstring /* directory */) // This message requests the id of the view that has the focus in the // specified window. If no view is focused, -1 is returned. Note that the // window should either be a ViewWindow or a Browser. - IPC_MESSAGE_ROUTED1(AutomationMsg_GetFocusedViewIDRequest, - int /* view_handle */) - IPC_MESSAGE_ROUTED1(AutomationMsg_GetFocusedViewIDResponse, - int /* focused_view_id */) + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_GetFocusedViewID, + int /* view_handle */, + int /* focused_view_id */) // This message shows/hides the window. - IPC_MESSAGE_ROUTED2(AutomationMsg_SetWindowVisibleRequest, - int /* view_handle */, bool /* visible */) - IPC_MESSAGE_ROUTED1(AutomationMsg_SetWindowVisibleResponse, - bool /* success */) + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_SetWindowVisible, + int /* view_handle */, + bool /* visible */, + bool /* success */) // Gets the active status of a window. - IPC_MESSAGE_ROUTED1(AutomationMsg_IsWindowActiveRequest, - int /* view_handle */) - IPC_MESSAGE_ROUTED2(AutomationMsg_IsWindowActiveResponse, - bool /* success */, bool /* active */) + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_IsWindowActive, + int /* view_handle */, + bool /* success */, + bool /* active */) // Makes the specified window the active window. IPC_MESSAGE_ROUTED1(AutomationMsg_ActivateWindow, int /* view_handle */) @@ -387,35 +363,31 @@ IPC_BEGIN_MESSAGES(Automation) // This message requests the handle (int64 app-unique identifier) of the // current active top window. On error, the returned handle value is 0. - IPC_MESSAGE_ROUTED0(AutomationMsg_ActiveWindowRequest) - IPC_MESSAGE_ROUTED1(AutomationMsg_ActiveWindowResponse, int) + IPC_SYNC_MESSAGE_ROUTED0_1(AutomationMsg_ActiveWindow, int) // This message requests the browser associated with the specified window // handle. - // The response contains a success flag and the handle of the browser. - IPC_MESSAGE_ROUTED1(AutomationMsg_BrowserForWindowRequest, - int /* window handle */) - IPC_MESSAGE_ROUTED2(AutomationMsg_BrowserForWindowResponse, - bool /* success flag */, - int /* browser handle */) + // The return value contains a success flag and the handle of the browser. + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_BrowserForWindow, + int /* window handle */, + bool /* success flag */, + int /* browser handle */) // This message requests the window associated with the specified browser // handle. - // The response contains a success flag and the handle of the window. - IPC_MESSAGE_ROUTED1(AutomationMsg_WindowForBrowserRequest, - int /* browser handle */) - IPC_MESSAGE_ROUTED2(AutomationMsg_WindowForBrowserResponse, - bool /* success flag */, - int /* window handle */) + // The return value contains a success flag and the handle of the window. + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_WindowForBrowser, + int /* browser handle */, + bool /* success flag */, + int /* window handle */) // This message requests the AutocompleteEdit associated with the specified // browser handle. - // The response contains a success flag and the handle of the omnibox. - IPC_MESSAGE_ROUTED1(AutomationMsg_AutocompleteEditForBrowserRequest, - int /* browser handle */) - IPC_MESSAGE_ROUTED2(AutomationMsg_AutocompleteEditForBrowserResponse, - bool /* success flag */, - int /* AutocompleteEdit handle */) + // The return value contains a success flag and the handle of the omnibox. + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_AutocompleteEditForBrowser, + int /* browser handle */, + bool /* success flag */, + int /* AutocompleteEdit handle */) #if defined(OS_WIN) // TODO(port): Port this message. @@ -427,7 +399,7 @@ IPC_BEGIN_MESSAGES(Automation) // POINT - the point to click // int - the flags which identify the mouse button(s) for the click, as // defined in chrome/views/event.h - IPC_MESSAGE_ROUTED3(AutomationMsg_WindowClickRequest, int, POINT, int) + IPC_MESSAGE_ROUTED3(AutomationMsg_WindowClick, int, POINT, int) #endif // defined(OS_WIN) // This message requests that a key press be performed. @@ -436,7 +408,7 @@ IPC_BEGIN_MESSAGES(Automation) // wchar_t - char of the key that was pressed. // int - the flags which identify the modifiers (shift, ctrl, alt) // associated for, as defined in chrome/views/event.h - IPC_MESSAGE_ROUTED3(AutomationMsg_WindowKeyPressRequest, int, wchar_t, int) + IPC_MESSAGE_ROUTED3(AutomationMsg_WindowKeyPress, int, wchar_t, int) #if defined(OS_WIN) // TODO(port): Port these messages. @@ -447,22 +419,21 @@ IPC_BEGIN_MESSAGES(Automation) // HWND - handle to a window acting as a parent/owner for the new tab. // gfx::Rect - initial dimensions. // style - window style to be used at the time of cration. - IPC_MESSAGE_ROUTED3(AutomationMsg_CreateExternalTab, - HWND /* owner_or_parent*/, - gfx::Rect /* dimensions */, - unsigned int /* style */) - // The response contains the HWND of the window that contains the external - // tab and the handle to the newly created tab. - IPC_MESSAGE_ROUTED2(AutomationMsg_CreateExternalTabResponse, HWND, int) + IPC_SYNC_MESSAGE_ROUTED3_2(AutomationMsg_CreateExternalTab, + HWND /* owner_or_parent*/, + gfx::Rect /* dimensions */, + unsigned int /* style */, + HWND /* The window handle is returned here */, + int /* Handle to the new tab */) #endif // defined(OS_WIN) // This message notifies the AutomationProvider to navigate to a specified // url in the external tab with given handle. The first parameter is the // handle to the tab resource. The second parameter is the target url. - // The response contains a status code which is nonnegative on success. - IPC_MESSAGE_ROUTED2(AutomationMsg_NavigateInExternalTabRequest, int, GURL) - IPC_MESSAGE_ROUTED1(AutomationMsg_NavigateInExternalTabResponse, - AutomationMsg_NavigationResponseValues) + // The return value contains a status code which is nonnegative on success. + // see AutomationMsg_NavigationResponseValues for the navigation response. + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_NavigateInExternalTab, int, GURL, + AutomationMsg_NavigationResponseValues) // This message is an outgoing message from Chrome to an external host. // It is a notification that the NavigationState was changed @@ -486,26 +457,25 @@ IPC_BEGIN_MESSAGES(Automation) // text in an interstitial page in the tab with given handle. The first // parameter is the handle to the tab resource. The second parameter is the // html text to be displayed. - // The response contains a success flag. - IPC_MESSAGE_ROUTED2(AutomationMsg_ShowInterstitialPageRequest, - int, - std::string) - IPC_MESSAGE_ROUTED1(AutomationMsg_ShowInterstitialPageResponse, bool) + // The return value contains a success flag. + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_ShowInterstitialPage, + int, + std::string, + bool) // This message notifies the AutomationProvider to hide the current - // interstitial page in the tab with given handle. The parameter is the handle - // to the tab resource. - // The response contains a success flag. - IPC_MESSAGE_ROUTED1(AutomationMsg_HideInterstitialPageRequest, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_HideInterstitialPageResponse, bool) + // interstitial page in the tab with given handle. The parameter is the + // handle to the tab resource. + // The return value contains a success flag. + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_HideInterstitialPage, int, + bool) // This message requests that a tab be closed. // Request: // - int: handle of the tab to close // - bool: if true the proxy blocks until the tab has completely closed, // otherwise the proxy only blocks until it initiates the close. - IPC_MESSAGE_ROUTED2(AutomationMsg_CloseTabRequest, int, bool) - IPC_MESSAGE_ROUTED1(AutomationMsg_CloseTabResponse, bool) + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_CloseTab, int, bool, bool) // This message requests that the browser be closed. // Request: @@ -514,9 +484,10 @@ IPC_BEGIN_MESSAGES(Automation) // - bool: whether the operation was successfull. // - bool: whether the browser process will be terminated as a result (if // this was the last closed browser window). - IPC_MESSAGE_ROUTED1(AutomationMsg_CloseBrowserRequest, int) - IPC_MESSAGE_ROUTED2(AutomationMsg_CloseBrowserResponse, bool, bool) + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_CloseBrowser, int, bool, + bool) + IPC_MESSAGE_ROUTED1(AutomationMsg_CloseBrowserRequestAsync, int) #if defined(OS_WIN) // TODO(port): Port these messages. // @@ -529,8 +500,8 @@ IPC_BEGIN_MESSAGES(Automation) // - int: The number of entries in the accelerator table // Response: // -bool: whether the operation was successful. - IPC_MESSAGE_ROUTED3(AutomationMsg_SetAcceleratorsForTab, int, HACCEL, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_SetAcceleratorsForTabResponse, bool) + IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_SetAcceleratorsForTab, int, HACCEL, + int, bool) // This message is an outgoing message from Chrome to an external host. // It is a request to process a keyboard accelerator. @@ -589,11 +560,7 @@ IPC_BEGIN_MESSAGES(Automation) // - int: handle of the tab // Response: // - bool: whether the operation was successful. - IPC_MESSAGE_ROUTED1(AutomationMsg_WaitForTabToBeRestored, int) - - // Sent in response to AutomationMsg_WaitForTabToBeRestored once the tab has - // finished loading. - IPC_MESSAGE_ROUTED0(AutomationMsg_TabFinishedRestoring) + IPC_SYNC_MESSAGE_ROUTED1_0(AutomationMsg_WaitForTabToBeRestored, int) // This message is an outgoing message from Chrome to an external host. // It is a notification that a navigation happened @@ -617,12 +584,13 @@ IPC_BEGIN_MESSAGES(Automation) // - int: the status of the server's ssl cert (0 means no errors or no ssl // was used). // - int: the mixed content state, 0 means no mixed/unsafe contents. - IPC_MESSAGE_ROUTED1(AutomationMsg_GetSecurityState, int) - IPC_MESSAGE_ROUTED4(AutomationMsg_GetSecurityStateResponse, - bool, - SecurityStyle, - int, - int) + + IPC_SYNC_MESSAGE_ROUTED1_4(AutomationMsg_GetSecurityState, + int, + bool, + SecurityStyle, + int, + int) // This message requests the page type of the page displayed in the specified // tab (normal, error or interstitial). @@ -631,10 +599,8 @@ IPC_BEGIN_MESSAGES(Automation) // Response: // - bool: whether the operation was successful. // - NavigationEntry::PageType: the type of the page currently displayed. - IPC_MESSAGE_ROUTED1(AutomationMsg_GetPageType, int) - IPC_MESSAGE_ROUTED2(AutomationMsg_GetPageTypeResponse, - bool, - NavigationEntry::PageType) + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_GetPageType, int, bool, + NavigationEntry::PageType) // This message simulates the user action on the SSL blocking page showing in // the specified tab. This message is only effective if an interstitial page @@ -644,8 +610,8 @@ IPC_BEGIN_MESSAGES(Automation) // - bool: whether to proceed or abort the navigation // Response: // - bool: whether the operation was successful. - IPC_MESSAGE_ROUTED2(AutomationMsg_ActionOnSSLBlockingPage, int, bool) - IPC_MESSAGE_ROUTED1(AutomationMsg_ActionOnSSLBlockingPageResponse, bool) + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_ActionOnSSLBlockingPage, int, bool, + bool) // Message to request that a browser window is brought to the front and // activated. @@ -653,8 +619,7 @@ IPC_BEGIN_MESSAGES(Automation) // - int: handle of the browser window. // Response: // - bool: True if the browser is brought to the front. - IPC_MESSAGE_ROUTED1(AutomationMsg_BringBrowserToFront, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_BringBrowserToFrontResponse, bool) + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_BringBrowserToFront, int, bool) // Message to request whether a certain item is enabled of disabled in the // "Page" menu in the browser window @@ -664,105 +629,96 @@ IPC_BEGIN_MESSAGES(Automation) // - int: IDC message identifier to query if enabled // Response: // - bool: True if the command is enabled on the Page menu - IPC_MESSAGE_ROUTED2(AutomationMsg_IsPageMenuCommandEnabled, int, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_IsPageMenuCommandEnabledResponse, bool) + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_IsPageMenuCommandEnabled, int, int, + bool) // This message notifies the AutomationProvider to print the tab with given // handle. The first parameter is the handle to the tab resource. The - // response contains a bool which is true on success. - IPC_MESSAGE_ROUTED1(AutomationMsg_PrintNowRequest, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_PrintNowResponse, bool) + // return value contains a bool which is true on success. + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_PrintNow, int, bool) // This message notifies the AutomationProvider to reload the current page in // the tab with given handle. The first parameter is the handle to the tab - // resource. The response contains a status code which is nonnegative on + // resource. The return value contains a status code which is nonnegative on // success. - IPC_MESSAGE_ROUTED1(AutomationMsg_ReloadRequest, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_ReloadResponse, - AutomationMsg_NavigationResponseValues) + // see AutomationMsg_NavigationResponseValues for the navigation response. + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_Reload, int, + AutomationMsg_NavigationResponseValues) // This message requests the handle (int64 app-unique identifier) of the // last active browser window, or the browser at index 0 if there is no last // active browser, or it no longer exists. Returns 0 if no browser windows // exist. - IPC_MESSAGE_ROUTED0(AutomationMsg_LastActiveBrowserWindowRequest) - IPC_MESSAGE_ROUTED1(AutomationMsg_LastActiveBrowserWindowResponse, int) + IPC_SYNC_MESSAGE_ROUTED0_1(AutomationMsg_LastActiveBrowserWindow, int) // This message requests the bounds of a constrained window (relative to its // containing TabContents). On an internal error, the boolean in the result // will be set to false. - IPC_MESSAGE_ROUTED1(AutomationMsg_ConstrainedWindowBoundsRequest, - int /* tab_handle */) - IPC_MESSAGE_ROUTED2(AutomationMsg_ConstrainedWindowBoundsResponse, - bool /* the requested window exists */, - gfx::Rect /* constrained_window_count */) + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_ConstrainedWindowBounds, + int /* tab_handle */, + bool /* the requested window exists */, + gfx::Rect /* constrained_window_count */) // This message notifies the AutomationProvider to save the page with given // handle. The first parameter is the handle to the tab resource. The second // parameter is the main HTML file name. The third parameter is the directory // for saving resources. The fourth parameter is the saving type: 0 for HTML // only; 1 for complete web page. - // The response contains a bool which is true on success. - IPC_MESSAGE_ROUTED4(AutomationMsg_SavePageRequest, int, std::wstring, - std::wstring, int) - IPC_MESSAGE_ROUTED1(AutomationMsg_SavePageResponse, bool) - + // The return value contains a bool which is true on success. + IPC_SYNC_MESSAGE_ROUTED4_1(AutomationMsg_SavePage, int, std::wstring, + std::wstring, int, bool) // This message requests the text currently being displayed in the // AutocompleteEdit. The parameter is the handle to the AutocompleteEdit. - // The response is a string indicating the text in the AutocompleteEdit. - IPC_MESSAGE_ROUTED1(AutomationMsg_AutocompleteEditGetTextRequest, - int /* autocomplete edit handle */) - IPC_MESSAGE_ROUTED2(AutomationMsg_AutocompleteEditGetTextResponse, - bool /* the requested autocomplete edit exists */, - std::wstring /* omnibox text */) + // The return value is a string indicating the text in the AutocompleteEdit. + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_AutocompleteEditGetText, + int /* autocomplete edit handle */, + bool /* the requested autocomplete edit exists */, + std::wstring /* omnibox text */) // This message sets the text being displayed in the AutocompleteEdit. The // first parameter is the handle to the omnibox and the second parameter is // the text to be displayed in the AutocompleteEdit. - // The response has no parameters and is returned when the operation has + // The return value has no parameters and is returned when the operation has // completed. - IPC_MESSAGE_ROUTED2(AutomationMsg_AutocompleteEditSetTextRequest, - int /* autocomplete edit handle */, - std::wstring /* text to set */) - IPC_MESSAGE_ROUTED1(AutomationMsg_AutocompleteEditSetTextResponse, - bool /* the requested autocomplete edit exists */) + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_AutocompleteEditSetText, + int /* autocomplete edit handle */, + std::wstring /* text to set */, + bool /* the requested autocomplete edit exists */) // This message requests if a query to a autocomplete provider is still in // progress. The first parameter in the request is the handle to the // autocomplete edit. - // The first parameter in the response indicates if the request succeeded. - // The second parameter in indicates if a query is still in progress. - IPC_MESSAGE_ROUTED1(AutomationMsg_AutocompleteEditIsQueryInProgressRequest, - int /* autocomplete edit handle*/) - IPC_MESSAGE_ROUTED2(AutomationMsg_AutocompleteEditIsQueryInProgressResponse, - bool /* the requested autocomplete edit exists */, - bool /* indicates if a query is in progress */) + // The first return value indicates if the request succeeded. + // The second return value indicates if a query is still in progress. + IPC_SYNC_MESSAGE_ROUTED1_2( \ + AutomationMsg_AutocompleteEditIsQueryInProgress, + int /* autocomplete edit handle*/, + bool /* the requested autocomplete edit exists */, + bool /* indicates if a query is in progress */) // This message requests a list of the autocomplete messages currently being // displayed by the popup. The parameter in the request is a handle to the // autocomplete edit. - // The first parameter in the response indicates if the request was - // successful while the second parameter is the actual list of matches. - IPC_MESSAGE_ROUTED1(AutomationMsg_AutocompleteEditGetMatchesRequest, - int /* autocomplete edit handle*/) - IPC_MESSAGE_ROUTED2(AutomationMsg_AutocompleteEditGetMatchesResponse, - bool /* the requested autocomplete edit exists */, - std::vector<AutocompleteMatchData> /* matches */) + // The first return value indicates if the request was successful, while + // while the second is the actual list of matches. + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_AutocompleteEditGetMatches, + int /* autocomplete edit handle*/, + bool /* the requested autocomplete edit exists */, + std::vector<AutocompleteMatchData> /* matches */) // This message requests the execution of a browser command in the browser // for which the handle is specified. - // The response contains a boolean, whether the command execution was + // The return value contains a boolean, whether the command execution was // successful. - IPC_MESSAGE_ROUTED2(AutomationMsg_WindowExecuteCommandRequest, - int /* automation handle */, - int /* browser command */) - IPC_MESSAGE_ROUTED1(AutomationMsg_WindowExecuteCommandResponse, - bool /* success flag */) + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_WindowExecuteCommand, + int /* automation handle */, + int /* browser command */, + bool /* success flag */) // This message opens the Find window within a tab corresponding to the // supplied tab handle. - IPC_MESSAGE_ROUTED1(AutomationMsg_OpenFindInPageRequest, + IPC_MESSAGE_ROUTED1(AutomationMsg_OpenFindInPage, int /* tab_handle */) // Posts a message from external host to chrome renderer. @@ -783,130 +739,111 @@ IPC_BEGIN_MESSAGES(Automation) // If an error occurs, |matches_found| will be -1 (see response message // AutomationMsg_FindInPageResponse2). // - IPC_MESSAGE_ROUTED2(AutomationMsg_FindRequest, - int, /* tab_handle */ - FindInPageRequest /* request */) + IPC_SYNC_MESSAGE_ROUTED2_2(AutomationMsg_Find, + int, /* tab_handle */ + FindInPageRequest /* request */, + int /* active_ordinal */, + int /* matches_found */) // Is the Find window fully visible (and not animating) for the specified // tab? - IPC_MESSAGE_ROUTED1(AutomationMsg_FindWindowVisibilityRequest, - int /* tab_handle */) - IPC_MESSAGE_ROUTED1(AutomationMsg_FindWindowVisibilityResponse, - bool /* is_visible */) + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_FindWindowVisibility, + int /* tab_handle */, + bool /* is_visible */) // Where is the Find window located. |x| and |y| will be -1, -1 on failure. - IPC_MESSAGE_ROUTED1(AutomationMsg_FindWindowLocationRequest, - int /* tab_handle */) - IPC_MESSAGE_ROUTED2(AutomationMsg_FindWindowLocationResponse, - int, /* x */ - int /* y */) + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_FindWindowLocation, + int /* tab_handle */, + int /* x */, + int /* y */) - // Is the Bookmark bar visible? The response will indicate whether it is + // Is the Bookmark bar visible? The return value will indicate whether it is // visible or not and whether it is being animated into (or out of its place). - IPC_MESSAGE_ROUTED1(AutomationMsg_BookmarkBarVisibilityRequest, - int /* browser_handle */) - IPC_MESSAGE_ROUTED2(AutomationMsg_BookmarkBarVisibilityResponse, - bool, /* is_visible */ - bool /* still_animating */) + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_BookmarkBarVisibility, + int /* browser_handle */, + bool, /* is_visible */ + bool /* still_animating */) // This message requests the number of SSL related info bars opened. It // returns -1 if an error occurred. - IPC_MESSAGE_ROUTED1(AutomationMsg_GetSSLInfoBarCountRequest, - int /* tab_handle */) - IPC_MESSAGE_ROUTED1(AutomationMsg_GetSSLInfoBarCountResponse, - int /* info bar count */) + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_GetSSLInfoBarCount, + int /* tab_handle */, + int /* info bar count */) // This message triggers the action associated with the link in the info-bar // at the specified index. If |wait for navigation| is true, it won't return // until a navigation has occurred. - IPC_MESSAGE_ROUTED3(AutomationMsg_ClickSSLInfoBarLinkRequest, - int /* tab_handle */, - int /* info bar index */, - bool /* wait for navigation */) - IPC_MESSAGE_ROUTED1(AutomationMsg_ClickSSLInfoBarLinkResponse, - bool /* success flag */) + IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_ClickSSLInfoBarLink, + int /* tab_handle */, + int /* info bar index */, + bool /* wait for navigation */, + bool /* success flag */) // This message retrieves the last time a navigation occurred in the specified // tab. The value is intended to be used with WaitForNavigation. - IPC_MESSAGE_ROUTED1(AutomationMsg_GetLastNavigationTimeRequest, - int /* tab_handle */) - IPC_MESSAGE_ROUTED1(AutomationMsg_GetLastNavigationTimeResponse, - int64 /* last navigation time */) + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_GetLastNavigationTime, + int /* tab_handle */, + int64 /* last navigation time */) // This messages is used to block until a new navigation occurs (if there is // none more recent then the time specified). - IPC_MESSAGE_ROUTED2(AutomationMsg_WaitForNavigationRequest, - int /* tab_handle */, - int64 /* last navigation time */) - IPC_MESSAGE_ROUTED1(AutomationMsg_WaitForNavigationResponse, - bool /* success */) + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_WaitForNavigation, + int /* tab_handle */, + int64 /* last navigation time */, + bool /* success */) // This messages sets an int-value preference. - IPC_MESSAGE_ROUTED3(AutomationMsg_SetIntPreferenceRequest, - int /* browser handle */, - std::wstring /* pref name */, - int /* value */) - IPC_MESSAGE_ROUTED1(AutomationMsg_SetIntPreferenceResponse, - bool /* success */) + IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_SetIntPreference, + int /* browser handle */, + std::wstring /* pref name */, + int /* value */, + bool /* success */) // Queries whether an app modal dialog is currently being shown. (i.e. a // javascript alert) and which buttons it contains. - IPC_MESSAGE_ROUTED0(AutomationMsg_ShowingAppModalDialogRequest) - IPC_MESSAGE_ROUTED2(AutomationMsg_ShowingAppModalDialogResponse, - bool /* showing dialog */, - int /* view::DelegateDialog::DialogButton */) - - // Returns the ordinal and the number of matches found as a response to - // a AutomationMsg_FindRequest. - IPC_MESSAGE_ROUTED2(AutomationMsg_FindInPageResponse2, - int /* active_ordinal */, - int /* matches_found */) + IPC_SYNC_MESSAGE_ROUTED0_2(AutomationMsg_ShowingAppModalDialog, + bool /* showing dialog */, + int /* view::DelegateDialog::DialogButton */) // This message triggers the specified button for the currently showing // modal dialog. - IPC_MESSAGE_ROUTED1(AutomationMsg_ClickAppModalDialogButtonRequest, - int /* view::DelegateDialog::DialogButton */) - IPC_MESSAGE_ROUTED1(AutomationMsg_ClickAppModalDialogButtonResponse, - bool /* success */) + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_ClickAppModalDialogButton, + int /* view::DelegateDialog::DialogButton */, + bool /* success */) // This messages sets a string-value preference. - IPC_MESSAGE_ROUTED3(AutomationMsg_SetStringPreferenceRequest, - int /* browser handle */, - std::wstring /* pref name */, - std::wstring /* pref value */) - IPC_MESSAGE_ROUTED1(AutomationMsg_SetStringPreferenceResponse, - bool /* success */) + IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_SetStringPreference, + int /* browser handle */, + std::wstring /* pref name */, + std::wstring /* pref value */, + bool) // This messages gets a boolean-value preference. - IPC_MESSAGE_ROUTED2(AutomationMsg_GetBooleanPreferenceRequest, - int /* browser handle */, - std::wstring /* pref name */) - IPC_MESSAGE_ROUTED2(AutomationMsg_GetBooleanPreferenceResponse, - bool /* success */, - bool /* pref value */) + IPC_SYNC_MESSAGE_ROUTED2_2(AutomationMsg_GetBooleanPreference, + int /* browser handle */, + std::wstring /* pref name */, + bool /* success */, + bool /* pref value */) // This messages sets a boolean-value preference. - IPC_MESSAGE_ROUTED3(AutomationMsg_SetBooleanPreferenceRequest, - int /* browser handle */, - std::wstring /* pref name */, - bool /* pref value */) - IPC_MESSAGE_ROUTED1(AutomationMsg_SetBooleanPreferenceResponse, - bool /* success */) + IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_SetBooleanPreference, + int /* browser handle */, + std::wstring /* pref name */, + bool /* pref value */, + bool /* success */) // Queries the current used encoding name of the page in the specified // web content tab. - IPC_MESSAGE_ROUTED1(AutomationMsg_GetPageCurrentEncodingRequest, - int /* tab handle */) - IPC_MESSAGE_ROUTED1(AutomationMsg_GetPageCurrentEncodingResponse, - std::wstring /* current used encoding name */) + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_GetPageCurrentEncoding, + int /* tab handle */, + std::wstring /* current used encoding name */) // Uses the specified encoding to override the encoding of the page in the // specified web content tab. - IPC_MESSAGE_ROUTED2(AutomationMsg_OverrideEncodingRequest, - int /* tab handle */, - std::wstring /* overrided encoding name */) - IPC_MESSAGE_ROUTED1(AutomationMsg_OverrideEncodingResponse, - bool /* success */) + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_OverrideEncoding, + int /* tab handle */, + std::wstring /* overrided encoding name */, + bool /* success */) // Used to disable the dialog box that prompts the user for a path when // saving a web page. diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index 0ad753e..8d0f87d 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -150,6 +150,8 @@ AutomationProxy::AutomationProxy(int command_execution_timeout_ms) } AutomationProxy::~AutomationProxy() { + DCHECK(shutdown_event_.get() != NULL); + ::SetEvent(shutdown_event_->handle()); // Destruction order is important. Thread has to outlive the channel and // tracker has to outlive the thread since we access the tracker inside // AutomationMessageFilter::OnMessageReceived. @@ -177,6 +179,8 @@ void AutomationProxy::InitializeEvents() { // See the above call to CreateEvent to understand these parameters. new_tab_ui_load_complete_ = CreateEvent(NULL, TRUE, FALSE, NULL); DCHECK(new_tab_ui_load_complete_); + + shutdown_event_.reset(new base::WaitableEvent(true, false)); } void AutomationProxy::InitializeChannelID() { @@ -204,12 +208,20 @@ void AutomationProxy::InitializeThread() { } void AutomationProxy::InitializeChannel() { - channel_.reset(new IPC::ChannelProxy( + DCHECK(shutdown_event_.get() != NULL); + + // TODO(iyengar) + // The shutdown event could be global on the same lines as the automation + // provider, where we use the shutdown event provided by the chrome browser + // process. + channel_.reset(new IPC::SyncChannel( channel_id_, IPC::Channel::MODE_SERVER, this, // we are the listener new AutomationMessageFilter(this), - thread_->message_loop())); + thread_->message_loop(), + true, + shutdown_event_.get())); } void AutomationProxy::InitializeHandleTracker() { @@ -259,26 +271,15 @@ bool AutomationProxy::GetBrowserWindowCount(int* num_windows) { return false; } - IPC::Message* response = NULL; - bool is_timeout = true; - bool succeeded = SendAndWaitForResponseWithTimeout( - new AutomationMsg_BrowserWindowCountRequest(0), &response, - AutomationMsg_BrowserWindowCountResponse::ID, - command_execution_timeout_ms_, &is_timeout); - if (!succeeded) - return false; + bool succeeded = SendWithTimeout( + new AutomationMsg_BrowserWindowCount(0, num_windows), + command_execution_timeout_ms_, NULL); - if (is_timeout) { + if (!succeeded) { DLOG(ERROR) << "GetWindowCount did not complete in a timely fashion"; return false; } - void* iter = NULL; - if (!response->ReadInt(&iter, num_windows)) { - succeeded = false; - } - - delete response; return succeeded; } @@ -323,46 +324,29 @@ bool AutomationProxy::GetShowingAppModalDialog( return false; } - IPC::Message* response = NULL; - bool is_timeout = true; - if (!SendAndWaitForResponseWithTimeout( - new AutomationMsg_ShowingAppModalDialogRequest(0), &response, - AutomationMsg_ShowingAppModalDialogResponse::ID, - command_execution_timeout_ms_, &is_timeout)) { - return false; - } + int button_int = 0; - scoped_ptr<IPC::Message> response_deleter(response); // Delete on exit. - if (is_timeout) { + if (!SendWithTimeout( + new AutomationMsg_ShowingAppModalDialog( + 0, showing_app_modal_dialog, &button_int), + command_execution_timeout_ms_, NULL)) { DLOG(ERROR) << "ShowingAppModalDialog did not complete in a timely fashion"; return false; } - void* iter = NULL; - int button_int = 0; - if (!response->ReadBool(&iter, showing_app_modal_dialog) || - !response->ReadInt(&iter, &button_int)) - return false; - *button = static_cast<views::DialogDelegate::DialogButton>(button_int); return true; } bool AutomationProxy::ClickAppModalDialogButton( views::DialogDelegate::DialogButton button) { - IPC::Message* response = NULL; - bool is_timeout = true; - if (!SendAndWaitForResponseWithTimeout( - new AutomationMsg_ClickAppModalDialogButtonRequest(0, button), - &response, AutomationMsg_ClickAppModalDialogButtonResponse::ID, - command_execution_timeout_ms_, &is_timeout)) { - return false; - } - bool succeeded = false; - void* iter = NULL; - if (!response->ReadBool(&iter, &succeeded)) + + if (!SendWithTimeout( + new AutomationMsg_ClickAppModalDialogButton( + 0, button, &succeeded), command_execution_timeout_ms_, NULL)) { return false; + } return succeeded; } @@ -406,124 +390,65 @@ void AutomationProxy::OnChannelError() { } WindowProxy* AutomationProxy::GetActiveWindow() { - IPC::Message* response = NULL; - bool is_timeout = true; - bool succeeded = SendAndWaitForResponseWithTimeout( - new AutomationMsg_ActiveWindowRequest(0), &response, - AutomationMsg_ActiveWindowResponse::ID, - command_execution_timeout_ms_, &is_timeout); - if (!succeeded) - return NULL; + int handle = 0; - scoped_ptr<IPC::Message> response_deleter(response); // Delete on exit. - if (is_timeout) { - DLOG(ERROR) << "GetActiveWindow did not complete in a timely fashion"; + if (!SendWithTimeout(new AutomationMsg_ActiveWindow(0, &handle), + command_execution_timeout_ms_, NULL)) { return NULL; } - void* iter = NULL; - int handle; - if (response->ReadInt(&iter, &handle) && (handle != 0)) - return new WindowProxy(this, tracker_.get(), handle); - - return NULL; + return new WindowProxy(this, tracker_.get(), handle); } BrowserProxy* AutomationProxy::GetBrowserWindow(int window_index) { - IPC::Message* response; - bool is_timeout = true; - bool succeeded = SendAndWaitForResponseWithTimeout( - new AutomationMsg_BrowserWindowRequest(0, window_index), &response, - AutomationMsg_BrowserWindowResponse::ID, - command_execution_timeout_ms_, &is_timeout); - if (!succeeded) - return NULL; + int handle = 0; - scoped_ptr<IPC::Message> response_deleter(response); // Delete on exit. - if (is_timeout) { + if (!SendWithTimeout(new AutomationMsg_BrowserWindow(0, window_index, + &handle), + command_execution_timeout_ms_, NULL)) { DLOG(ERROR) << "GetBrowserWindow did not complete in a timely fashion"; return NULL; } - void* iter = NULL; - int handle; - if (!response->ReadInt(&iter, &handle) || (handle == 0)) { - DLOG(ERROR) << "Bad response from the window getter."; + if (handle == 0) { return NULL; } + return new BrowserProxy(this, tracker_.get(), handle); } BrowserProxy* AutomationProxy::GetLastActiveBrowserWindow() { - IPC::Message* response; - bool is_timeout = true; - bool succeeded = SendAndWaitForResponseWithTimeout( - new AutomationMsg_LastActiveBrowserWindowRequest(0), - &response, AutomationMsg_LastActiveBrowserWindowResponse::ID, - command_execution_timeout_ms_, &is_timeout); - if (!succeeded) - return NULL; + int handle = 0; - scoped_ptr<IPC::Message> response_deleter(response); // Delete on exit. - if (is_timeout) { + if (!SendWithTimeout(new AutomationMsg_LastActiveBrowserWindow( + 0, &handle), command_execution_timeout_ms_, NULL)) { DLOG(ERROR) << "GetLastActiveBrowserWindow did not complete in a timely fashion"; return NULL; } - void* iter = NULL; - int handle; - if (!response->ReadInt(&iter, &handle) || (handle == 0)) { - DLOG(ERROR) << "Bad response from the window getter."; - return NULL; - } return new BrowserProxy(this, tracker_.get(), handle); } bool AutomationProxy::Send(IPC::Message* message) { - if (channel_.get()) - return channel_->Send(message); - - DLOG(WARNING) << "Channel has been closed; dropping message!"; - delete message; - return false; + return SendWithTimeout(message, INFINITE, NULL); } -bool AutomationProxy::SendAndWaitForResponse(IPC::Message* request, - IPC::Message** response, - int response_type) { - return SendAndWaitForResponseWithTimeout(request, response, response_type, - INFINITE, NULL); -} - -bool AutomationProxy::SendAndWaitForResponseWithTimeout( - IPC::Message* request, - IPC::Message** response, - int response_type, - uint32 timeout_ms, - bool* is_timeout) { - - DCHECK(request); - DCHECK(response); - DCHECK(!current_request_) << - "Only one synchronous request should exist at any given time."; - - scoped_refptr<AutomationRequest> req = new AutomationRequest; - current_request_ = req; - - // Rewrite the message's routing ID so that we'll recognize the response - // to it when it comes back. - request->set_routing_id(req->routing_id()); - bool result = Send(request) && req->WaitForResponse(timeout_ms, is_timeout); - if (!result || req->response().type() != response_type) { - // If Send() or WaitForResponse() failed, current_request_ may not have - // gotten cleared by the background thread, so we'll clear it here. - current_request_ = NULL; - return false; +bool AutomationProxy::SendWithTimeout(IPC::Message* message, int timeout, + bool* is_timeout) { + if (is_timeout) + *is_timeout = false; + + if (channel_.get()) { + bool result = channel_->SendWithTimeout(message, timeout); + if (!result && is_timeout) + *is_timeout = true; + return result; } - req->GrabResponse(response); - return true; + DLOG(WARNING) << "Channel has been closed; dropping message!"; + delete message; + return false; } void AutomationProxy::InvalidateHandle(const IPC::Message& message) { @@ -544,25 +469,17 @@ TabProxy* AutomationProxy::CreateExternalTab(HWND parent, unsigned int style, HWND* external_tab_container) { IPC::Message* response = NULL; - bool succeeded = SendAndWaitForResponse( - new AutomationMsg_CreateExternalTab(0, parent, dimensions, style), - &response, AutomationMsg_CreateExternalTabResponse::ID); + int handle = 0; + + bool succeeded = + Send(new AutomationMsg_CreateExternalTab(0, parent, dimensions, style, + external_tab_container, + &handle)); if (!succeeded) { return NULL; } - void* iter = NULL; - int handle = 0; - TabProxy* tab_proxy = NULL; - if (IPC::ReadParam(response, &iter, external_tab_container) && - IsWindow(*external_tab_container)) { - if (response->ReadInt(&iter, &handle) && - (handle >= 0)) { - succeeded = true; - tab_proxy = new TabProxy(this, tracker_.get(), handle); - } - } else { - succeeded = false; - } - delete response; - return tab_proxy; + + DCHECK(IsWindow(*external_tab_container)); + + return new TabProxy(this, tracker_.get(), handle); } diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index 22fdebc..2988b6f 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -12,6 +12,7 @@ #include "base/thread.h" #include "chrome/common/ipc_channel_proxy.h" #include "chrome/common/ipc_message.h" +#include "chrome/common/ipc_sync_channel.h" #include "chrome/test/automation/automation_handle_tracker.h" #include "chrome/test/automation/automation_messages.h" #include "chrome/views/dialog_delegate.h" @@ -25,33 +26,17 @@ class WindowProxy; // access the message-sending abilities of the Proxy. class AutomationMessageSender : public IPC::Message::Sender { public: - // Sends a message synchronously (from the perspective of the caller's - // thread, at least); it doesn't return until a response has been received. - // This method takes ownership of the request object passed in. The caller - // is responsible for deleting the response object when they're done with it. - // response_type should be set to the message type of the expected response. - // A response object will only be available if the method returns true. - // NOTE: This method will overwrite any routing_id on the request message, - // since it uses this field to match the response up with the request. - virtual bool SendAndWaitForResponse(IPC::Message* request, - IPC::Message** response, - int response_type) = 0; - // Sends a message synchronously; it doesn't return until a response has been // received or a timeout has expired. // The function returns true if a response is received, and returns false if // there is a failure or timeout (in milliseconds). If return after timeout, // is_timeout is set to true. - // See the comments in SendAndWaitForResponse for other details on usage. // NOTE: When timeout occurs, the connection between proxy provider may be // in transit state. Specifically, there might be pending IPC messages, // and the proxy provider might be still working on the previous // request. - virtual bool SendAndWaitForResponseWithTimeout(IPC::Message* request, - IPC::Message** response, - int response_type, - uint32 timeout_ms, - bool* is_timeout) = 0; + virtual bool SendWithTimeout(IPC::Message* message, int timeout, + bool* is_timeout) = 0; }; // This is the interface that external processes can use to interact with @@ -163,14 +148,8 @@ class AutomationProxy : public IPC::Channel::Listener, // AutomationMessageSender implementations. virtual bool Send(IPC::Message* message); - virtual bool SendAndWaitForResponse(IPC::Message* request, - IPC::Message** response, - int response_type); - virtual bool SendAndWaitForResponseWithTimeout(IPC::Message* request, - IPC::Message** response, - int response_type, - uint32 timeout_ms, - bool* is_timeout); + virtual bool SendWithTimeout(IPC::Message* message, int timeout, + bool* is_timeout); // Returns the current AutomationRequest object. AutomationRequest* current_request() { return current_request_; } @@ -201,7 +180,7 @@ class AutomationProxy : public IPC::Channel::Listener, std::wstring channel_id_; scoped_ptr<base::Thread> thread_; - scoped_ptr<IPC::ChannelProxy> channel_; + scoped_ptr<IPC::SyncChannel> channel_; scoped_ptr<AutomationHandleTracker> tracker_; HANDLE app_launched_; @@ -209,6 +188,9 @@ class AutomationProxy : public IPC::Channel::Listener, HANDLE new_tab_ui_load_complete_; int new_tab_ui_load_time_; + // An event that notifies when we are shutting-down. + scoped_ptr<base::WaitableEvent> shutdown_event_; + AutomationRequest* current_request_; // Delay to let the browser execute the command. diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc index a08fdc6..87f2746 100644 --- a/chrome/test/automation/browser_proxy.cc +++ b/chrome/test/automation/browser_proxy.cc @@ -27,25 +27,15 @@ bool BrowserProxy::ActivateTabWithTimeout(int tab_index, uint32 timeout_ms, if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_ActivateTabRequest(0, handle_, tab_index), &response, - AutomationMsg_ActivateTabResponse::ID, timeout_ms, is_timeout); + int activate_tab_response = -1; - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!succeeded) - return false; + sender_->SendWithTimeout(new AutomationMsg_ActivateTab( + 0, handle_, tab_index, &activate_tab_response), timeout_ms, is_timeout); - void* iter = NULL; - int activate_tab_response = -1; - if (response->ReadInt(&iter, &activate_tab_response) && - (activate_tab_response >= 0)) { - succeeded = true; - } else { - succeeded = false; - } + if (activate_tab_response >= 0) + return true; - return succeeded; + return false; } bool BrowserProxy::BringToFront() { @@ -57,18 +47,10 @@ bool BrowserProxy::BringToFrontWithTimeout(uint32 timeout_ms, if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_BringBrowserToFront(0, handle_), &response, - AutomationMsg_BringBrowserToFrontResponse::ID, timeout_ms, is_timeout); - - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!succeeded) - return false; + bool succeeded = false; - void* iter = NULL; - if (!response->ReadBool(&iter, &succeeded)) - succeeded = false; + sender_->SendWithTimeout(new AutomationMsg_BringBrowserToFront( + 0, handle_, &succeeded), timeout_ms, is_timeout); return succeeded; } @@ -79,18 +61,10 @@ bool BrowserProxy::IsPageMenuCommandEnabledWithTimeout(int id, if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_IsPageMenuCommandEnabled(0, handle_, id), &response, - AutomationMsg_IsPageMenuCommandEnabledResponse::ID, timeout_ms, is_timeout); + bool succeeded = false; - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!succeeded) - return false; - - void* iter = NULL; - if (!response->ReadBool(&iter, &succeeded)) - succeeded = false; + sender_->SendWithTimeout(new AutomationMsg_IsPageMenuCommandEnabled( + 0, handle_, id, &succeeded), timeout_ms, is_timeout); return succeeded; } @@ -99,26 +73,11 @@ bool BrowserProxy::AppendTab(const GURL& tab_url) { if (!is_valid()) return false; - IPC::Message* response = NULL; - - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_AppendTabRequest(0, handle_, tab_url), &response, - AutomationMsg_AppendTabResponse::ID); - - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!succeeded) - return false; - - void* iter = NULL; int append_tab_response = -1; - if (response->ReadInt(&iter, &append_tab_response) && - (append_tab_response >= 0)) { - succeeded = true; - } else { - succeeded = false; - } - return succeeded; + sender_->Send(new AutomationMsg_AppendTab(0, handle_, tab_url, + &append_tab_response)); + return append_tab_response >= 0; } bool BrowserProxy::GetActiveTabIndex(int* active_tab_index) const { @@ -136,19 +95,13 @@ bool BrowserProxy::GetActiveTabIndexWithTimeout(int* active_tab_index, return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_ActiveTabIndexRequest(0, handle_), &response, - AutomationMsg_ActiveTabIndexResponse::ID, timeout_ms, is_timeout); + int active_tab_index_response = -1; - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!succeeded) - return false; + bool succeeded = sender_->SendWithTimeout( + new AutomationMsg_ActiveTabIndex(0, handle_, &active_tab_index_response), + timeout_ms, is_timeout); - void* iter = NULL; - int active_tab_index_response = -1; - if (response->ReadInt(&iter, &active_tab_index_response) && - (active_tab_index_response >= 0)) { + if (active_tab_index_response >= 0) { *active_tab_index = active_tab_index_response; } else { succeeded = false; @@ -161,19 +114,12 @@ TabProxy* BrowserProxy::GetTab(int tab_index) const { if (!is_valid()) return NULL; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_TabRequest(0, handle_, tab_index), &response, - AutomationMsg_TabResponse::ID); - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!succeeded) - return NULL; - - void* iter = NULL; - int handle; + int handle = 0; - if (!response->ReadInt(&iter, &handle) || (handle == 0)) + sender_->Send(new AutomationMsg_Tab(0, handle_, tab_index, &handle)); + if (!handle) return NULL; + return new TabProxy(sender_, tracker_, handle); } @@ -203,19 +149,12 @@ bool BrowserProxy::GetTabCountWithTimeout(int* num_tabs, uint32 timeout_ms, return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_TabCountRequest(0, handle_), &response, - AutomationMsg_TabCountResponse::ID, timeout_ms, is_timeout); + int tab_count_response = -1; - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!succeeded) - return false; + bool succeeded = sender_->SendWithTimeout(new AutomationMsg_TabCount( + 0, handle_, &tab_count_response), timeout_ms, is_timeout); - void* iter = NULL; - int tab_count_response = -1; - if (response->ReadInt(&iter, &tab_count_response) && - (tab_count_response >= 0)) { + if (tab_count_response >= 0) { *num_tabs = tab_count_response; } else { succeeded = false; @@ -229,7 +168,7 @@ bool BrowserProxy::ApplyAccelerator(int id) { return false; return sender_->Send( - new AutomationMsg_ApplyAcceleratorRequest(0, handle_, id)); + new AutomationMsg_ApplyAccelerator(0, handle_, id)); } bool BrowserProxy::SimulateDrag(const POINT& start, @@ -253,21 +192,13 @@ bool BrowserProxy::SimulateDragWithTimeout(const POINT& start, drag_path.push_back(start); drag_path.push_back(end); - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_WindowDragRequest(0, handle_, drag_path, flags, - press_escape_en_route), - &response, AutomationMsg_WindowDragResponse::ID, timeout_ms, is_timeout); + bool result = false; - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!succeeded) - return false; + sender_->SendWithTimeout(new AutomationMsg_WindowDrag( + 0, handle_, drag_path, flags, press_escape_en_route, &result), + timeout_ms, is_timeout); - void* iter = NULL; - if (!response->ReadBool(&iter, &succeeded)) - succeeded = false; - - return succeeded; + return result; } bool BrowserProxy::WaitForTabCountToChange(int count, int* new_count, @@ -329,45 +260,20 @@ bool BrowserProxy::GetHWND(HWND* handle) const { return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_WindowHWNDRequest(0, handle_), &response, - AutomationMsg_WindowHWNDResponse::ID); - - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!succeeded) - return false; - - HWND hwnd_response; - if (AutomationMsg_WindowHWNDResponse::Read(response, &hwnd_response) && - hwnd_response) { - *handle = hwnd_response; - } else { - succeeded = false; - } - - return succeeded; + return sender_->Send(new AutomationMsg_WindowHWND(0, handle_, handle)); } bool BrowserProxy::RunCommand(int browser_command) const { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_WindowExecuteCommandRequest(0, handle_, browser_command), - &response, AutomationMsg_WindowExecuteCommandResponse::ID); - - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!succeeded) - return false; + bool result = false; - bool success = false; - if (AutomationMsg_WindowExecuteCommandResponse::Read(response, &success)) - return success; + sender_->Send(new AutomationMsg_WindowExecuteCommand(0, handle_, + browser_command, + &result)); - // We failed to deserialize the returned value. - return false; + return result; } bool BrowserProxy::GetBookmarkBarVisibility(bool* is_visible, @@ -380,40 +286,19 @@ bool BrowserProxy::GetBookmarkBarVisibility(bool* is_visible, return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_BookmarkBarVisibilityRequest(0, handle_), - &response, - AutomationMsg_BookmarkBarVisibilityResponse::ID); - - if (!succeeded) - return false; - - void* iter = NULL; - response->ReadBool(&iter, is_visible); - response->ReadBool(&iter, is_animating); - delete response; - return true; + return sender_->Send(new AutomationMsg_BookmarkBarVisibility( + 0, handle_, is_visible, is_animating)); } bool BrowserProxy::SetIntPreference(const std::wstring& name, int value) { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool success = sender_->SendAndWaitForResponse( - new AutomationMsg_SetIntPreferenceRequest(0, handle_, name , value), - &response, AutomationMsg_SetIntPreferenceResponse::ID); + bool result = false; - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!success) - return false; - - if (AutomationMsg_SetIntPreferenceResponse::Read(response, &success)) - return success; - - // We failed to deserialize the returned value. - return false; + sender_->Send(new AutomationMsg_SetIntPreference(0, handle_, name, value, + &result)); + return result; } bool BrowserProxy::SetStringPreference(const std::wstring& name, @@ -421,19 +306,11 @@ bool BrowserProxy::SetStringPreference(const std::wstring& name, if (!is_valid()) return false; - IPC::Message* response = NULL; - bool success = sender_->SendAndWaitForResponse( - new AutomationMsg_SetStringPreferenceRequest(0, handle_, name , value), - &response, AutomationMsg_SetStringPreferenceResponse::ID); - - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!success) - return false; - - if (AutomationMsg_SetStringPreferenceResponse::Read(response, &success)) - return success; + bool result = false; - return false; + sender_->Send(new AutomationMsg_SetStringPreference(0, handle_, name, value, + &result)); + return result; } bool BrowserProxy::GetBooleanPreference(const std::wstring& name, @@ -441,23 +318,11 @@ bool BrowserProxy::GetBooleanPreference(const std::wstring& name, if (!is_valid()) return false; - IPC::Message* response = NULL; - bool success = sender_->SendAndWaitForResponse( - new AutomationMsg_GetBooleanPreferenceRequest(0, handle_, name), - &response, AutomationMsg_GetBooleanPreferenceResponse::ID); - - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!success) - return false; - - void* iter = NULL; - bool successed_get_value; - success = response->ReadBool(&iter, &successed_get_value); - if (!success || !successed_get_value) - return false; - DCHECK(iter); - success = response->ReadBool(&iter, value); - return success; + bool result = false; + + sender_->Send(new AutomationMsg_GetBooleanPreference(0, handle_, name, value, + &result)); + return result; } bool BrowserProxy::SetBooleanPreference(const std::wstring& name, @@ -465,63 +330,39 @@ bool BrowserProxy::SetBooleanPreference(const std::wstring& name, if (!is_valid()) return false; - IPC::Message* response = NULL; - bool success = sender_->SendAndWaitForResponse( - new AutomationMsg_SetBooleanPreferenceRequest(0, handle_, name , value), - &response, AutomationMsg_SetBooleanPreferenceResponse::ID); - - scoped_ptr<IPC::Message> response_deleter(response); // Delete on return. - if (!success) - return false; - - if (AutomationMsg_SetBooleanPreferenceResponse::Read(response, &success)) - return success; + bool result = false; - return false; + sender_->Send(new AutomationMsg_SetBooleanPreference(0, handle_, name, + value, &result)); + return result; } WindowProxy* BrowserProxy::GetWindow() { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_WindowForBrowserRequest(0, handle_), &response, - AutomationMsg_WindowForBrowserResponse::ID); - if (!succeeded) - return NULL; + bool handle_ok = false; + int window_handle = 0; - scoped_ptr<IPC::Message> response_deleter(response); // Delete on exit. - int window_handle; - void* iter = NULL; - bool handle_ok; - succeeded = response->ReadBool(&iter, &handle_ok); - if (succeeded) - succeeded = response->ReadInt(&iter, &window_handle); - - if (succeeded) { - return new WindowProxy(sender_, tracker_, window_handle); - } else { + sender_->Send(new AutomationMsg_WindowForBrowser(0, handle_, &handle_ok, + &window_handle)); + if (!handle_ok) return NULL; - } + + return new WindowProxy(sender_, tracker_, window_handle); } AutocompleteEditProxy* BrowserProxy::GetAutocompleteEdit() { if (!is_valid()) return NULL; - IPC::Message* response = NULL; - if (!sender_->SendAndWaitForResponse( - new AutomationMsg_AutocompleteEditForBrowserRequest(0, handle_), - &response, AutomationMsg_AutocompleteEditForBrowserResponse::ID)) - return NULL; - scoped_ptr<IPC::Message> response_deleter(response); + bool handle_ok = false; + int autocomplete_edit_handle = 0; + + sender_->Send(new AutomationMsg_AutocompleteEditForBrowser( + 0, handle_, &handle_ok, &autocomplete_edit_handle)); - int autocomplete_edit_handle; - void* iter = NULL; - bool handle_ok; - if (!response->ReadBool(&iter, &handle_ok) || - !response->ReadInt(&iter, &autocomplete_edit_handle)) + if (!handle_ok) return NULL; return new AutocompleteEditProxy(sender_, tracker_, autocomplete_edit_handle); diff --git a/chrome/test/automation/constrained_window_proxy.cc b/chrome/test/automation/constrained_window_proxy.cc index 0d75486..fd78c5b 100644 --- a/chrome/test/automation/constrained_window_proxy.cc +++ b/chrome/test/automation/constrained_window_proxy.cc @@ -16,25 +16,12 @@ bool ConstrainedWindowProxy::GetTitle(std::wstring* title) const { return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_ConstrainedTitleRequest(0, handle_), &response, - AutomationMsg_ConstrainedTitleResponse::ID); - - if (!succeeded) - return false; - - void* iter = NULL; int title_size_response = -1; - if (response->ReadInt(&iter, &title_size_response) && - (title_size_response >= 0)) { - response->ReadWString(&iter, title); - } else { - succeeded = false; - } - delete response; - return succeeded; + sender_->Send(new AutomationMsg_ConstrainedTitle(0, handle_, + &title_size_response, + title)); + return title_size_response >= 0; } bool ConstrainedWindowProxy::GetBoundsWithTimeout(gfx::Rect* bounds, @@ -48,21 +35,10 @@ bool ConstrainedWindowProxy::GetBoundsWithTimeout(gfx::Rect* bounds, return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_ConstrainedWindowBoundsRequest(0, handle_), - &response, - AutomationMsg_ConstrainedWindowBoundsResponse::ID, - timeout_ms, - is_timeout); - scoped_ptr<IPC::Message> responseDeleter(response); - if (!succeeded) - return false; + bool result = false; - Tuple2<bool, gfx::Rect> result; - AutomationMsg_WindowViewBoundsResponse::Read(response, &result); + sender_->SendWithTimeout(new AutomationMsg_ConstrainedWindowBounds( + 0, handle_, &result, bounds), timeout_ms, NULL); - *bounds = result.b; - return result.a; + return result; } - diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index e0e6102..f0f9a72 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -23,16 +23,10 @@ bool TabProxy::GetTabTitle(std::wstring* title) const { return false; } - IPC::Message* response = NULL; - int tab_title_size_response; - - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_TabTitleRequest(0, handle_), &response, - AutomationMsg_TabTitleResponse::ID) && - AutomationMsg_TabTitleResponse::Read(response, &tab_title_size_response, title) && - tab_title_size_response >= 0; - scoped_ptr<IPC::Message> auto_deleter(response); + int tab_title_size_response = 0; + bool succeeded = sender_->Send( + new AutomationMsg_TabTitle(0, handle_, &tab_title_size_response, title)); return succeeded; } @@ -45,20 +39,15 @@ bool TabProxy::IsShelfVisible(bool* is_visible) { return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_ShelfVisibilityRequest(0, handle_), - &response, AutomationMsg_ShelfVisibilityResponse::ID) && - AutomationMsg_ShelfVisibilityResponse::Read(response, is_visible); - scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + return sender_->Send(new AutomationMsg_ShelfVisibility(0, handle_, + is_visible)); } bool TabProxy::OpenFindInPage() { if (!is_valid()) return false; - return sender_->Send(new AutomationMsg_OpenFindInPageRequest(0, handle_)); + return sender_->Send(new AutomationMsg_OpenFindInPage(0, handle_)); // This message expects no response. } @@ -71,26 +60,16 @@ bool TabProxy::IsFindWindowFullyVisible(bool* is_visible) { return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_FindWindowVisibilityRequest(0, handle_), - &response, AutomationMsg_FindWindowVisibilityResponse::ID) && - AutomationMsg_FindWindowVisibilityResponse::Read(response, is_visible); - scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + return sender_->Send(new AutomationMsg_FindWindowVisibility( + 0, handle_, is_visible)); } bool TabProxy::GetFindWindowLocation(int* x, int* y) { if (!is_valid() || !x || !y) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_FindWindowLocationRequest(0, handle_), - &response, AutomationMsg_FindWindowLocationResponse::ID) && - AutomationMsg_FindWindowLocationResponse::Read(response, x, y); - scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + return sender_->Send(new AutomationMsg_FindWindowLocation( + 0, handle_, x, y)); } int TabProxy::FindInPage(const std::wstring& search_string, @@ -108,14 +87,12 @@ int TabProxy::FindInPage(const std::wstring& search_string, request.match_case = match_case == TRUE; request.forward = forward == TRUE; - IPC::Message* response = NULL; - int matches; - int ordinal2; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_FindRequest(0, handle_, request), - &response, AutomationMsg_FindInPageResponse2::ID) && - AutomationMsg_FindInPageResponse2::Read(response, &ordinal2, &matches); - scoped_ptr<IPC::Message> auto_deleter(response); + int matches = 0; + int ordinal2 = 0; + bool succeeded = sender_->Send(new AutomationMsg_Find(0, handle_, + request, + &ordinal2, + &matches)); if (!succeeded) return -1; if (ordinal) @@ -132,15 +109,12 @@ AutomationMsg_NavigationResponseValues TabProxy::NavigateToURLWithTimeout( if (!is_valid()) return AUTOMATION_MSG_NAVIGATION_ERROR; - IPC::Message* response = NULL; AutomationMsg_NavigationResponseValues navigate_response = AUTOMATION_MSG_NAVIGATION_ERROR; - if (sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_NavigateToURLRequest(0, handle_, url), &response, - AutomationMsg_NavigateToURLResponse::ID, timeout_ms, is_timeout)) { - AutomationMsg_NavigateToURLResponse::Read(response, &navigate_response); - } - scoped_ptr<IPC::Message> auto_deleter(response); + + sender_->SendWithTimeout(new AutomationMsg_NavigateToURL( + 0, handle_, url, &navigate_response), timeout_ms, is_timeout); + return navigate_response; } @@ -149,16 +123,8 @@ AutomationMsg_NavigationResponseValues TabProxy::NavigateInExternalTab( if (!is_valid()) return AUTOMATION_MSG_NAVIGATION_ERROR; - IPC::Message* response = NULL; - bool is_timeout = false; AutomationMsg_NavigationResponseValues rv = AUTOMATION_MSG_NAVIGATION_ERROR; - if (sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_NavigateInExternalTabRequest(0, handle_, url), - &response, AutomationMsg_NavigateInExternalTabResponse::ID, INFINITE, - &is_timeout)) { - AutomationMsg_NavigateInExternalTabResponse::Read(response, &rv); - } - scoped_ptr<IPC::Message> auto_deleter(response); + sender_->Send(new AutomationMsg_NavigateInExternalTab(0, handle_, url, &rv)); return rv; } @@ -167,15 +133,10 @@ bool TabProxy::SetAuth(const std::wstring& username, if (!is_valid()) return false; - IPC::Message* response = NULL; int navigate_response = -1; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_SetAuthRequest(0, handle_, username, password), - &response, AutomationMsg_SetAuthResponse::ID) && - AutomationMsg_SetAuthResponse::Read(response, &navigate_response) && - navigate_response >= 0; - scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + sender_->Send(new AutomationMsg_SetAuth(0, handle_, username, password, + &navigate_response)); + return navigate_response >= 0; } bool TabProxy::CancelAuth() { @@ -184,13 +145,8 @@ bool TabProxy::CancelAuth() { IPC::Message* response = NULL; int navigate_response = -1; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_CancelAuthRequest(0, handle_), &response, - AutomationMsg_CancelAuthResponse::ID) && - AutomationMsg_CancelAuthResponse::Read(response, &navigate_response) && - navigate_response >= 0; - scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + sender_->Send(new AutomationMsg_CancelAuth(0, handle_, &navigate_response)); + return navigate_response >= 0; } bool TabProxy::NeedsAuth() const { @@ -199,11 +155,7 @@ bool TabProxy::NeedsAuth() const { IPC::Message* response = NULL; bool needs_auth = false; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_NeedsAuthRequest(0, handle_), &response, - AutomationMsg_NeedsAuthResponse::ID) && - AutomationMsg_NeedsAuthResponse::Read(response, &needs_auth); - scoped_ptr<IPC::Message> auto_deleter(response); + sender_->Send(new AutomationMsg_NeedsAuth(0, handle_, &needs_auth)); return needs_auth; } @@ -211,15 +163,9 @@ AutomationMsg_NavigationResponseValues TabProxy::GoBack() { if (!is_valid()) return AUTOMATION_MSG_NAVIGATION_ERROR; - IPC::Message* response = NULL; AutomationMsg_NavigationResponseValues navigate_response = AUTOMATION_MSG_NAVIGATION_ERROR; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_GoBackRequest(0, handle_), &response, - AutomationMsg_GoBackResponse::ID)) { - AutomationMsg_GoBackResponse::Read(response, &navigate_response); - } - scoped_ptr<IPC::Message> auto_deleter(response); + sender_->Send(new AutomationMsg_GoBack(0, handle_, &navigate_response)); return navigate_response; } @@ -227,15 +173,9 @@ AutomationMsg_NavigationResponseValues TabProxy::GoForward() { if (!is_valid()) return AUTOMATION_MSG_NAVIGATION_ERROR; - IPC::Message* response = NULL; AutomationMsg_NavigationResponseValues navigate_response = AUTOMATION_MSG_NAVIGATION_ERROR; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_GoForwardRequest(0, handle_), &response, - AutomationMsg_GoForwardResponse::ID)) { - AutomationMsg_GoForwardResponse::Read(response, &navigate_response); - } - scoped_ptr<IPC::Message> auto_deleter(response); + sender_->Send(new AutomationMsg_GoForward(0, handle_, &navigate_response)); return navigate_response; } @@ -243,31 +183,19 @@ AutomationMsg_NavigationResponseValues TabProxy::Reload() { if (!is_valid()) return AUTOMATION_MSG_NAVIGATION_ERROR; - IPC::Message* response = NULL; AutomationMsg_NavigationResponseValues navigate_response = AUTOMATION_MSG_NAVIGATION_ERROR; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_ReloadRequest(0, handle_), &response, - AutomationMsg_ReloadResponse::ID)) { - AutomationMsg_ReloadResponse::Read(response, &navigate_response); - } - scoped_ptr<IPC::Message> auto_deleter(response); + sender_->Send(new AutomationMsg_Reload(0, handle_, &navigate_response)); return navigate_response; } bool TabProxy::GetRedirectsFrom(const GURL& source_url, std::vector<GURL>* redirects) { - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_RedirectsFromRequest(0, handle_, source_url), &response, - AutomationMsg_RedirectsFromResponse::ID); - scoped_ptr<IPC::Message> auto_deleter(response); - if (succeeded) { - succeeded = AutomationMsg_RedirectsFromResponse::Read( - response, &succeeded, redirects) && - succeeded; - } - + bool succeeded = false; + sender_->Send(new AutomationMsg_RedirectsFrom(0, handle_, + source_url, + &succeeded, + redirects)); return succeeded; } @@ -280,13 +208,8 @@ bool TabProxy::GetCurrentURL(GURL* url) const { return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_TabURLRequest(0, handle_), &response, - AutomationMsg_TabURLResponse::ID) && - AutomationMsg_TabURLResponse::Read(response, &succeeded, url) && - succeeded; - scoped_ptr<IPC::Message> auto_deleter(response); + bool succeeded = false; + sender_->Send(new AutomationMsg_TabURL(0, handle_, &succeeded, url)); return succeeded; } @@ -294,14 +217,8 @@ bool TabProxy::NavigateToURLAsync(const GURL& url) { if (!is_valid()) return false; - IPC::Message* response = NULL; bool status = false; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_NavigationAsyncRequest(0, handle_, url), &response, - AutomationMsg_NavigationAsyncResponse::ID)) { - AutomationMsg_NavigationAsyncResponse::Read(response, &status); - } - scoped_ptr<IPC::Message> auto_deleter(response); + sender_->Send(new AutomationMsg_NavigationAsync(0, handle_, url, &status)); return status; } @@ -312,15 +229,8 @@ bool TabProxy::GetHWND(HWND* hwnd) const { NOTREACHED(); return false; } - IPC::Message* response = NULL; - bool succeeded = false; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_TabHWNDRequest(0, handle_), &response, - AutomationMsg_TabHWNDResponse::ID)) { - succeeded = AutomationMsg_TabHWNDResponse::Read(response, hwnd); - } - scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + + return sender_->Send(new AutomationMsg_TabHWND(0, handle_, hwnd)); } bool TabProxy::GetProcessID(int* process_id) const { @@ -332,15 +242,7 @@ bool TabProxy::GetProcessID(int* process_id) const { return false; } - IPC::Message* response = NULL; - bool succeeded = false; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_TabProcessIDRequest(0, handle_), &response, - AutomationMsg_TabProcessIDResponse::ID)) { - succeeded = AutomationMsg_TabProcessIDResponse::Read(response, process_id); - } - scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + return sender_->Send(new AutomationMsg_TabProcessID(0, handle_, process_id)); } bool TabProxy::ExecuteAndExtractString(const std::wstring& frame_xpath, @@ -423,15 +325,9 @@ bool TabProxy::ExecuteAndExtractValue(const std::wstring& frame_xpath, return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_DomOperationRequest(0, handle_, frame_xpath, jscript), - &response, AutomationMsg_DomOperationResponse::ID); std::string json; - if (succeeded) - succeeded = AutomationMsg_DomOperationResponse::Read(response, &json); - scoped_ptr<IPC::Message> auto_deleter(response); - if (!succeeded) + if (!sender_->Send(new AutomationMsg_DomOperation(0, handle_, frame_xpath, + jscript, &json))) return false; // Wrap |json| in an array before deserializing because valid JSON has an // array or an object as the root. @@ -452,13 +348,8 @@ bool TabProxy::GetConstrainedWindowCount(int* count) const { return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_ConstrainedWindowCountRequest(0, handle_), - &response, AutomationMsg_ConstrainedWindowCountResponse::ID) && - AutomationMsg_ConstrainedWindowCountResponse::Read(response, count); - scoped_ptr<IPC::Message> auto_deleter(response); - return succeeded; + return sender_->Send(new AutomationMsg_ConstrainedWindowCount( + 0, handle_, count)); } ConstrainedWindowProxy* TabProxy::GetConstrainedWindow( @@ -466,15 +357,13 @@ ConstrainedWindowProxy* TabProxy::GetConstrainedWindow( if (!is_valid()) return NULL; - IPC::Message* response = NULL; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_ConstrainedWindowRequest(0, handle_, window_index), - &response, AutomationMsg_ConstrainedWindowResponse::ID)) { - scoped_ptr<IPC::Message> response_deleter(response); - int handle; - if (AutomationMsg_ConstrainedWindowResponse::Read(response, &handle)) - return new ConstrainedWindowProxy(sender_, tracker_, handle); + int handle = 0; + if (sender_->Send(new AutomationMsg_ConstrainedWindow(0, handle_, + window_index, + &handle))) { + return new ConstrainedWindowProxy(sender_, tracker_, handle); } + return NULL; } @@ -495,15 +384,9 @@ bool TabProxy::GetCookies(const GURL& url, std::string* cookies) { if (!is_valid()) return false; - IPC::Message* response = NULL; - int size; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_GetCookiesRequest(0, url, handle_), &response, - AutomationMsg_GetCookiesResponse::ID) && - AutomationMsg_GetCookiesResponse::Read(response, &size, cookies) && - size >= 0; - scoped_ptr<IPC::Message> response_deleter(response); - return succeeded; + int size = 0; + return sender_->Send(new AutomationMsg_GetCookies(0, url, handle_, &size, + cookies)); } bool TabProxy::GetCookieByName(const GURL& url, @@ -526,29 +409,17 @@ bool TabProxy::GetCookieByName(const GURL& url, } bool TabProxy::SetCookie(const GURL& url, const std::string& value) { - IPC::Message* response = NULL; - int response_value; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_SetCookieRequest(0, url, value, handle_), &response, - AutomationMsg_SetCookieResponse::ID) && - AutomationMsg_SetCookieResponse::Read(response, &response_value) && - response_value >= 0; - scoped_ptr<IPC::Message> response_deleter(response); - return succeeded; + int response_value = 0; + return sender_->Send(new AutomationMsg_SetCookie(0, url, value, handle_, + &response_value)); } int TabProxy::InspectElement(int x, int y) { if (!is_valid()) return -1; - IPC::Message* response = NULL; int ret = -1; - if (sender_->SendAndWaitForResponse( - new AutomationMsg_InspectElementRequest(0, handle_, x, y), - &response, AutomationMsg_InspectElementResponse::ID)) { - AutomationMsg_InspectElementResponse::Read(response, &ret); - } - scoped_ptr<IPC::Message> response_deleter(response); + sender_->Send(new AutomationMsg_InspectElement(0, handle_, x, y, &ret)); return ret; } @@ -557,13 +428,8 @@ bool TabProxy::GetDownloadDirectory(std::wstring* directory) { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_DownloadDirectoryRequest(0, handle_), &response, - AutomationMsg_DownloadDirectoryResponse::ID) && - AutomationMsg_DownloadDirectoryResponse::Read(response, directory); - scoped_ptr<IPC::Message> response_deleter(response); - return succeeded; + return sender_->Send(new AutomationMsg_DownloadDirectory(0, handle_, + directory)); } bool TabProxy::ShowInterstitialPage(const std::string& html_text, @@ -571,15 +437,9 @@ bool TabProxy::ShowInterstitialPage(const std::string& html_text, if (!is_valid()) return false; - bool is_timeout = false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_ShowInterstitialPageRequest(0, handle_, html_text), - &response, AutomationMsg_ShowInterstitialPageResponse::ID, timeout_ms, - &is_timeout) && - AutomationMsg_ShowInterstitialPageResponse::Read(response, &succeeded) && - succeeded; - scoped_ptr<IPC::Message> response_deleter(response); + bool succeeded = false; + sender_->SendWithTimeout(new AutomationMsg_ShowInterstitialPage( + 0, handle_, html_text, &succeeded), timeout_ms, NULL); return succeeded; } @@ -587,14 +447,9 @@ bool TabProxy::HideInterstitialPage() { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_HideInterstitialPageRequest(0, handle_), - &response, AutomationMsg_HideInterstitialPageResponse::ID) && - AutomationMsg_HideInterstitialPageResponse::Read(response, &succeeded) && - succeeded; - scoped_ptr<IPC::Message> response_deleter(response); - return succeeded; + bool result = false; + sender_->Send(new AutomationMsg_HideInterstitialPage(0, handle_, &result)); + return result; } bool TabProxy::Close() { @@ -605,13 +460,9 @@ bool TabProxy::Close(bool wait_until_closed) { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_CloseTabRequest(0, handle_, wait_until_closed), - &response, AutomationMsg_CloseTabResponse::ID) && - AutomationMsg_CloseTabResponse::Read(response, &succeeded) && - succeeded; - scoped_ptr<IPC::Message> response_deleter(response); + bool succeeded = false; + sender_->Send(new AutomationMsg_CloseTab(0, handle_, wait_until_closed, + &succeeded)); return succeeded; } @@ -620,16 +471,9 @@ bool TabProxy::SetAccelerators(HACCEL accel_table, if (!is_valid()) return false; - IPC::Message* response = NULL; - bool is_timeout = false; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_SetAcceleratorsForTab( - 0, handle_, accel_table, accel_table_entry_count), - &response, AutomationMsg_SetAcceleratorsForTabResponse::ID, INFINITE, - &is_timeout) && - AutomationMsg_SetAcceleratorsForTabResponse::Read(response, &succeeded) && - succeeded; - scoped_ptr<IPC::Message> response_deleter(response); + bool succeeded = false; + sender_->Send(new AutomationMsg_SetAcceleratorsForTab( + 0, handle_, accel_table, accel_table_entry_count, &succeeded)); return succeeded; } @@ -652,13 +496,7 @@ bool TabProxy::SetInitialFocus(bool reverse) { bool TabProxy::WaitForTabToBeRestored(uint32 timeout_ms) { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool is_timeout; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_WaitForTabToBeRestored(0, handle_), &response, - AutomationMsg_TabFinishedRestoring::ID, timeout_ms, &is_timeout); - scoped_ptr<IPC::Message> response_deleter(response); - return succeeded; + return sender_->Send(new AutomationMsg_WaitForTabToBeRestored(0, handle_)); } bool TabProxy::GetSecurityState(SecurityStyle* security_style, @@ -669,17 +507,12 @@ bool TabProxy::GetSecurityState(SecurityStyle* security_style, if (!is_valid()) return false; - IPC::Message* response = NULL; - bool is_timeout = false; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_GetSecurityState(0, handle_), - &response, - AutomationMsg_GetSecurityStateResponse::ID, INFINITE, &is_timeout) && - AutomationMsg_GetSecurityStateResponse::Read( - response, &succeeded, security_style, ssl_cert_status, - mixed_content_state) && - succeeded; - scoped_ptr<IPC::Message> auto_deleter(response); + bool succeeded = false; + + sender_->Send(new AutomationMsg_GetSecurityState( + 0, handle_, &succeeded, security_style, ssl_cert_status, + mixed_content_state)); + return succeeded; } @@ -689,16 +522,8 @@ bool TabProxy::GetPageType(NavigationEntry::PageType* type) { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool is_timeout = false; - bool succeeded; - succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_GetPageType(0, handle_), - &response, - AutomationMsg_GetPageTypeResponse::ID, INFINITE, &is_timeout) && - AutomationMsg_GetPageTypeResponse::Read(response, &succeeded, type) && - succeeded; - scoped_ptr<IPC::Message> auto_deleter(response); + bool succeeded = false; + sender_->Send(new AutomationMsg_GetPageType(0, handle_, &succeeded, type)); return succeeded; } @@ -706,15 +531,9 @@ bool TabProxy::TakeActionOnSSLBlockingPage(bool proceed) { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool timeout = false; - bool success = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_ActionOnSSLBlockingPage(0, handle_, proceed), - &response, - AutomationMsg_ActionOnSSLBlockingPageResponse::ID, INFINITE, &timeout) && - AutomationMsg_ActionOnSSLBlockingPageResponse::Read(response, &success) && - success; - scoped_ptr<IPC::Message> auto_deleter(response); + bool success = false; + sender_->Send(new AutomationMsg_ActionOnSSLBlockingPage(0, handle_, proceed, + &success)); return success; } @@ -722,13 +541,8 @@ bool TabProxy::PrintNow() { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_PrintNowRequest(0, handle_), &response, - AutomationMsg_PrintNowResponse::ID) && - AutomationMsg_PrintNowResponse::Read(response, &succeeded) && - succeeded; - scoped_ptr<IPC::Message> auto_deleter(response); + bool succeeded = false; + sender_->Send(new AutomationMsg_PrintNow(0, handle_, &succeeded)); return succeeded; } @@ -738,14 +552,10 @@ bool TabProxy::SavePage(const std::wstring& file_name, if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_SavePageRequest( - 0, handle_, file_name, dir_path, static_cast<int>(type)), - &response, AutomationMsg_SavePageResponse::ID) && - AutomationMsg_SavePageResponse::Read(response, &succeeded) && - succeeded; - scoped_ptr<IPC::Message> auto_deleter(response); + bool succeeded = false; + sender_->Send(new AutomationMsg_SavePage(0, handle_, file_name, dir_path, + static_cast<int>(type), + &succeeded)); return succeeded; } @@ -766,14 +576,8 @@ bool TabProxy::GetSSLInfoBarCount(int* count) { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool success = sender_->SendAndWaitForResponse( - new AutomationMsg_GetSSLInfoBarCountRequest(0, handle_), - &response, AutomationMsg_GetSSLInfoBarCountResponse::ID) && - AutomationMsg_GetSSLInfoBarCountResponse::Read(response, count) && - count >= 0; - scoped_ptr<IPC::Message> auto_deleter(response); - return success; + return sender_->Send(new AutomationMsg_GetSSLInfoBarCount(0, handle_, + count)); } bool TabProxy::ClickSSLInfoBarLink(int info_bar_index, @@ -781,14 +585,9 @@ bool TabProxy::ClickSSLInfoBarLink(int info_bar_index, if (!is_valid()) return false; - IPC::Message* response = NULL; - bool success = sender_->SendAndWaitForResponse( - new AutomationMsg_ClickSSLInfoBarLinkRequest( - 0, handle_, info_bar_index, wait_for_navigation), - &response, AutomationMsg_ClickSSLInfoBarLinkResponse::ID) && - AutomationMsg_ClickSSLInfoBarLinkResponse::Read(response, &success) && - success; - scoped_ptr<IPC::Message> auto_deleter(response); + bool success = false; + sender_->Send(new AutomationMsg_ClickSSLInfoBarLink( + 0, handle_, info_bar_index, wait_for_navigation, &success)); return success; } @@ -796,12 +595,9 @@ bool TabProxy::GetLastNavigationTime(int64* nav_time) { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool success = sender_->SendAndWaitForResponse( - new AutomationMsg_GetLastNavigationTimeRequest(0, handle_), - &response, AutomationMsg_GetLastNavigationTimeResponse::ID) && - AutomationMsg_GetLastNavigationTimeResponse::Read(response, nav_time); - scoped_ptr<IPC::Message> auto_deleter(response); + bool success = false; + success = sender_->Send(new AutomationMsg_GetLastNavigationTime( + 0, handle_, nav_time)); return success; } @@ -809,14 +605,10 @@ bool TabProxy::WaitForNavigation(int64 last_navigation_time) { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool success = sender_->SendAndWaitForResponse( - new AutomationMsg_WaitForNavigationRequest( - 0, handle_, last_navigation_time), - &response, AutomationMsg_WaitForNavigationResponse::ID) && - AutomationMsg_WaitForNavigationResponse::Read(response, &success) && - success; - scoped_ptr<IPC::Message> auto_deleter(response); + bool success = false; + sender_->Send(new AutomationMsg_WaitForNavigation(0, handle_, + last_navigation_time, + &success)); return success; } @@ -824,12 +616,8 @@ bool TabProxy::GetPageCurrentEncoding(std::wstring* encoding) { if (!is_valid()) return false; - IPC::Message* response; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_GetPageCurrentEncodingRequest(0, handle_), - &response, AutomationMsg_GetPageCurrentEncodingResponse::ID) && - AutomationMsg_GetPageCurrentEncodingResponse::Read(response, encoding); - scoped_ptr<IPC::Message> response_deleter(response); + bool succeeded = sender_->Send( + new AutomationMsg_GetPageCurrentEncoding(0, handle_, encoding)); return succeeded; } @@ -837,12 +625,8 @@ bool TabProxy::OverrideEncoding(const std::wstring& encoding) { if (!is_valid()) return false; - IPC::Message* response; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_OverrideEncodingRequest(0, handle_, encoding), - &response, AutomationMsg_OverrideEncodingResponse::ID) && - AutomationMsg_OverrideEncodingResponse::Read(response, &succeeded) && - succeeded; - scoped_ptr<IPC::Message> response_deleter(response); + bool succeeded = false; + sender_->Send(new AutomationMsg_OverrideEncoding(0, handle_, encoding, + &succeeded)); return succeeded; } diff --git a/chrome/test/automation/window_proxy.cc b/chrome/test/automation/window_proxy.cc index 1780956..d43f718 100644 --- a/chrome/test/automation/window_proxy.cc +++ b/chrome/test/automation/window_proxy.cc @@ -24,78 +24,40 @@ bool WindowProxy::GetHWND(HWND* handle) const { return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_WindowHWNDRequest(0, handle_), &response, - AutomationMsg_WindowHWNDResponse::ID); - if (!succeeded) - return false; - - HWND hwnd_response; - if (AutomationMsg_WindowHWNDResponse::Read(response, &hwnd_response) && - hwnd_response) { - *handle = hwnd_response; - } else { - succeeded = false; - } - - delete response; - return succeeded; + return sender_->Send(new AutomationMsg_WindowHWND(0, handle_, handle)); } bool WindowProxy::SimulateOSClick(const POINT& click, int flags) { if (!is_valid()) return false; return sender_->Send( - new AutomationMsg_WindowClickRequest(0, handle_, click, flags)); + new AutomationMsg_WindowClick(0, handle_, click, flags)); } bool WindowProxy::SimulateOSKeyPress(wchar_t key, int flags) { if (!is_valid()) return false; return sender_->Send( - new AutomationMsg_WindowKeyPressRequest(0, handle_, key, flags)); + new AutomationMsg_WindowKeyPress(0, handle_, key, flags)); } bool WindowProxy::SetVisible(bool visible) { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_SetWindowVisibleRequest(0, handle_, visible), - &response, AutomationMsg_SetWindowVisibleResponse::ID); - - scoped_ptr<IPC::Message> response_deleter(response); // Ensure deleted. - if (!succeeded) - return false; - - void* iter = NULL; - if (!response->ReadBool(&iter, &succeeded)) - succeeded = false; + bool result = false; - return succeeded; + sender_->Send(new AutomationMsg_SetWindowVisible(0, handle_, visible, + &result)); + return result; } bool WindowProxy::IsActive(bool* active) { if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_IsWindowActiveRequest(0, handle_), - &response, AutomationMsg_IsWindowActiveResponse::ID); - - scoped_ptr<IPC::Message> response_deleter(response); // Ensure deleted. - if (!succeeded) - return false; - - void* iter = NULL; - if (!response->ReadBool(&iter, &succeeded) || !succeeded) - return false; - - if (!response->ReadBool(&iter, active)) - return false; + bool result = false; - return true; + sender_->Send(new AutomationMsg_IsWindowActive(0, handle_, &result, active)); + return result; } bool WindowProxy::Activate() { @@ -114,29 +76,21 @@ bool WindowProxy::GetViewBoundsWithTimeout(int view_id, gfx::Rect* bounds, bool screen_coordinates, uint32 timeout_ms, bool* is_timeout) { - if (!is_valid()) return false; + if (!is_valid()) + return false; if (!bounds) { NOTREACHED(); return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_WindowViewBoundsRequest(0, handle_, view_id, - screen_coordinates), - &response, - AutomationMsg_WindowViewBoundsResponse::ID, - timeout_ms, - is_timeout); - if (!succeeded) - return false; + bool result = false; - Tuple2<bool, gfx::Rect> result; - AutomationMsg_WindowViewBoundsResponse::Read(response, &result); + sender_->SendWithTimeout(new AutomationMsg_WindowViewBounds( + 0, handle_, view_id, screen_coordinates, &result, bounds), + timeout_ms, is_timeout); - *bounds = result.b; - return result.a; + return result; } bool WindowProxy::GetFocusedViewID(int* view_id) { @@ -147,18 +101,8 @@ bool WindowProxy::GetFocusedViewID(int* view_id) { return false; } - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponse( - new AutomationMsg_GetFocusedViewIDRequest(0, handle_), - &response, - AutomationMsg_GetFocusedViewIDResponse::ID); - - *view_id = -1; - if (succeeded && - AutomationMsg_GetFocusedViewIDResponse::Read(response, view_id)) - return true; - - return false; + return sender_->Send(new AutomationMsg_GetFocusedViewID(0, handle_, + view_id)); } BrowserProxy* WindowProxy::GetBrowser() { @@ -170,24 +114,13 @@ BrowserProxy* WindowProxy::GetBrowserWithTimeout(uint32 timeout_ms, if (!is_valid()) return false; - IPC::Message* response = NULL; - bool succeeded = sender_->SendAndWaitForResponseWithTimeout( - new AutomationMsg_BrowserForWindowRequest(0, handle_), &response, - AutomationMsg_BrowserForWindowResponse::ID, timeout_ms, is_timeout); - if (!succeeded) - return NULL; - - scoped_ptr<IPC::Message> response_deleter(response); // Delete on exit. + bool handle_ok = false; int browser_handle = 0; - void* iter = NULL; - bool handle_ok; - succeeded = response->ReadBool(&iter, &handle_ok); - if (succeeded) - succeeded = response->ReadInt(&iter, &browser_handle); - - if (succeeded) { - return new BrowserProxy(sender_, tracker_, browser_handle); - } else { + + sender_->Send(new AutomationMsg_BrowserForWindow(0, handle_, &handle_ok, + &browser_handle)); + if (!handle_ok) return NULL; - } + + return new BrowserProxy(sender_, tracker_, browser_handle); } diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 5d88ba9..486ee0d 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -698,7 +698,7 @@ std::wstring UITest::GetDownloadDirectory() { void UITest::CloseBrowserAsync(BrowserProxy* browser) const { server_->Send( - new AutomationMsg_CloseBrowserRequest(0, browser->handle())); + new AutomationMsg_CloseBrowserRequestAsync(0, browser->handle())); } bool UITest::CloseBrowser(BrowserProxy* browser, @@ -707,26 +707,20 @@ bool UITest::CloseBrowser(BrowserProxy* browser, if (!browser->is_valid() || !browser->handle()) return false; - IPC::Message* response = NULL; - bool succeeded = server_->SendAndWaitForResponse( - new AutomationMsg_CloseBrowserRequest(0, browser->handle()), - &response, AutomationMsg_CloseBrowserResponse__ID); + bool result = true; + + bool succeeded = server_->Send(new AutomationMsg_CloseBrowser( + 0, browser->handle(), &result, application_closed)); if (!succeeded) return false; - void* iter = NULL; - bool result = true; - response->ReadBool(&iter, &result); - response->ReadBool(&iter, application_closed); - if (*application_closed) { // Let's wait until the process dies (if it is not gone already). int r = WaitForSingleObject(process_, INFINITE); DCHECK(r != WAIT_FAILED); } - delete response; return result; } |