diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-10 21:51:52 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-10 21:51:52 +0000 |
commit | 52415f845c07904de5e22b901c86fa5ddea05102 (patch) | |
tree | 9701556a907004422b23ded0e100e2c3a20c96ba | |
parent | 9c53a338c232cddc09838f1e2e927dcfe08abb00 (diff) | |
download | chromium_src-52415f845c07904de5e22b901c86fa5ddea05102.zip chromium_src-52415f845c07904de5e22b901c86fa5ddea05102.tar.gz chromium_src-52415f845c07904de5e22b901c86fa5ddea05102.tar.bz2 |
Clean up external-tab related code in automation provider and automation proxy.
BUG=44695
TEST=compile
Review URL: http://codereview.chromium.org/2743006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49448 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 142 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 98 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_gtk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_mac.mm | 13 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_win.cc | 101 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.cc | 72 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.h | 34 |
7 files changed, 225 insertions, 241 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 98f05e7..de32396 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -25,11 +25,9 @@ #include "chrome/app/chrome_version_info.h" #include "chrome/browser/app_modal_dialog.h" #include "chrome/browser/app_modal_dialog_queue.h" -#include "chrome/browser/automation/automation_extension_function.h" #include "chrome/browser/automation/automation_extension_tracker.h" #include "chrome/browser/automation/automation_provider_list.h" #include "chrome/browser/automation/automation_provider_observers.h" -#include "chrome/browser/automation/extension_automation_constants.h" #include "chrome/browser/automation/extension_port_container.h" #include "chrome/browser/blocked_popup_container.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -399,29 +397,12 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_AutocompleteEditForBrowser, GetAutocompleteEditForBrowser) IPC_MESSAGE_HANDLER(AutomationMsg_BrowserForWindow, GetBrowserForWindow) -#if defined(OS_WIN) - IPC_MESSAGE_HANDLER(AutomationMsg_CreateExternalTab, CreateExternalTab) -#endif - IPC_MESSAGE_HANDLER(AutomationMsg_NavigateInExternalTab, - NavigateInExternalTab) - IPC_MESSAGE_HANDLER(AutomationMsg_NavigateExternalTabAtIndex, - NavigateExternalTabAtIndex) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ShowInterstitialPage, ShowInterstitialPage) IPC_MESSAGE_HANDLER(AutomationMsg_HideInterstitialPage, HideInterstitialPage) -#if defined(OS_WIN) - IPC_MESSAGE_HANDLER(AutomationMsg_ProcessUnhandledAccelerator, - ProcessUnhandledAccelerator) -#endif IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabToBeRestored, WaitForTabToBeRestored) - IPC_MESSAGE_HANDLER(AutomationMsg_SetInitialFocus, SetInitialFocus) -#if defined(OS_WIN) - IPC_MESSAGE_HANDLER(AutomationMsg_TabReposition, OnTabReposition) - IPC_MESSAGE_HANDLER(AutomationMsg_ForwardContextMenuCommandToChrome, - OnForwardContextMenuCommandToChrome) -#endif IPC_MESSAGE_HANDLER(AutomationMsg_GetSecurityState, GetSecurityState) IPC_MESSAGE_HANDLER(AutomationMsg_GetPageType, GetPageType) IPC_MESSAGE_HANDLER(AutomationMsg_GetMetricEventDuration, @@ -444,8 +425,6 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { AutocompleteEditGetMatches) IPC_MESSAGE_HANDLER(AutomationMsg_OpenFindInPage, HandleOpenFindInPageRequest) - IPC_MESSAGE_HANDLER(AutomationMsg_HandleMessageFromExternalHost, - OnMessageFromExternalHost) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Find, HandleFindRequest) IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowVisibility, GetFindWindowVisibility) @@ -494,11 +473,6 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_SavePackageShouldPromptUser, SavePackageShouldPromptUser) IPC_MESSAGE_HANDLER(AutomationMsg_WindowTitle, GetWindowTitle) -#if defined(OS_WIN) - // Depends on ExternalTabContainer, so Windows-only - IPC_MESSAGE_HANDLER(AutomationMsg_SetEnableExtensionAutomation, - SetEnableExtensionAutomation) -#endif IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) IPC_MESSAGE_HANDLER(AutomationMsg_BlockedPopupCount, GetBlockedPopupCount) IPC_MESSAGE_HANDLER(AutomationMsg_SelectAll, SelectAll) @@ -519,9 +493,6 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER_DELAY_REPLY( AutomationMsg_GoForwardBlockUntilNavigationsComplete, GoForwardBlockUntilNavigationsComplete) -#if defined(OS_WIN) - IPC_MESSAGE_HANDLER(AutomationMsg_ConnectExternalTab, ConnectExternalTab) -#endif IPC_MESSAGE_HANDLER(AutomationMsg_SetPageFontSize, OnSetPageFontSize) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InstallExtension, InstallExtension) @@ -568,6 +539,25 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { WaitForPopupMenuToOpen) #endif IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme) +#if defined(OS_WIN) + // These are for use with external tabs. + IPC_MESSAGE_HANDLER(AutomationMsg_CreateExternalTab, CreateExternalTab) + IPC_MESSAGE_HANDLER(AutomationMsg_ProcessUnhandledAccelerator, + ProcessUnhandledAccelerator) + IPC_MESSAGE_HANDLER(AutomationMsg_SetInitialFocus, SetInitialFocus) + IPC_MESSAGE_HANDLER(AutomationMsg_TabReposition, OnTabReposition) + IPC_MESSAGE_HANDLER(AutomationMsg_ForwardContextMenuCommandToChrome, + OnForwardContextMenuCommandToChrome) + IPC_MESSAGE_HANDLER(AutomationMsg_NavigateInExternalTab, + NavigateInExternalTab) + IPC_MESSAGE_HANDLER(AutomationMsg_NavigateExternalTabAtIndex, + NavigateExternalTabAtIndex) + IPC_MESSAGE_HANDLER(AutomationMsg_ConnectExternalTab, ConnectExternalTab) + IPC_MESSAGE_HANDLER(AutomationMsg_SetEnableExtensionAutomation, + SetEnableExtensionAutomation) + IPC_MESSAGE_HANDLER(AutomationMsg_HandleMessageFromExternalHost, + OnMessageFromExternalHost) +#endif IPC_END_MESSAGE_MAP() } @@ -2516,30 +2506,6 @@ void AutomationProvider::CloseBrowserAsync(int browser_handle) { } } -void AutomationProvider::NavigateInExternalTab( - int handle, const GURL& url, const GURL& referrer, - AutomationMsg_NavigationResponseValues* status) { - *status = AUTOMATION_MSG_NAVIGATION_ERROR; - - if (tab_tracker_->ContainsHandle(handle)) { - NavigationController* tab = tab_tracker_->GetResource(handle); - tab->LoadURL(url, referrer, PageTransition::TYPED); - *status = AUTOMATION_MSG_NAVIGATION_SUCCESS; - } -} - -void AutomationProvider::NavigateExternalTabAtIndex( - int handle, int navigation_index, - AutomationMsg_NavigationResponseValues* status) { - *status = AUTOMATION_MSG_NAVIGATION_ERROR; - - if (tab_tracker_->ContainsHandle(handle)) { - NavigationController* tab = tab_tracker_->GetResource(handle); - tab->GoToIndex(navigation_index); - *status = AUTOMATION_MSG_NAVIGATION_SUCCESS; - } -} - void AutomationProvider::WaitForTabToBeRestored(int tab_handle, IPC::Message* reply_message) { if (tab_tracker_->ContainsHandle(tab_handle)) { @@ -2737,77 +2703,7 @@ void AutomationProvider::AutocompleteEditIsQueryInProgress( } #if !defined(OS_MACOSX) -void AutomationProvider::OnMessageFromExternalHost(int handle, - const std::string& message, - const std::string& origin, - const std::string& target) { - RenderViewHost* view_host = GetViewForTab(handle); - if (!view_host) { - return; - } - if (AutomationExtensionFunction::InterceptMessageFromExternalHost( - view_host, message, origin, target)) { - // Message was diverted. - return; - } - - if (ExtensionPortContainer::InterceptMessageFromExternalHost(message, - origin, target, this, view_host, handle)) { - // Message was diverted. - return; - } - - if (InterceptBrowserEventMessageFromExternalHost(message, origin, target)) { - // Message was diverted. - return; - } - - view_host->ForwardMessageFromExternalHost(message, origin, target); -} - -bool AutomationProvider::InterceptBrowserEventMessageFromExternalHost( - const std::string& message, const std::string& origin, - const std::string& target) { - if (target != - extension_automation_constants::kAutomationBrowserEventRequestTarget) - return false; - - if (origin != extension_automation_constants::kAutomationOrigin) { - LOG(WARNING) << "Wrong origin on automation browser event " << origin; - return false; - } - - // The message is a JSON-encoded array with two elements, both strings. The - // first is the name of the event to dispatch. The second is a JSON-encoding - // of the arguments specific to that event. - scoped_ptr<Value> message_value(base::JSONReader::Read(message, false)); - if (!message_value.get() || !message_value->IsType(Value::TYPE_LIST)) { - LOG(WARNING) << "Invalid browser event specified through automation"; - return false; - } - - const ListValue* args = static_cast<const ListValue*>(message_value.get()); - - std::string event_name; - if (!args->GetString(0, &event_name)) { - LOG(WARNING) << "No browser event name specified through automation"; - return false; - } - - std::string json_args; - if (!args->GetString(1, &json_args)) { - LOG(WARNING) << "No browser event args specified through automation"; - return false; - } - - if (profile()->GetExtensionMessageService()) { - profile()->GetExtensionMessageService()->DispatchEventToRenderers( - event_name, json_args, profile()->IsOffTheRecord(), GURL()); - } - - return true; -} #endif // !defined(OS_MACOSX) TabContents* AutomationProvider::GetTabContentsForHandle( diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 59be59f..d95ee98 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -138,8 +138,10 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // the handle is simply returned. int AddExtension(Extension* extension); +#if defined(OS_WIN) // Adds the external tab passed in to the tab tracker. bool AddExternalTab(ExternalTabContainer* external_tab); +#endif protected: friend class base::RefCounted<AutomationProvider>; @@ -469,17 +471,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, IPC::Message* reply_message); void HideInterstitialPage(int tab_handle, bool* success); - void CreateExternalTab(const IPC::ExternalTabSettings& settings, - gfx::NativeWindow* tab_container_window, - gfx::NativeWindow* tab_window, - int* tab_handle); - - void ConnectExternalTab(uint64 cookie, - bool allow, - gfx::NativeWindow* tab_container_window, - gfx::NativeWindow* tab_window, - int* tab_handle); - void OnSetPageFontSize(int tab_handle, int font_size); // See browsing_data_remover.h for explanation of bitmap fields. @@ -523,34 +514,10 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, bool* success, std::string* value); - void NavigateInExternalTab( - int handle, const GURL& url, const GURL& referrer, - AutomationMsg_NavigationResponseValues* status); - void NavigateExternalTabAtIndex( - int handle, int index, AutomationMsg_NavigationResponseValues* status); - -// TODO(port): remove windowisms. -#if defined(OS_WIN) - // 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 - void ProcessUnhandledAccelerator(const IPC::Message& message, int handle, - const MSG& msg); -#endif - - void SetInitialFocus(const IPC::Message& message, int handle, bool reverse, - bool restore_focus_to_view); // See comment in AutomationMsg_WaitForTabToBeRestored. void WaitForTabToBeRestored(int tab_handle, IPC::Message* reply_message); -// TODO(port): remove windowisms. -#if defined(OS_WIN) - void OnTabReposition(int tab_handle, - const IPC::Reposition_Params& params); - void OnForwardContextMenuCommandToChrome(int tab_handle, int command); -#endif // defined(OS_WIN) - // Gets the security state for the tab associated to the specified |handle|. void GetSecurityState(int handle, bool* success, SecurityStyle* security_style, int* ssl_cert_status, @@ -612,10 +579,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, bool* success, std::vector<AutocompleteMatchData>* matches); - // Handler for a message sent by the automation client. - void OnMessageFromExternalHost(int handle, const std::string& message, - const std::string& origin, - const std::string& target); // Retrieves the number of info-bars currently showing in |count|. void GetInfoBarCount(int handle, int* count); @@ -714,8 +677,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // is not of the TabContents type. TabContents* GetTabContentsForHandle(int handle, NavigationController** tab); - ExternalTabContainer* GetExternalTabForHandle(int handle); - #if defined(OS_CHROMEOS) // Logs in through the Chrome OS Login Wizard with given |username| and // password. Returns true via |reply_message| on success. @@ -731,12 +692,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, bool success, history::RedirectList* redirects); - // Determine if the message from the external host represents a browser - // event, and if so dispatch it. - bool InterceptBrowserEventMessageFromExternalHost(const std::string& message, - const std::string& origin, - const std::string& target); - // Returns the associated view for the tab handle passed in. // Returns NULL on failure. RenderViewHost* GetViewForTab(int tab_handle); @@ -769,6 +724,55 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // Method called by the popup menu tracker when a popup menu is opened. void NotifyPopupMenuOpened(); +#if defined(OS_WIN) + // The functions in this block are for use with external tabs, so they are + // Windows only. + + // 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 + void ProcessUnhandledAccelerator(const IPC::Message& message, int handle, + const MSG& msg); + + void SetInitialFocus(const IPC::Message& message, int handle, bool reverse, + bool restore_focus_to_view); + + void OnTabReposition(int tab_handle, + const IPC::Reposition_Params& params); + + void OnForwardContextMenuCommandToChrome(int tab_handle, int command); + + void CreateExternalTab(const IPC::ExternalTabSettings& settings, + gfx::NativeWindow* tab_container_window, + gfx::NativeWindow* tab_window, + int* tab_handle); + + void ConnectExternalTab(uint64 cookie, + bool allow, + gfx::NativeWindow* tab_container_window, + gfx::NativeWindow* tab_window, + int* tab_handle); + + void NavigateInExternalTab( + int handle, const GURL& url, const GURL& referrer, + AutomationMsg_NavigationResponseValues* status); + void NavigateExternalTabAtIndex( + int handle, int index, AutomationMsg_NavigationResponseValues* status); + + // Handler for a message sent by the automation client. + void OnMessageFromExternalHost(int handle, const std::string& message, + const std::string& origin, + const std::string& target); + + // Determine if the message from the external host represents a browser + // event, and if so dispatch it. + bool InterceptBrowserEventMessageFromExternalHost(const std::string& message, + const std::string& origin, + const std::string& target); + + ExternalTabContainer* GetExternalTabForHandle(int handle); +#endif + typedef ObserverList<NotificationObserver> NotificationObserverList; typedef std::map<NavigationController*, LoginHandler*> LoginHandlerMap; typedef std::map<int, ExtensionPortContainer*> PortContainerMap; diff --git a/chrome/browser/automation/automation_provider_gtk.cc b/chrome/browser/automation/automation_provider_gtk.cc index 8e12c89..8b839f7 100644 --- a/chrome/browser/automation/automation_provider_gtk.cc +++ b/chrome/browser/automation/automation_provider_gtk.cc @@ -82,12 +82,6 @@ void AutomationProvider::PrintAsync(int tab_handle) { NOTIMPLEMENTED(); } -void AutomationProvider::SetInitialFocus(const IPC::Message& message, - int handle, bool reverse, - bool restore_focus_to_view) { - NOTIMPLEMENTED(); -} - // This task sends a WindowDragResponse message with the appropriate // routing ID to the automation proxy. This is implemented as a task so that // we know that the mouse events (and any tasks that they spawn on the message diff --git a/chrome/browser/automation/automation_provider_mac.mm b/chrome/browser/automation/automation_provider_mac.mm index ff92977..124cb71 100644 --- a/chrome/browser/automation/automation_provider_mac.mm +++ b/chrome/browser/automation/automation_provider_mac.mm @@ -70,19 +70,6 @@ void AutomationProvider::PrintAsync(int tab_handle) { NOTIMPLEMENTED(); } -void AutomationProvider::OnMessageFromExternalHost(int handle, - const std::string& message, - const std::string& origin, - const std::string& target) { - NOTIMPLEMENTED(); -} - -void AutomationProvider::SetInitialFocus(const IPC::Message& message, - int handle, bool reverse, - bool restore_focus_to_view) { - NOTIMPLEMENTED(); -} - void AutomationProvider::WindowSimulateDrag(int handle, std::vector<gfx::Point> drag_path, int flags, diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 47f252b..acc7a16 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -4,11 +4,17 @@ #include "chrome/browser/automation/automation_provider.h" +#include "base/json/json_reader.h" #include "base/keyboard_codes.h" +#include "chrome/browser/automation/automation_extension_function.h" +#include "chrome/browser/automation/extension_automation_constants.h" +#include "chrome/browser/automation/extension_port_container.h" #include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/browser_window.h" +#include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/external_tab_container.h" #include "chrome/browser/profile.h" +#include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/views/bookmark_bar_view.h" #include "chrome/test/automation/automation_messages.h" @@ -495,3 +501,98 @@ void AutomationProvider::GetWindowTitle(int handle, string16* text) { ::GetWindowText(window, WriteInto(&result, length), length); text->assign(WideToUTF16(result)); } + +void AutomationProvider::OnMessageFromExternalHost(int handle, + const std::string& message, + const std::string& origin, + const std::string& target) { + RenderViewHost* view_host = GetViewForTab(handle); + if (!view_host) + return; + + if (AutomationExtensionFunction::InterceptMessageFromExternalHost( + view_host, message, origin, target)) { + // Message was diverted. + return; + } + + if (ExtensionPortContainer::InterceptMessageFromExternalHost( + message, origin, target, this, view_host, handle)) { + // Message was diverted. + return; + } + + if (InterceptBrowserEventMessageFromExternalHost(message, origin, target)) { + // Message was diverted. + return; + } + + view_host->ForwardMessageFromExternalHost(message, origin, target); +} + +bool AutomationProvider::InterceptBrowserEventMessageFromExternalHost( + const std::string& message, const std::string& origin, + const std::string& target) { + if (target != + extension_automation_constants::kAutomationBrowserEventRequestTarget) + return false; + + if (origin != extension_automation_constants::kAutomationOrigin) { + LOG(WARNING) << "Wrong origin on automation browser event " << origin; + return false; + } + + // The message is a JSON-encoded array with two elements, both strings. The + // first is the name of the event to dispatch. The second is a JSON-encoding + // of the arguments specific to that event. + scoped_ptr<Value> message_value(base::JSONReader::Read(message, false)); + if (!message_value.get() || !message_value->IsType(Value::TYPE_LIST)) { + LOG(WARNING) << "Invalid browser event specified through automation"; + return false; + } + + const ListValue* args = static_cast<const ListValue*>(message_value.get()); + + std::string event_name; + if (!args->GetString(0, &event_name)) { + LOG(WARNING) << "No browser event name specified through automation"; + return false; + } + + std::string json_args; + if (!args->GetString(1, &json_args)) { + LOG(WARNING) << "No browser event args specified through automation"; + return false; + } + + if (profile()->GetExtensionMessageService()) { + profile()->GetExtensionMessageService()->DispatchEventToRenderers( + event_name, json_args, profile()->IsOffTheRecord(), GURL()); + } + + return true; +} + +void AutomationProvider::NavigateInExternalTab( + int handle, const GURL& url, const GURL& referrer, + AutomationMsg_NavigationResponseValues* status) { + *status = AUTOMATION_MSG_NAVIGATION_ERROR; + + if (tab_tracker_->ContainsHandle(handle)) { + NavigationController* tab = tab_tracker_->GetResource(handle); + tab->LoadURL(url, referrer, PageTransition::TYPED); + *status = AUTOMATION_MSG_NAVIGATION_SUCCESS; + } +} + +void AutomationProvider::NavigateExternalTabAtIndex( + int handle, int navigation_index, + AutomationMsg_NavigationResponseValues* status) { + *status = AUTOMATION_MSG_NAVIGATION_ERROR; + + if (tab_tracker_->ContainsHandle(handle)) { + NavigationController* tab = tab_tracker_->GetResource(handle); + tab->GoToIndex(navigation_index); + *status = AUTOMATION_MSG_NAVIGATION_SUCCESS; + } +} diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 8e31e00..a4711ca 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -97,28 +97,6 @@ AutomationMsg_NavigationResponseValues return navigate_response; } -AutomationMsg_NavigationResponseValues TabProxy::NavigateInExternalTab( - const GURL& url, const GURL& referrer) { - if (!is_valid()) - return AUTOMATION_MSG_NAVIGATION_ERROR; - - AutomationMsg_NavigationResponseValues rv = AUTOMATION_MSG_NAVIGATION_ERROR; - sender_->Send(new AutomationMsg_NavigateInExternalTab(0, handle_, url, - referrer, &rv)); - return rv; -} - -AutomationMsg_NavigationResponseValues TabProxy::NavigateExternalTabAtIndex( - int index) { - if (!is_valid()) - return AUTOMATION_MSG_NAVIGATION_ERROR; - - AutomationMsg_NavigationResponseValues rv = AUTOMATION_MSG_NAVIGATION_ERROR; - sender_->Send(new AutomationMsg_NavigateExternalTabAtIndex(0, handle_, index, - &rv)); - return rv; -} - bool TabProxy::SetAuth(const std::wstring& username, const std::wstring& password) { if (!is_valid()) @@ -537,25 +515,59 @@ bool TabProxy::Close(bool wait_until_closed) { } #if defined(OS_WIN) -// TODO(port): Remove windowsisms. bool TabProxy::ProcessUnhandledAccelerator(const MSG& msg) { if (!is_valid()) return false; + return sender_->Send( new AutomationMsg_ProcessUnhandledAccelerator(0, handle_, msg)); // This message expects no response } -#endif // defined(OS_WIN) bool TabProxy::SetInitialFocus(bool reverse, bool restore_focus_to_view) { if (!is_valid()) return false; + return sender_->Send( new AutomationMsg_SetInitialFocus(0, handle_, reverse, restore_focus_to_view)); // This message expects no response } +AutomationMsg_NavigationResponseValues TabProxy::NavigateInExternalTab( + const GURL& url, const GURL& referrer) { + if (!is_valid()) + return AUTOMATION_MSG_NAVIGATION_ERROR; + + AutomationMsg_NavigationResponseValues rv = AUTOMATION_MSG_NAVIGATION_ERROR; + sender_->Send(new AutomationMsg_NavigateInExternalTab(0, handle_, url, + referrer, &rv)); + return rv; +} + +AutomationMsg_NavigationResponseValues TabProxy::NavigateExternalTabAtIndex( + int index) { + if (!is_valid()) + return AUTOMATION_MSG_NAVIGATION_ERROR; + + AutomationMsg_NavigationResponseValues rv = AUTOMATION_MSG_NAVIGATION_ERROR; + sender_->Send(new AutomationMsg_NavigateExternalTabAtIndex(0, handle_, index, + &rv)); + return rv; +} + +void TabProxy::HandleMessageFromExternalHost(const std::string& message, + const std::string& origin, + const std::string& target) { + if (!is_valid()) + return; + + sender_->Send( + new AutomationMsg_HandleMessageFromExternalHost( + 0, handle_, message, origin, target)); +} +#endif // defined(OS_WIN) + bool TabProxy::WaitForTabToBeRestored(uint32 timeout_ms) { if (!is_valid()) return false; @@ -631,18 +643,6 @@ bool TabProxy::SavePage(const FilePath& file_name, return succeeded; } -void TabProxy::HandleMessageFromExternalHost(const std::string& message, - const std::string& origin, - const std::string& target) { - if (!is_valid()) - return; - - bool succeeded = - sender_->Send(new AutomationMsg_HandleMessageFromExternalHost(0, handle_, - message, origin, target)); - DCHECK(succeeded); -} - bool TabProxy::GetInfoBarCount(int* count) { if (!is_valid()) return false; diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index adcacf9..3c33318 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -134,15 +134,6 @@ class TabProxy : public AutomationResourceProxy, NavigateToURLBlockUntilNavigationsComplete( const GURL& url, int number_of_navigations) WARN_UNUSED_RESULT; - // Navigates to a url in an externally hosted tab. - // This method accepts the same kinds of URL input that - // can be passed to Chrome on the command line. This is a synchronous call and - // hence blocks until the navigation completes. - AutomationMsg_NavigationResponseValues NavigateInExternalTab( - const GURL& url, const GURL& referrer) WARN_UNUSED_RESULT; - - AutomationMsg_NavigationResponseValues NavigateExternalTabAtIndex( - int index) WARN_UNUSED_RESULT; // Navigates to a url. This is an asynchronous version of NavigateToURL. // The function returns immediately after sending the LoadURL notification @@ -287,20 +278,36 @@ class TabProxy : public AutomationResourceProxy, bool HideInterstitialPage() WARN_UNUSED_RESULT; #if defined(OS_WIN) - // TODO(port): Use something portable. + // The functions in this block are for external tabs, hence Windows only. // 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 bool ProcessUnhandledAccelerator(const MSG& msg) WARN_UNUSED_RESULT; -#endif // defined(OS_WIN) // Ask the tab to set focus to either the first or last element on the page. // When the restore_focus_to_view parameter is true, the render view // associated with the current tab is informed that it is receiving focus. + // For external tabs only. bool SetInitialFocus(bool reverse, bool restore_focus_to_view) WARN_UNUSED_RESULT; + // Navigates to a url in an externally hosted tab. + // This method accepts the same kinds of URL input that + // can be passed to Chrome on the command line. This is a synchronous call and + // hence blocks until the navigation completes. + AutomationMsg_NavigationResponseValues NavigateInExternalTab( + const GURL& url, const GURL& referrer) WARN_UNUSED_RESULT; + + AutomationMsg_NavigationResponseValues NavigateExternalTabAtIndex( + int index) WARN_UNUSED_RESULT; + + // Posts a message to the external tab. + void HandleMessageFromExternalHost(const std::string& message, + const std::string& origin, + const std::string& target); +#endif // defined(OS_WIN) + // Waits for the tab to finish being restored. Returns true on success. // timeout_ms gives the max amount of time to wait for restore to complete. bool WaitForTabToBeRestored(uint32 timeout_ms) WARN_UNUSED_RESULT; @@ -331,11 +338,6 @@ class TabProxy : public AutomationResourceProxy, bool SavePage(const FilePath& file_name, const FilePath& dir_path, SavePackage::SavePackageType type) WARN_UNUSED_RESULT; - // Posts a message to the external tab. - void HandleMessageFromExternalHost(const std::string& message, - const std::string& origin, - const std::string& target); - // Retrieves the number of info-bars currently showing in |count|. bool GetInfoBarCount(int* count) WARN_UNUSED_RESULT; |