diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-06 19:25:58 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-06 19:25:58 +0000 |
commit | ae5184d682c302981920f45b580b5a306fc957f9 (patch) | |
tree | 5374e7d63121d44649ab87f3a1c4571bb0ed33ba /content/browser | |
parent | 7bc551f6363486b7ea6f004d1404304f7f69a7e0 (diff) | |
download | chromium_src-ae5184d682c302981920f45b580b5a306fc957f9.zip chromium_src-ae5184d682c302981920f45b580b5a306fc957f9.tar.gz chromium_src-ae5184d682c302981920f45b580b5a306fc957f9.tar.bz2 |
Hook into another code path that lets the renderer request a new tab to be created
BUG=96877
TEST=browser_tests:ExtensionApiTest.WebNavigationRequestOpenTab
Review URL: http://codereview.chromium.org/8055011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104346 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
7 files changed, 48 insertions, 11 deletions
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index c797151..f2b1a76 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -951,12 +951,14 @@ void RenderViewHost::OnMsgToggleFullscreen(bool enter_fullscreen) { void RenderViewHost::OnMsgOpenURL(const GURL& url, const GURL& referrer, - WindowOpenDisposition disposition) { + WindowOpenDisposition disposition, + int64 source_frame_id) { GURL validated_url(url); FilterURL(ChildProcessSecurityPolicy::GetInstance(), process()->id(), &validated_url); - delegate_->RequestOpenURL(validated_url, referrer, disposition); + delegate_->RequestOpenURL( + validated_url, referrer, disposition, source_frame_id); } void RenderViewHost::OnMsgDidContentsPreferredSizeChange( diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h index ef541c8..d29b8e4 100644 --- a/content/browser/renderer_host/render_view_host.h +++ b/content/browser/renderer_host/render_view_host.h @@ -490,8 +490,10 @@ class CONTENT_EXPORT RenderViewHost : public RenderWidgetHost { void OnMsgDocumentOnLoadCompletedInMainFrame(int32 page_id); void OnMsgContextMenu(const ContextMenuParams& params); void OnMsgToggleFullscreen(bool enter_fullscreen); - void OnMsgOpenURL(const GURL& url, const GURL& referrer, - WindowOpenDisposition disposition); + void OnMsgOpenURL(const GURL& url, + const GURL& referrer, + WindowOpenDisposition disposition, + int64 source_frame_id); void OnMsgDidContentsPreferredSizeChange(const gfx::Size& new_size); void OnMsgDidChangeScrollbarsForMainFrame(bool has_horizontal_scrollbar, bool has_vertical_scrollbar); diff --git a/content/browser/renderer_host/render_view_host_delegate.h b/content/browser/renderer_host/render_view_host_delegate.h index 65bb4ac..c86dc34 100644 --- a/content/browser/renderer_host/render_view_host_delegate.h +++ b/content/browser/renderer_host/render_view_host_delegate.h @@ -283,7 +283,8 @@ class CONTENT_EXPORT RenderViewHostDelegate : public IPC::Channel::Listener { // The page wants to open a URL with the specified disposition. virtual void RequestOpenURL(const GURL& url, const GURL& referrer, - WindowOpenDisposition disposition) {} + WindowOpenDisposition disposition, + int64 source_frame_id) {} // A javascript message, confirmation or prompt should be shown. virtual void RunJavaScriptMessage(const RenderViewHost* rvh, diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 2d3cf8d..5d809cc 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -1675,8 +1675,12 @@ void TabContents::DocumentOnLoadCompletedInMainFrame( Details<int>(&page_id)); } -void TabContents::RequestOpenURL(const GURL& url, const GURL& referrer, - WindowOpenDisposition disposition) { +void TabContents::RequestOpenURL(const GURL& url, + const GURL& referrer, + WindowOpenDisposition disposition, + int64 source_frame_id) { + TabContents* new_contents = NULL; + PageTransition::Type transition_type = PageTransition::LINK; if (render_manager_.web_ui()) { // When we're a Web UI, it will provide a page transition type for us (this // is so the new tab page can specify AUTO_BOOKMARK for automatically @@ -1686,10 +1690,21 @@ void TabContents::RequestOpenURL(const GURL& url, const GURL& referrer, // want web sites to see a referrer of "chrome://blah" (and some // chrome: URLs might have search terms or other stuff we don't want to // send to the site), so we send no referrer. - OpenURL(url, GURL(), disposition, + new_contents = OpenURL(url, GURL(), disposition, render_manager_.web_ui()->link_transition_type()); + transition_type = render_manager_.web_ui()->link_transition_type(); } else { - OpenURL(url, referrer, disposition, PageTransition::LINK); + new_contents = OpenURL(url, referrer, disposition, PageTransition::LINK); + } + if (new_contents) { + // Notify observers. + FOR_EACH_OBSERVER(TabContentsObserver, observers_, + DidOpenRequestedURL(new_contents, + url, + referrer, + disposition, + transition_type, + source_frame_id)); } } diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index acdefbc..8262c95 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -655,8 +655,10 @@ class CONTENT_EXPORT TabContents : public PageNavigator, virtual void DocumentOnLoadCompletedInMainFrame( RenderViewHost* render_view_host, int32 page_id) OVERRIDE; - virtual void RequestOpenURL(const GURL& url, const GURL& referrer, - WindowOpenDisposition disposition) OVERRIDE; + virtual void RequestOpenURL(const GURL& url, + const GURL& referrer, + WindowOpenDisposition disposition, + int64 source_frame_id) OVERRIDE; virtual void RunJavaScriptMessage(const RenderViewHost* rvh, const string16& message, const string16& default_prompt, diff --git a/content/browser/tab_contents/tab_contents_observer.cc b/content/browser/tab_contents/tab_contents_observer.cc index f3b5af5..fa5ff3c 100644 --- a/content/browser/tab_contents/tab_contents_observer.cc +++ b/content/browser/tab_contents/tab_contents_observer.cc @@ -85,6 +85,14 @@ void TabContentsObserver::DidOpenURL(const GURL& url, PageTransition::Type transition) { } +void TabContentsObserver::DidOpenRequestedURL(TabContents* new_contents, + const GURL& url, + const GURL& referrer, + WindowOpenDisposition disposition, + PageTransition::Type transition, + int64 source_frame_id) { +} + void TabContentsObserver::AppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy) { } diff --git a/content/browser/tab_contents/tab_contents_observer.h b/content/browser/tab_contents/tab_contents_observer.h index 3d922c1..fdc157d 100644 --- a/content/browser/tab_contents/tab_contents_observer.h +++ b/content/browser/tab_contents/tab_contents_observer.h @@ -64,6 +64,13 @@ class CONTENT_EXPORT TabContentsObserver : public IPC::Channel::Listener, WindowOpenDisposition disposition, PageTransition::Type transition); + virtual void DidOpenRequestedURL(TabContents* new_contents, + const GURL& url, + const GURL& referrer, + WindowOpenDisposition disposition, + PageTransition::Type transition, + int64 source_frame_id); + virtual void AppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy); #if 0 |