diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-22 18:15:34 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-22 18:15:34 +0000 |
commit | 5951b5c1c74422be6793df444364f2f5436685ff (patch) | |
tree | cb424f37692a95576cd314cb8bc9dc8e6b844c88 /chrome | |
parent | 750d1df01bae3a105313008e649d6a8e756bc316 (diff) | |
download | chromium_src-5951b5c1c74422be6793df444364f2f5436685ff.zip chromium_src-5951b5c1c74422be6793df444364f2f5436685ff.tar.gz chromium_src-5951b5c1c74422be6793df444364f2f5436685ff.tar.bz2 |
Initial HTTP requests issued by ChromeFrame popups could bypass the host network stack. The host network
stack in ChromeFrame intercepts HTTP requests based on registered render views. When a popup window is created
we register it in the AddNewContents notification on the TabContentsDelegate. This is a little late as network
requests could be issued before the view actually becomes visible.
To fix this we now have a new method in the TabContentsDelegate interface called TabContentsCreated which
notifies the delegate about the creation of a new TabContents. The ExternalTabContainer implements this
method and registers the render view as pending. I also changed the signature of the
RenderViewHostDelegateViewHelper::CreateNewWindow method to return the new TabContents.
As part of this fix we also unregister the render view when the ExternalTabContainer is deleted. The
container registers for the NotificationType::RENDER_VIEW_HOST_DELETED notification. However we end up
deleting the TabContents in WM_DESTROY, which results in the container never receiving this notification.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=36323
Bug=36323
Test=Will be covered by the automation proxy test which Stoyan is adding
Review URL: http://codereview.chromium.org/652009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39611 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
6 files changed, 37 insertions, 20 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index 0abba3b..55e8846 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -163,8 +163,12 @@ void ExternalTabContainer::Uninitialize() { registrar_.RemoveAll(); if (tab_contents_) { RenderViewHost* rvh = tab_contents_->render_view_host(); - if (rvh && DevToolsManager::GetInstance()) { - DevToolsManager::GetInstance()->UnregisterDevToolsClientHostFor(rvh); + if (rvh) { + if (DevToolsManager::GetInstance()) + DevToolsManager::GetInstance()->UnregisterDevToolsClientHostFor(rvh); + + AutomationResourceMessageFilter::UnRegisterRenderView( + rvh->process()->id(), rvh->routing_id()); } NotificationService::current()->Notify( @@ -351,17 +355,6 @@ void ExternalTabContainer::AddNewContents(TabContents* source, new_container->set_pending(true); - RenderViewHost* rvh = new_contents->render_view_host(); - DCHECK(rvh != NULL); - if (rvh) { - // Register this render view as a pending render view, i.e. any network - // requests initiated by this render view would be serviced when the - // external host connects to the new external tab instance. - AutomationResourceMessageFilter::RegisterRenderView( - rvh->process()->id(), rvh->routing_id(), - tab_handle_, automation_resource_message_filter_, - true); - } automation_->Send(new AutomationMsg_AttachExternalTab( 0, tab_handle_, @@ -372,6 +365,20 @@ void ExternalTabContainer::AddNewContents(TabContents* source, } } +void ExternalTabContainer::TabContentsCreated(TabContents* new_contents) { + RenderViewHost* rvh = new_contents->render_view_host(); + DCHECK(rvh != NULL); + if (rvh) { + // Register this render view as a pending render view, i.e. any network + // requests initiated by this render view would be serviced when the + // external host connects to the new external tab instance. + AutomationResourceMessageFilter::RegisterRenderView( + rvh->process()->id(), rvh->routing_id(), + tab_handle_, automation_resource_message_filter_, + true); + } +} + void ExternalTabContainer::ActivateContents(TabContents* contents) { } diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h index 154d258..d3d8625 100644 --- a/chrome/browser/external_tab_container.h +++ b/chrome/browser/external_tab_container.h @@ -196,6 +196,8 @@ class ExternalTabContainer : public TabContentsDelegate, // InfoBarContainer::Delegate overrides virtual void InfoBarSizeChanged(bool is_animating); + virtual void TabContentsCreated(TabContents* new_contents); + protected: // Overridden from views::WidgetWin: virtual LRESULT OnCreate(LPCREATESTRUCT create_struct); diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc index a69d1f1..084e571 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -20,7 +20,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" -void RenderViewHostDelegateViewHelper::CreateNewWindow( +TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow( int route_id, Profile* profile, SiteInstance* site, @@ -42,6 +42,7 @@ void RenderViewHostDelegateViewHelper::CreateNewWindow( // Save the created window associated with the route so we can show it later. pending_contents_[route_id] = new_contents; + return new_contents; } RenderWidgetHostView* RenderViewHostDelegateViewHelper::CreateNewWidget( diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.h b/chrome/browser/tab_contents/render_view_host_delegate_helper.h index 21ce783..5078858 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.h +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.h @@ -30,11 +30,11 @@ class RenderViewHostDelegateViewHelper { public: RenderViewHostDelegateViewHelper() {} - virtual void CreateNewWindow(int route_id, - Profile* profile, - SiteInstance* site, - DOMUITypeID domui_type, - TabContents* old_tab_contents); + virtual TabContents* CreateNewWindow(int route_id, + Profile* profile, + SiteInstance* site, + DOMUITypeID domui_type, + TabContents* old_tab_contents); virtual RenderWidgetHostView* CreateNewWidget(int route_id, bool activatable, RenderProcessHost* process); virtual TabContents* GetCreatedWindow(int route_id); diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h index e2b00b5..a6ddbd1 100644 --- a/chrome/browser/tab_contents/tab_contents_delegate.h +++ b/chrome/browser/tab_contents/tab_contents_delegate.h @@ -278,6 +278,10 @@ class TabContentsDelegate { // Returns the native window framing the view containing the tab contents. virtual gfx::NativeWindow GetFrameNativeWindow() { return NULL; } + // Notifies the delegate about the creation of a new TabContents. This + // typically happens when popups are created. + virtual void TabContentsCreated(TabContents* new_contents) {} + protected: ~TabContentsDelegate() {} }; diff --git a/chrome/browser/tab_contents/tab_contents_view.cc b/chrome/browser/tab_contents/tab_contents_view.cc index 4d25c33..fc5455e 100644 --- a/chrome/browser/tab_contents/tab_contents_view.cc +++ b/chrome/browser/tab_contents/tab_contents_view.cc @@ -31,9 +31,12 @@ void TabContentsView::UpdatePreferredSize(const gfx::Size& pref_size) { } void TabContentsView::CreateNewWindow(int route_id) { - delegate_view_helper_.CreateNewWindow( + TabContents* new_contents = delegate_view_helper_.CreateNewWindow( route_id, tab_contents_->profile(), tab_contents_->GetSiteInstance(), DOMUIFactory::GetDOMUIType(tab_contents_->GetURL()), tab_contents_); + + if (tab_contents_->delegate()) + tab_contents_->delegate()->TabContentsCreated(new_contents); } void TabContentsView::CreateNewWidget(int route_id, bool activatable) { |