summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 19:14:56 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 19:14:56 +0000
commit71f65dd427f9a579d258162fd02a73ae9a500916 (patch)
tree43630d5ca64029a0f82db8831c08a0e032991e31 /chrome/browser
parent521c0356810dac743b751c0f96bf605e6b41e880 (diff)
downloadchromium_src-71f65dd427f9a579d258162fd02a73ae9a500916.zip
chromium_src-71f65dd427f9a579d258162fd02a73ae9a500916.tar.gz
chromium_src-71f65dd427f9a579d258162fd02a73ae9a500916.tar.bz2
The Chrome Automation framework is based on a homegrown request response IPC model and thus ends up duplicating a lot of functionality already available in the SyncChannel.
This CL gets the automation framework to use the SyncChannel. The request response IPCs have been changed to sync IPCs. Review URL: http://codereview.chromium.org/20189 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9585 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/automation/automation_provider.cc1381
-rw-r--r--chrome/browser/automation/automation_provider.h310
2 files changed, 846 insertions, 845 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);
};