diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-03 07:57:44 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-03 07:57:44 +0000 |
commit | 4adf556dec57f4a937a3a03b9b3a3d9ffdf7a49e (patch) | |
tree | 7425f8ca3a9411f5b07a408253b951ff320aef1f /webkit/glue/webplugin_impl.cc | |
parent | 3d248b2db2eae7c805ada987f997caa0929700c7 (diff) | |
download | chromium_src-4adf556dec57f4a937a3a03b9b3a3d9ffdf7a49e.zip chromium_src-4adf556dec57f4a937a3a03b9b3a3d9ffdf7a49e.tar.gz chromium_src-4adf556dec57f4a937a3a03b9b3a3d9ffdf7a49e.tar.bz2 |
Don't set referrers on outgoing plugin requests if the load_manually flag is set. This emulates the
behavior of other browsers and fixes http://code.google.com/p/chromium/issues/detail?id=28800
I added a UI test to validate that the plugin source URL is set on outgoing GetURL requests issued
by the plugin. To validate that the document URL is set as the referrer on the initial URL request
would take some more work. Will try and add that in a future CL.
I also changed the WebPluginImpl::RouteToFrame function to set the referrer on similar lines.
Bug=28800
Test=Covered by UI test
Review URL: http://codereview.chromium.org/459003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33673 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webplugin_impl.cc')
-rw-r--r-- | webkit/glue/webplugin_impl.cc | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index a42fd70..c0c035d 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -481,7 +481,8 @@ WebPluginImpl::RoutingStatus WebPluginImpl::RouteToFrame( bool is_file_data, bool notify_needed, intptr_t notify_data, - const char* url) { + const char* url, + Referrer referrer_flag) { // If there is no target, there is nothing to do if (!target) return NOT_ROUTED; @@ -524,6 +525,8 @@ WebPluginImpl::RoutingStatus WebPluginImpl::RouteToFrame( } WebURLRequest request(complete_url); + SetReferrer(&request, referrer_flag); + request.setHTTPMethod(WebString::fromUTF8(method)); if (len > 0) { if (!is_file_data) { @@ -597,7 +600,7 @@ void WebPluginImpl::InvalidateRect(const gfx::Rect& rect) { void WebPluginImpl::OnDownloadPluginSrcUrl() { HandleURLRequestInternal("GET", false, NULL, 0, NULL, false, false, plugin_url_.spec().c_str(), NULL, false, - false); + DOCUMENT_URL); } WebPluginResourceClient* WebPluginImpl::GetClientFromLoader( @@ -813,16 +816,18 @@ void WebPluginImpl::HandleURLRequest(const char *method, const char* buf, bool is_file_data, bool notify, const char* url, intptr_t notify_data, bool popups_allowed) { + // GetURL/PostURL requests initiated explicitly by plugins should specify the + // plugin SRC url as the referrer if it is available. HandleURLRequestInternal(method, is_javascript_url, target, len, buf, is_file_data, notify, url, notify_data, - popups_allowed, true); + popups_allowed, PLUGIN_SRC); } void WebPluginImpl::HandleURLRequestInternal( const char *method, bool is_javascript_url, const char* target, unsigned int len, const char* buf, bool is_file_data, bool notify, const char* url, intptr_t notify_data, bool popups_allowed, - bool use_plugin_src_as_referrer) { + Referrer referrer_flag) { // For this request, we either route the output to a frame // because a target has been specified, or we handle the request // here, i.e. by executing the script if it is a javascript url @@ -832,7 +837,7 @@ void WebPluginImpl::HandleURLRequestInternal( // to the plugin's frame. RoutingStatus routing_status = RouteToFrame(method, is_javascript_url, target, len, buf, is_file_data, - notify, notify_data, url); + notify, notify_data, url, referrer_flag); if (routing_status == ROUTED) return; @@ -873,7 +878,7 @@ void WebPluginImpl::HandleURLRequestInternal( return; InitiateHTTPRequest(resource_id, resource_client, method, buf, len, - complete_url, NULL, use_plugin_src_as_referrer); + complete_url, NULL, referrer_flag); } } @@ -892,7 +897,7 @@ bool WebPluginImpl::InitiateHTTPRequest(unsigned long resource_id, int buf_len, const GURL& url, const char* range_info, - bool use_plugin_src_as_referrer) { + Referrer referrer_flag) { if (!client) { NOTREACHED(); return false; @@ -919,12 +924,7 @@ bool WebPluginImpl::InitiateHTTPRequest(unsigned long resource_id, SetPostData(&info.request, buf, buf_len); } - // GetURL/PostURL requests initiated explicitly by plugins should specify the - // plugin SRC url as the referrer if it is available. - GURL referrer_url; - if (use_plugin_src_as_referrer && !plugin_url_.spec().empty()) - referrer_url = plugin_url_; - webframe_->setReferrerForRequest(info.request, referrer_url); + SetReferrer(&info.request, referrer_flag); // Sets the routing id to associate the ResourceRequest with the RenderView. webframe_->dispatchWillSendRequest(info.request); @@ -965,7 +965,7 @@ void WebPluginImpl::InitiateHTTPRangeRequest(const char* url, resource_id, complete_url, notify_needed, notify_data, existing_stream); InitiateHTTPRequest( resource_id, resource_client, "GET", NULL, 0, complete_url, range_info, - true); + load_manually_ ? NO_REFERRER : PLUGIN_SRC); } void WebPluginImpl::SetDeferResourceLoading(unsigned long resource_id, @@ -1106,4 +1106,20 @@ void WebPluginImpl::TearDownPluginInstance( method_factory_.RevokeAll(); } +void WebPluginImpl::SetReferrer(WebKit::WebURLRequest* request, + Referrer referrer_flag) { + switch (referrer_flag) { + case DOCUMENT_URL: + webframe_->setReferrerForRequest(*request, GURL()); + break; + + case PLUGIN_SRC: + webframe_->setReferrerForRequest(*request, plugin_url_); + break; + + default: + break; + } +} + } // namespace webkit_glue |