diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-05 20:00:22 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-05 20:00:22 +0000 |
commit | c88a70fe5a69daf5d3d6e0599ed273d160b55c41 (patch) | |
tree | b0c2303575c6f9d5f6d42e1716fbdc5decdd139e | |
parent | 0302e4ac5907fcdaafbf2a883b29496032c0db19 (diff) | |
download | chromium_src-c88a70fe5a69daf5d3d6e0599ed273d160b55c41.zip chromium_src-c88a70fe5a69daf5d3d6e0599ed273d160b55c41.tar.gz chromium_src-c88a70fe5a69daf5d3d6e0599ed273d160b55c41.tar.bz2 |
Plumb the creator URL for popups up to the browser. We don't yet use this for anything; it will be used for whitelisting popups by hostname.
BUG=11440
Review URL: http://codereview.chromium.org/105004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15326 0039d316-1c4b-4281-b951-d872f2087c98
19 files changed, 60 insertions, 28 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 4e5f615a..7f6bd01 100755 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -124,7 +124,8 @@ void ExtensionHost::CreateNewWidget(int route_id, bool activatable) { void ExtensionHost::ShowCreatedWindow(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, - bool user_gesture) { + bool user_gesture, + const GURL& creator_url) { TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id); if (contents) { // TODO(erikkay) is it safe to pass in NULL as source? diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index 9e90522..6a80cb4 100755 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -63,7 +63,8 @@ class ExtensionHost : public RenderViewHostDelegate, virtual void ShowCreatedWindow(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, - bool user_gesture); + bool user_gesture, + const GURL& creator_url); virtual void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos); virtual void ShowContextMenu(const ContextMenuParams& params); diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 7d19fe3..8991f5f 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -828,10 +828,13 @@ void RenderViewHost::CreateNewWidget(int route_id, bool activatable) { void RenderViewHost::OnMsgShowView(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, - bool user_gesture) { + bool user_gesture, + const GURL& creator_url) { RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); - if (view) - view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture); + if (view) { + view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture, + creator_url); + } } void RenderViewHost::OnMsgShowWidget(int route_id, diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 50b5dff..9755b50 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -431,7 +431,8 @@ class RenderViewHost : public RenderWidgetHost { void OnMsgShowView(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, - bool user_gesture); + bool user_gesture, + const GURL& creator_url); void OnMsgShowWidget(int route_id, const gfx::Rect& initial_pos); void OnMsgRunModal(IPC::Message* reply_msg); void OnMsgRenderViewReady(); diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 14a1da0..a3fe299 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -88,7 +88,8 @@ class RenderViewHostDelegate { virtual void ShowCreatedWindow(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, - bool user_gesture) = 0; + bool user_gesture, + const GURL& creator_url) = 0; // Show the newly created widget with the specified bounds. // The widget is identified by the route_id passed to CreateNewWidget. diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index 9384988..e0106aa 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -76,7 +76,8 @@ class InterstitialPage::InterstitialPageRVHViewDelegate virtual void ShowCreatedWindow(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, - bool user_gesture); + bool user_gesture, + const GURL& creator_url); virtual void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos); virtual void ShowContextMenu(const ContextMenuParams& params); @@ -473,7 +474,7 @@ void InterstitialPage::InterstitialPageRVHViewDelegate::CreateNewWidget( void InterstitialPage::InterstitialPageRVHViewDelegate::ShowCreatedWindow( int route_id, WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, bool user_gesture) { + const gfx::Rect& initial_pos, bool user_gesture, const GURL& creator_url) { NOTREACHED() << "InterstitialPage does not support showing popups yet."; } diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 3712fc4..92d5584 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -774,7 +774,8 @@ ConstrainedWindow* TabContents::CreateConstrainedDialog( void TabContents::AddNewContents(TabContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, - bool user_gesture) { + bool user_gesture, + const GURL& creator_url) { if (!delegate_) return; diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 0497fdd..cb7e589 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -332,7 +332,8 @@ class TabContents : public PageNavigator, void AddNewContents(TabContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, - bool user_gesture); + bool user_gesture, + const GURL& creator_url); // Builds a ConstrainedWindow* for the incoming |new_contents| and // adds it to child_windows_. diff --git a/chrome/browser/tab_contents/tab_contents_view.cc b/chrome/browser/tab_contents/tab_contents_view.cc index da6c894..402876d 100644 --- a/chrome/browser/tab_contents/tab_contents_view.cc +++ b/chrome/browser/tab_contents/tab_contents_view.cc @@ -35,11 +35,12 @@ void TabContentsView::CreateNewWidget(int route_id, bool activatable) { void TabContentsView::ShowCreatedWindow(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, - bool user_gesture) { + bool user_gesture, + const GURL& creator_url) { TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id); if (contents) { tab_contents()->AddNewContents(contents, disposition, initial_pos, - user_gesture); + user_gesture, creator_url); } } @@ -65,4 +66,3 @@ void TabContentsView::ShowCreatedWidgetInternal( initial_pos); widget_host_view->GetRenderWidgetHost()->Init(); } - diff --git a/chrome/browser/tab_contents/tab_contents_view.h b/chrome/browser/tab_contents/tab_contents_view.h index 1887f13..2af4902 100644 --- a/chrome/browser/tab_contents/tab_contents_view.h +++ b/chrome/browser/tab_contents/tab_contents_view.h @@ -154,7 +154,8 @@ class TabContentsView : public RenderViewHostDelegate::View { virtual void ShowCreatedWindow(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, - bool user_gesture); + bool user_gesture, + const GURL& creator_url); virtual void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos); // The TabContents whose contents we display. diff --git a/chrome/browser/views/blocked_popup_container.cc b/chrome/browser/views/blocked_popup_container.cc index 37b42f3..4fa0505 100644 --- a/chrome/browser/views/blocked_popup_container.cc +++ b/chrome/browser/views/blocked_popup_container.cc @@ -285,7 +285,7 @@ void BlockedPopupContainer::LaunchPopupIndex(int index) { // Pass this TabContents back to our owner, forcing the window to be // displayed since user_gesture is true. - owner_->AddNewContents(contents, NEW_POPUP, bounds, true); + owner_->AddNewContents(contents, NEW_POPUP, bounds, true, GURL()); } if (blocked_popups_.size() == 0) @@ -357,7 +357,7 @@ void BlockedPopupContainer::AddNewContents(TabContents* source, const gfx::Rect& initial_position, bool user_gesture) { owner_->AddNewContents(new_contents, disposition, initial_position, - user_gesture); + user_gesture, GURL()); } void BlockedPopupContainer::CloseContents(TabContents* source) { diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index c78897b..a74e54b 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -606,11 +606,12 @@ IPC_BEGIN_MESSAGES(ViewHost) // // FUTURE: there will probably be flags here to control if the result is // in a new window. - IPC_MESSAGE_ROUTED4(ViewHostMsg_ShowView, + IPC_MESSAGE_ROUTED5(ViewHostMsg_ShowView, int /* route_id */, WindowOpenDisposition /* disposition */, gfx::Rect /* initial_pos */, - bool /* opened_by_user_gesture */) + bool /* opened_by_user_gesture */, + GURL /* creator_url */) IPC_MESSAGE_ROUTED2(ViewHostMsg_ShowWidget, int /* route_id */, diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 6664d1c..e0b661e 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1773,7 +1773,9 @@ void RenderView::DebuggerOutput(const std::wstring& out) { Send(new ViewHostMsg_DebuggerOutput(routing_id_, out)); } -WebView* RenderView::CreateWebView(WebView* webview, bool user_gesture) { +WebView* RenderView::CreateWebView(WebView* webview, + bool user_gesture, + const GURL& creator_url) { // Check to make sure we aren't overloading on popups. if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) return NULL; @@ -1805,6 +1807,7 @@ WebView* RenderView::CreateWebView(WebView* webview, bool user_gesture) { prefs, shared_popup_counter_, routing_id); view->opened_by_user_gesture_ = user_gesture; + view->creator_url_ = creator_url; // Copy over the alternate error page URL so we can have alt error pages in // the new render view (we don't need the browser to send the URL back down). @@ -1949,7 +1952,7 @@ void RenderView::Show(WebWidget* webwidget, WindowOpenDisposition disposition) { // that's okay. It'll be ignored if disposition is not NEW_POPUP, or the // browser process will impose a default position otherwise. Send(new ViewHostMsg_ShowView(opener_id_, routing_id_, disposition, - initial_pos_, opened_by_user_gesture_)); + initial_pos_, opened_by_user_gesture_, creator_url_)); } void RenderView::CloseWidgetSoon(WebWidget* webwidget) { diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 65fca92..8c34769 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -233,7 +233,9 @@ class RenderView : public RenderWidget, WindowOpenDisposition disposition, bool is_redirect); - virtual WebView* CreateWebView(WebView* webview, bool user_gesture); + virtual WebView* CreateWebView(WebView* webview, + bool user_gesture, + const GURL& creator_url); virtual WebWidget* CreatePopupWidget(WebView* webview, bool activatable); virtual WebPluginDelegate* CreatePluginDelegate( WebView* webview, @@ -684,6 +686,7 @@ class RenderView : public RenderWidget, // Used for popups. bool opened_by_user_gesture_; + GURL creator_url_; // The alternate error page URL, if one exists. GURL alternate_error_page_url_; diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc index 9a823a9..e410805 100644 --- a/webkit/glue/chrome_client_impl.cc +++ b/webkit/glue/chrome_client_impl.cc @@ -9,6 +9,7 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "Console.h" #include "Cursor.h" +#include "DocumentLoader.h" #include "FloatRect.h" #include "FileChooser.h" #include "FrameLoadRequest.h" @@ -170,8 +171,14 @@ WebCore::Page* ChromeClientImpl::createWindow( return NULL; bool user_gesture = frame->script()->processingUserGesture(); + + const std::string security_origin(webkit_glue::StringToStdString( + frame->document()->securityOrigin()->toString())); + GURL creator_url(security_origin); WebViewImpl* new_view = static_cast<WebViewImpl*>( - delegate->CreateWebView(webview_, user_gesture)); + delegate->CreateWebView(webview_, user_gesture, + (creator_url.is_valid() && creator_url.IsStandard()) ? + creator_url : GURL())); if (!new_view) return NULL; diff --git a/webkit/glue/inspector_client_impl.cc b/webkit/glue/inspector_client_impl.cc index ae6a57e..1ddae85 100644 --- a/webkit/glue/inspector_client_impl.cc +++ b/webkit/glue/inspector_client_impl.cc @@ -62,7 +62,7 @@ Page* WebInspectorClient::createPage() { if (!delegate) return NULL; inspector_web_view_ = static_cast<WebViewImpl*>( - delegate->CreateWebView(inspected_web_view_, true)); + delegate->CreateWebView(inspected_web_view_, true, GURL())); if (!inspector_web_view_) return NULL; diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 29c31be..dbaf3b8 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -99,8 +99,12 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // made visible until the new WebView's Delegate has its Show method called. // The returned WebView pointer is assumed to be owned by the host window, // and the caller of CreateWebView should not release the given WebView. - // user_gesture is true if a user action initiated this call. - virtual WebView* CreateWebView(WebView* webview, bool user_gesture) { + // |user_gesture| is true if a user action initiated this call. + // |creator_url|, if nonempty, holds the security origin of the page creating + // this WebView. + virtual WebView* CreateWebView(WebView* webview, + bool user_gesture, + const GURL& creator_url) { return NULL; } diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 4bf5601..93d498c 100755 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -105,7 +105,8 @@ const char* WebNavigationTypeToString(WebNavigationType type) { // WebViewDelegate ----------------------------------------------------------- WebView* TestWebViewDelegate::CreateWebView(WebView* webview, - bool user_gesture) { + bool user_gesture, + const GURL& creator_url) { return shell_->CreateWebView(webview); } diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 79fd25d..0c5ef3b 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -77,7 +77,9 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, virtual ~TestWebViewDelegate(); // WebViewDelegate - virtual WebView* CreateWebView(WebView* webview, bool user_gesture); + virtual WebView* CreateWebView(WebView* webview, + bool user_gesture, + const GURL& creator_url); virtual WebWidget* CreatePopupWidget(WebView* webview, bool activatable); virtual WebPluginDelegate* CreatePluginDelegate( WebView* webview, |