diff options
author | stoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-08 18:44:44 +0000 |
---|---|---|
committer | stoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-08 18:44:44 +0000 |
commit | eac83f0d14be2fed85edf2ffad934dd1309819e7 (patch) | |
tree | ff49e92397297d26cf3b860546a6a4730399d454 /chrome | |
parent | 35a321ef8cb16f44a29b114dbcfa99f62388710a (diff) | |
download | chromium_src-eac83f0d14be2fed85edf2ffad934dd1309819e7.zip chromium_src-eac83f0d14be2fed85edf2ffad934dd1309819e7.tar.gz chromium_src-eac83f0d14be2fed85edf2ffad934dd1309819e7.tar.bz2 |
Pass external tab handle when Chrome sends outgoing notifications through automation interface.
Review URL: http://codereview.chromium.org/115134
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15663 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 1 | ||||
-rw-r--r-- | chrome/browser/external_tab_container.cc | 27 | ||||
-rw-r--r-- | chrome/browser/external_tab_container.h | 6 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 29 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy_uitest.cc | 5 |
5 files changed, 45 insertions, 23 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 74eac52..282bb16 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -2401,6 +2401,7 @@ void AutomationProvider::CreateExternalTab(HWND parent, TabContents* tab_contents = external_tab_container->tab_contents(); if (tab_contents) { *tab_handle = tab_tracker_->Add(&tab_contents->controller()); + external_tab_container->set_tab_handle(*tab_handle); *tab_container_window = *external_tab_container; } else { delete external_tab_container; diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index e8ece07..339fd29 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -33,6 +33,7 @@ ExternalTabContainer::ExternalTabContainer( external_accel_table_(NULL), external_accel_entry_count_(0), tab_contents_container_(NULL), + tab_handle_(0), ignore_next_load_notification_(false) { } @@ -161,7 +162,8 @@ void ExternalTabContainer::OpenURLFromTab(TabContents* source, case NEW_BACKGROUND_TAB: case NEW_WINDOW: if (automation_) { - automation_->Send(new AutomationMsg_OpenURL(0, url, disposition)); + automation_->Send(new AutomationMsg_OpenURL(0, tab_handle_, + url, disposition)); } break; default: @@ -172,8 +174,8 @@ void ExternalTabContainer::OpenURLFromTab(TabContents* source, void ExternalTabContainer::NavigationStateChanged(const TabContents* source, unsigned changed_flags) { if (automation_) { - automation_->Send( - new AutomationMsg_NavigationStateChanged(0, changed_flags)); + automation_->Send(new AutomationMsg_NavigationStateChanged(0, tab_handle_, + changed_flags)); } } @@ -217,7 +219,7 @@ void ExternalTabContainer::UpdateTargetURL(TabContents* source, if (automation_) { std::wstring url_string = CA2W(url.spec().c_str()); automation_->Send( - new AutomationMsg_UpdateTargetUrl(0, url_string)); + new AutomationMsg_UpdateTargetUrl(0, tab_handle_, url_string)); } } @@ -233,8 +235,8 @@ void ExternalTabContainer::ForwardMessageToExternalHost( const std::string& target) { if(automation_) { automation_->Send( - new AutomationMsg_ForwardMessageToExternalHost(0, message, origin, - target)); + new AutomationMsg_ForwardMessageToExternalHost(0, tab_handle_, + message, origin, target)); } } @@ -245,7 +247,7 @@ bool ExternalTabContainer::TakeFocus(bool reverse) { DCHECK(focus_manager); if (focus_manager) { focus_manager->ClearFocus(); - automation_->Send(new AutomationMsg_TabbedOut(0, + automation_->Send(new AutomationMsg_TabbedOut(0, tab_handle_, win_util::IsShiftPressed())); } } @@ -267,7 +269,8 @@ void ExternalTabContainer::Observe(NotificationType type, const LoadNotificationDetails* load = Details<LoadNotificationDetails>(details).ptr(); if (PageTransition::IsMainFrame(load->origin())) { - automation_->Send(new AutomationMsg_TabLoaded(0, load->url())); + automation_->Send(new AutomationMsg_TabLoaded(0, tab_handle_, + load->url())); } break; } @@ -283,7 +286,7 @@ void ExternalTabContainer::Observe(NotificationType type, if (commit->http_status_code >= kHttpClientErrorStart && commit->http_status_code <= kHttpServerErrorEnd) { automation_->Send(new AutomationMsg_NavigationFailed( - 0, commit->http_status_code, commit->entry->url())); + 0, tab_handle_, commit->http_status_code, commit->entry->url())); ignore_next_load_notification_ = true; } else { @@ -291,7 +294,7 @@ void ExternalTabContainer::Observe(NotificationType type, // will still make the computation come out right (navigating to the // 0th entry will be +1). automation_->Send(new AutomationMsg_DidNavigate( - 0, commit->type, + 0, tab_handle_, commit->type, commit->previous_entry_index - tab_contents_->controller().last_committed_entry_index(), commit->entry->url())); @@ -302,7 +305,7 @@ void ExternalTabContainer::Observe(NotificationType type, const ProvisionalLoadDetails* load_details = Details<ProvisionalLoadDetails>(details).ptr(); automation_->Send(new AutomationMsg_NavigationFailed( - 0, load_details->error_code(), load_details->url())); + 0, tab_handle_, load_details->error_code(), load_details->url())); ignore_next_load_notification_ = true; break; @@ -372,7 +375,7 @@ bool ExternalTabContainer::ProcessKeyStroke(HWND window, UINT message, msg.message = message; msg.wParam = wparam; msg.lParam = lparam; - automation_->Send(new AutomationMsg_HandleAccelerator(0, msg)); + automation_->Send(new AutomationMsg_HandleAccelerator(0, tab_handle_, msg)); return true; } diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h index b55c84d..c0effce 100644 --- a/chrome/browser/external_tab_container.h +++ b/chrome/browser/external_tab_container.h @@ -52,6 +52,11 @@ class ExternalTabContainer : public TabContentsDelegate, return tab_contents_; } + // Temporary hack so we can send notifications back + void set_tab_handle(int handle) { + tab_handle_ = handle; + } + bool Init(Profile* profile, HWND parent, const gfx::Rect& dimensions, unsigned int style); @@ -159,6 +164,7 @@ class ExternalTabContainer : public TabContentsDelegate, TabContentsContainerView* tab_contents_container_; private: + int tab_handle_; // A failed navigation like a 404 is followed in chrome with a success // navigation for the 404 page. We need to ignore the next navigation // to avoid confusing the clients of the external tab. This member variable diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index bfbd4d2..decfc24 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -450,16 +450,19 @@ IPC_BEGIN_MESSAGES(Automation) // (see TabContents::InvalidateTypes) // Response: // None expected - IPC_MESSAGE_ROUTED1(AutomationMsg_NavigationStateChanged, int) + IPC_MESSAGE_ROUTED2(AutomationMsg_NavigationStateChanged, + int, // tab handle + int) // TabContents::InvalidateTypes // This message is an outgoing message from Chrome to an external host. // It is a notification that the target URL has changed (the target URL // is the URL of the link that the user is hovering on) // Request: + // -int: The tab handle // -std::wstring: The new target URL // Response: // None expected - IPC_MESSAGE_ROUTED1(AutomationMsg_UpdateTargetUrl, std::wstring) + IPC_MESSAGE_ROUTED2(AutomationMsg_UpdateTargetUrl, int, std::wstring) // This message notifies the AutomationProvider to show the specified html // text in an interstitial page in the tab with given handle. The first @@ -514,12 +517,13 @@ IPC_BEGIN_MESSAGES(Automation) // This message is an outgoing message from Chrome to an external host. // It is a request to process a keyboard accelerator. // Request: + // -int: Tab handle // -MSG: The keyboard message // Response: // None expected // TODO(sanjeevr): Ideally we need to add a response from the external // host saying whether it processed the accelerator - IPC_MESSAGE_ROUTED1(AutomationMsg_HandleAccelerator, MSG) + IPC_MESSAGE_ROUTED2(AutomationMsg_HandleAccelerator, int, MSG) // This message is sent by the container of an externally hosted tab to // reflect any accelerator keys that it did not process. This gives the @@ -535,11 +539,12 @@ IPC_BEGIN_MESSAGES(Automation) // Sent by the external tab to the host to notify that the user has tabbed // out of the tab. // Request: + // - int: Tab handle // - bool: |reverse| set to true when shift-tabbing out of the tab, false // otherwise. // Response: // None expected - IPC_MESSAGE_ROUTED1(AutomationMsg_TabbedOut, bool) + IPC_MESSAGE_ROUTED2(AutomationMsg_TabbedOut, int, bool) // Sent by the external tab host to ask focus to be set to either the first // or last element on the page. @@ -555,12 +560,13 @@ IPC_BEGIN_MESSAGES(Automation) // This message is an outgoing message from Chrome to an external host. // It is a request to open a url // Request: + // -int: Tab handle // -GURL: The URL to open // -int: The WindowOpenDisposition that specifies where the URL should // be opened (new tab, new window etc). // Response: // None expected - IPC_MESSAGE_ROUTED2(AutomationMsg_OpenURL, GURL, int) + IPC_MESSAGE_ROUTED3(AutomationMsg_OpenURL, int, GURL, int) // This message requests the provider to wait until the specified tab has // finished restoring after session restore. @@ -573,6 +579,7 @@ IPC_BEGIN_MESSAGES(Automation) // This message is an outgoing message from Chrome to an external host. // It is a notification that a navigation happened // Request: + // -int: Tab handle // -int : Indicates the type of navigation (see the NavigationType enum) // -int: If this was not a new navigation, then this value indicates the // relative offset of the navigation. A positive offset means a @@ -580,7 +587,7 @@ IPC_BEGIN_MESSAGES(Automation) // and 0 means this was a redirect // Response: // None expected - IPC_MESSAGE_ROUTED3(AutomationMsg_DidNavigate, int, int, GURL) + IPC_MESSAGE_ROUTED4(AutomationMsg_DidNavigate, int, int, int, GURL) // This message requests the different security states of the page displayed // in the specified tab. @@ -746,7 +753,8 @@ IPC_BEGIN_MESSAGES(Automation) std::string /* target */) // A message for an external host. - IPC_MESSAGE_ROUTED3(AutomationMsg_ForwardMessageToExternalHost, + IPC_MESSAGE_ROUTED4(AutomationMsg_ForwardMessageToExternalHost, + int, // handle std::string /* message */, std::string /* origin */, std::string /* target */) @@ -869,11 +877,12 @@ IPC_BEGIN_MESSAGES(Automation) // This message is an outgoing message from Chrome to an external host. // It is a notification that a navigation failed // Request: + // -int : Tab handle // -int : The status code. // -GURL: The URL we failed to navigate to. // Response: // None expected - IPC_MESSAGE_ROUTED2(AutomationMsg_NavigationFailed, int, GURL) + IPC_MESSAGE_ROUTED3(AutomationMsg_NavigationFailed, int, int, GURL) #if defined(OS_WIN) // This message is an outgoing message from an automation client to Chrome. @@ -889,7 +898,9 @@ IPC_BEGIN_MESSAGES(Automation) string16 /* title text */ ) // Tab load complete - IPC_MESSAGE_ROUTED1(AutomationMsg_TabLoaded, GURL) + IPC_MESSAGE_ROUTED2(AutomationMsg_TabLoaded, + int, // tab handle + GURL) // This message requests the tabstrip index of the tab with the given handle. // The return value contains the index, which will be -1 on failure. diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index f997166..a2f8232 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -872,12 +872,13 @@ class AutomationProxyForExternalTab : public AutomationProxy { IPC_END_MESSAGE_MAP() } - void OnDidNavigate(int navigation_type, int relative_offset, + void OnDidNavigate(int tab_handle, int navigation_type, int relative_offset, const GURL& url) { navigate_complete_ = true; } - void OnForwardMessageToExternalHost(const std::string& message, + void OnForwardMessageToExternalHost(int tab_handle, + const std::string& message, const std::string& origin, const std::string& target) { messages_received_++; |