diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-19 23:41:24 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-19 23:41:24 +0000 |
commit | 2d09a70aeb1e05dfc0a4665e86bb368056531f05 (patch) | |
tree | b2bd9227020e0b287b68959808e2cf4ae0314f90 | |
parent | 15d8aa7891a36577e6022e14d4c0b468a2b30f4c (diff) | |
download | chromium_src-2d09a70aeb1e05dfc0a4665e86bb368056531f05.zip chromium_src-2d09a70aeb1e05dfc0a4665e86bb368056531f05.tar.gz chromium_src-2d09a70aeb1e05dfc0a4665e86bb368056531f05.tar.bz2 |
Fix chrome.webRequest.onBeforeRequest for requests coming from NPAPI plugin processes.
BUG=332481
R=jochen@chromium.org
Review URL: https://codereview.chromium.org/132233022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245847 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/api/web_request/web_request_api.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_renderer_state.cc | 13 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_renderer_state.h | 10 | ||||
-rw-r--r-- | content/browser/loader/resource_loader.cc | 2 | ||||
-rw-r--r-- | content/browser/loader/resource_request_info_impl.cc | 4 | ||||
-rw-r--r-- | content/browser/loader/resource_request_info_impl.h | 1 | ||||
-rw-r--r-- | content/child/npapi/plugin_url_fetcher.cc | 21 | ||||
-rw-r--r-- | content/child/npapi/plugin_url_fetcher.h | 1 | ||||
-rw-r--r-- | content/child/npapi/webplugin_delegate.h | 3 | ||||
-rw-r--r-- | content/child/npapi/webplugin_delegate_impl.cc | 5 | ||||
-rw-r--r-- | content/child/npapi/webplugin_delegate_impl.h | 3 | ||||
-rw-r--r-- | content/plugin/webplugin_delegate_stub.cc | 3 | ||||
-rw-r--r-- | content/public/browser/resource_request_info.h | 3 | ||||
-rw-r--r-- | content/renderer/npapi/webplugin_delegate_proxy.cc | 3 | ||||
-rw-r--r-- | content/renderer/npapi/webplugin_delegate_proxy.h | 3 | ||||
-rw-r--r-- | content/renderer/npapi/webplugin_impl.cc | 3 |
16 files changed, 64 insertions, 16 deletions
diff --git a/chrome/browser/extensions/api/web_request/web_request_api.cc b/chrome/browser/extensions/api/web_request/web_request_api.cc index cf2927e..1aeaab8 100644 --- a/chrome/browser/extensions/api/web_request/web_request_api.cc +++ b/chrome/browser/extensions/api/web_request/web_request_api.cc @@ -177,7 +177,7 @@ void ExtractRequestInfoDetails(net::URLRequest* request, const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); ExtensionRendererState::GetInstance()->GetTabAndWindowId( - info->GetChildID(), info->GetRouteID(), tab_id, window_id); + info, tab_id, window_id); *frame_id = info->GetFrameID(); *is_main_frame = info->IsMainFrame(); *parent_frame_id = info->GetParentFrameID(); diff --git a/chrome/browser/extensions/extension_renderer_state.cc b/chrome/browser/extensions/extension_renderer_state.cc index b483abe..bb3621a 100644 --- a/chrome/browser/extensions/extension_renderer_state.cc +++ b/chrome/browser/extensions/extension_renderer_state.cc @@ -17,8 +17,10 @@ #include "content/public/browser/notification_types.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" +#include "content/public/browser/resource_request_info.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" +#include "content/public/common/process_type.h" using content::BrowserThread; using content::RenderProcessHost; @@ -200,9 +202,16 @@ void ExtensionRendererState::ClearTabAndWindowId( } bool ExtensionRendererState::GetTabAndWindowId( - int render_process_host_id, int routing_id, int* tab_id, int* window_id) { + const content::ResourceRequestInfo* info, int* tab_id, int* window_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - RenderId render_id(render_process_host_id, routing_id); + int render_process_id; + if (info->GetProcessType() == content::PROCESS_TYPE_PLUGIN) { + render_process_id = info->GetOriginPID(); + } else { + render_process_id = info->GetChildID(); + } + int render_view_id = info->GetRouteID(); + RenderId render_id(render_process_id, render_view_id); TabAndWindowIdMap::iterator iter = map_.find(render_id); if (iter != map_.end()) { *tab_id = iter->second.first; diff --git a/chrome/browser/extensions/extension_renderer_state.h b/chrome/browser/extensions/extension_renderer_state.h index a462b80..a47c5b5 100644 --- a/chrome/browser/extensions/extension_renderer_state.h +++ b/chrome/browser/extensions/extension_renderer_state.h @@ -15,6 +15,10 @@ class WebViewGuest; +namespace content { +class ResourceRequestInfo; +} + // This class keeps track of renderer state for use on the IO thread. All // methods should be called on the IO thread except for Init and Shutdown. class ExtensionRendererState { @@ -39,10 +43,10 @@ class ExtensionRendererState { bool GetWebViewInfo(int guest_process_id, int guest_routing_id, WebViewInfo* webview_info); - // Looks up the tab and window ID for a given render view. Returns true - // if we have the IDs in our map. Called on the IO thread. + // Looks up the tab and window ID for a given request. Returns true if we have + // the IDs in our map. Called on the IO thread. bool GetTabAndWindowId( - int render_process_host_id, int routing_id, int* tab_id, int* window_id); + const content::ResourceRequestInfo* info, int* tab_id, int* window_id); // Returns true if the given renderer is used by webviews. bool IsWebViewRenderer(int render_process_id); diff --git a/content/browser/loader/resource_loader.cc b/content/browser/loader/resource_loader.cc index c87c280..97017da 100644 --- a/content/browser/loader/resource_loader.cc +++ b/content/browser/loader/resource_loader.cc @@ -200,7 +200,7 @@ void ResourceLoader::OnReceivedRedirect(net::URLRequest* unused, ResourceRequestInfoImpl* info = GetRequestInfo(); - if (info->process_type() != PROCESS_TYPE_PLUGIN && + if (info->GetProcessType() != PROCESS_TYPE_PLUGIN && !ChildProcessSecurityPolicyImpl::GetInstance()-> CanRequestURL(info->GetChildID(), new_url)) { VLOG(1) << "Denied unauthorized request for " diff --git a/content/browser/loader/resource_request_info_impl.cc b/content/browser/loader/resource_request_info_impl.cc index 97d55ba..065b4f6 100644 --- a/content/browser/loader/resource_request_info_impl.cc +++ b/content/browser/loader/resource_request_info_impl.cc @@ -182,6 +182,10 @@ ResourceType::Type ResourceRequestInfoImpl::GetResourceType() const { return resource_type_; } +int ResourceRequestInfoImpl::GetProcessType() const { + return process_type_; +} + blink::WebReferrerPolicy ResourceRequestInfoImpl::GetReferrerPolicy() const { return referrer_policy_; } diff --git a/content/browser/loader/resource_request_info_impl.h b/content/browser/loader/resource_request_info_impl.h index 4d53779..e007424 100644 --- a/content/browser/loader/resource_request_info_impl.h +++ b/content/browser/loader/resource_request_info_impl.h @@ -75,6 +75,7 @@ class ResourceRequestInfoImpl : public ResourceRequestInfo, virtual bool ParentIsMainFrame() const OVERRIDE; virtual int64 GetParentFrameID() const OVERRIDE; virtual ResourceType::Type GetResourceType() const OVERRIDE; + virtual int GetProcessType() const OVERRIDE; virtual blink::WebReferrerPolicy GetReferrerPolicy() const OVERRIDE; virtual PageTransition GetPageTransition() const OVERRIDE; virtual bool HasUserGesture() const OVERRIDE; diff --git a/content/child/npapi/plugin_url_fetcher.cc b/content/child/npapi/plugin_url_fetcher.cc index 2dd4761..ef4156c 100644 --- a/content/child/npapi/plugin_url_fetcher.cc +++ b/content/child/npapi/plugin_url_fetcher.cc @@ -12,6 +12,7 @@ #include "content/child/npapi/plugin_stream_url.h" #include "content/child/npapi/webplugin_resource_client.h" #include "content/child/plugin_messages.h" +#include "content/child/request_extra_data.h" #include "content/child/resource_dispatcher.h" #include "net/base/load_flags.h" #include "net/base/net_errors.h" @@ -81,6 +82,7 @@ PluginURLFetcher::PluginURLFetcher(PluginStreamUrl* plugin_stream, bool is_plugin_src_load, int origin_pid, int render_frame_id, + int render_view_id, unsigned long resource_id, bool copy_stream_data) : plugin_stream_(plugin_stream), @@ -102,7 +104,24 @@ PluginURLFetcher::PluginURLFetcher(PluginStreamUrl* plugin_stream, request_info.load_flags = net::LOAD_NORMAL; request_info.requestor_pid = origin_pid; request_info.request_type = ResourceType::OBJECT; - request_info.routing_id = render_frame_id; + request_info.routing_id = render_view_id; + + RequestExtraData extra_data(blink::WebReferrerPolicyDefault, + base::string16(), + false, + render_frame_id, + false, + -1, + GURL(), + false, + -1, + true, + PAGE_TRANSITION_LINK, + false, + -1, + -1); + + request_info.extra_data = &extra_data; std::vector<char> body; if (method == "POST") { diff --git a/content/child/npapi/plugin_url_fetcher.h b/content/child/npapi/plugin_url_fetcher.h index 53f9f19..2a0a10d 100644 --- a/content/child/npapi/plugin_url_fetcher.h +++ b/content/child/npapi/plugin_url_fetcher.h @@ -33,6 +33,7 @@ class PluginURLFetcher : public webkit_glue::ResourceLoaderBridge::Peer { bool is_plugin_src_load, int origin_pid, int render_frame_id, + int render_view_id, unsigned long resource_id, bool copy_stream_data); virtual ~PluginURLFetcher(); diff --git a/content/child/npapi/webplugin_delegate.h b/content/child/npapi/webplugin_delegate.h index 0a647be..f8502c5 100644 --- a/content/child/npapi/webplugin_delegate.h +++ b/content/child/npapi/webplugin_delegate.h @@ -142,7 +142,8 @@ class WebPluginDelegate { bool notify_redirects, bool is_plugin_src_load, int origin_pid, - int render_frame_id) = 0; + int render_frame_id, + int render_view_id) = 0; }; diff --git a/content/child/npapi/webplugin_delegate_impl.cc b/content/child/npapi/webplugin_delegate_impl.cc index 0fe49b9..4d98941 100644 --- a/content/child/npapi/webplugin_delegate_impl.cc +++ b/content/child/npapi/webplugin_delegate_impl.cc @@ -314,7 +314,8 @@ void WebPluginDelegateImpl::FetchURL(unsigned long resource_id, bool notify_redirects, bool is_plugin_src_load, int origin_pid, - int render_frame_id) { + int render_frame_id, + int render_view_id) { // TODO(jam): once we switch over to resource loading always happening in this // code path, remove WebPluginResourceClient abstraction. PluginStreamUrl* plugin_stream = instance()->CreateStream( @@ -324,7 +325,7 @@ void WebPluginDelegateImpl::FetchURL(unsigned long resource_id, plugin_stream->SetPluginURLFetcher(new PluginURLFetcher( plugin_stream, url, first_party_for_cookies, method, buf, len, referrer, notify_redirects, is_plugin_src_load, origin_pid, - render_frame_id, resource_id, copy_stream_data)); + render_frame_id, render_view_id, resource_id, copy_stream_data)); } } // namespace content diff --git a/content/child/npapi/webplugin_delegate_impl.h b/content/child/npapi/webplugin_delegate_impl.h index c52a394..6f9248c 100644 --- a/content/child/npapi/webplugin_delegate_impl.h +++ b/content/child/npapi/webplugin_delegate_impl.h @@ -129,7 +129,8 @@ class WebPluginDelegateImpl : public WebPluginDelegate { bool notify_redirects, bool is_plugin_src_load, int origin_pid, - int render_frame_id) OVERRIDE; + int render_frame_id, + int render_view_id) OVERRIDE; // End of WebPluginDelegate implementation. gfx::PluginWindowHandle windowed_handle() const { return windowed_handle_; } diff --git a/content/plugin/webplugin_delegate_stub.cc b/content/plugin/webplugin_delegate_stub.cc index 4866e06..813f5f3 100644 --- a/content/plugin/webplugin_delegate_stub.cc +++ b/content/plugin/webplugin_delegate_stub.cc @@ -442,7 +442,8 @@ void WebPluginDelegateStub::OnFetchURL( params.notify_redirect, params.is_plugin_src_load, channel_->renderer_id(), - params.render_frame_id); + params.render_frame_id, + webplugin_->host_render_view_routing_id()); } } // namespace content diff --git a/content/public/browser/resource_request_info.h b/content/public/browser/resource_request_info.h index 6741a08..bbaff70 100644 --- a/content/public/browser/resource_request_info.h +++ b/content/public/browser/resource_request_info.h @@ -86,6 +86,9 @@ class ResourceRequestInfo { // Returns the associated resource type. virtual ResourceType::Type GetResourceType() const = 0; + // Returns the process type that initiated this request. + virtual int GetProcessType() const = 0; + // Returns the associated referrer policy. virtual blink::WebReferrerPolicy GetReferrerPolicy() const = 0; diff --git a/content/renderer/npapi/webplugin_delegate_proxy.cc b/content/renderer/npapi/webplugin_delegate_proxy.cc index cbc2f2c..19797f9 100644 --- a/content/renderer/npapi/webplugin_delegate_proxy.cc +++ b/content/renderer/npapi/webplugin_delegate_proxy.cc @@ -1128,7 +1128,8 @@ void WebPluginDelegateProxy::FetchURL(unsigned long resource_id, bool notify_redirects, bool is_plugin_src_load, int origin_pid, - int render_frame_id) { + int render_frame_id, + int render_view_id) { PluginMsg_FetchURL_Params params; params.resource_id = resource_id; params.notify_id = notify_id; diff --git a/content/renderer/npapi/webplugin_delegate_proxy.h b/content/renderer/npapi/webplugin_delegate_proxy.h index 38c4176..6df1ab7 100644 --- a/content/renderer/npapi/webplugin_delegate_proxy.h +++ b/content/renderer/npapi/webplugin_delegate_proxy.h @@ -138,7 +138,8 @@ class WebPluginDelegateProxy bool notify_redirects, bool is_plugin_src_load, int origin_pid, - int render_frame_id) OVERRIDE; + int render_frame_id, + int render_view_id) OVERRIDE; gfx::PluginWindowHandle GetPluginWindowHandle(); diff --git a/content/renderer/npapi/webplugin_impl.cc b/content/renderer/npapi/webplugin_impl.cc index c8db6d5..bb8531d 100644 --- a/content/renderer/npapi/webplugin_impl.cc +++ b/content/renderer/npapi/webplugin_impl.cc @@ -1203,7 +1203,8 @@ void WebPluginImpl::HandleURLRequestInternal(const char* url, delegate_->FetchURL(resource_id, notify_id, complete_url, first_party_for_cookies, method, buf, len, referrer, notify_redirects, is_plugin_src_load, 0, - render_frame_->GetRoutingID()); + render_frame_->GetRoutingID(), + render_view_->GetRoutingID()); } else { WebPluginResourceClient* resource_client = delegate_->CreateResourceClient( resource_id, complete_url, notify_id); |