diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-01 21:02:14 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-01 21:02:14 +0000 |
commit | 8add541ad22bf41d3f5bff4f9c58a65cf7a2c228 (patch) | |
tree | 86c446a7d76044f2a6422b340f35423e8ff6e7cc /chrome/browser/extensions/extension_function_dispatcher.cc | |
parent | 637bf32f0bc3debadd6371992f8a68f0dc30ea7d (diff) | |
download | chromium_src-8add541ad22bf41d3f5bff4f9c58a65cf7a2c228.zip chromium_src-8add541ad22bf41d3f5bff4f9c58a65cf7a2c228.tar.gz chromium_src-8add541ad22bf41d3f5bff4f9c58a65cf7a2c228.tar.bz2 |
Get rid of BindingsPolicy::EXTENSION
BUG=89642
TEST=everything still works
Review URL: http://codereview.chromium.org/8052032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_function_dispatcher.cc')
-rw-r--r-- | chrome/browser/extensions/extension_function_dispatcher.cc | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index 91c470e..dcec789 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -61,7 +61,6 @@ #include "chrome/browser/ui/browser_window.h" #include "chrome/common/extensions/extension_messages.h" #include "chrome/common/url_constants.h" -#include "content/browser/child_process_security_policy.h" #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/render_view_host.h" #include "ipc/ipc_message.h" @@ -518,9 +517,16 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread( const Extension* extension = extension_info_map->extensions().GetByURL(params.source_url); - scoped_refptr<ExtensionFunction> function( - CreateExtensionFunction(params, extension, profile, render_process_id, - ipc_sender, routing_id)); + if (!extension_info_map->AreBindingsEnabledForProcess(render_process_id)) { + // TODO(aa): Allow content scripts access to low-threat extension APIs. + // See: crbug.com/80308. + LOG(ERROR) << "Extension API called from non-extension process."; + SendAccessDenied(ipc_sender, routing_id, params.request_id); + return; + } + + scoped_refptr<ExtensionFunction> function(CreateExtensionFunction( + params, extension, profile, ipc_sender, routing_id)); if (!function) return; @@ -576,7 +582,9 @@ void ExtensionFunctionDispatcher::Dispatch( const ExtensionHostMsg_Request_Params& params, RenderViewHost* render_view_host) { ExtensionService* service = profile()->GetExtensionService(); - if (!service) + ExtensionProcessManager* extension_process_manager = + profile()->GetExtensionProcessManager(); + if (!service || !extension_process_manager) return; if (!service->ExtensionBindingsAllowed(params.source_url)) { @@ -586,6 +594,15 @@ void ExtensionFunctionDispatcher::Dispatch( params.request_id); return; } + if (!extension_process_manager->AreBindingsEnabledForProcess( + render_view_host->process()->id())) { + // TODO(aa): Allow content scripts access to low-threat extension APIs. + // See: crbug.com/80308. + LOG(ERROR) << "Extension API called from non-extension process."; + SendAccessDenied(render_view_host, render_view_host->routing_id(), + params.request_id); + return; + } // TODO(aa): When we allow content scripts to call extension APIs, we will // have to pass the extension ID explicitly here, not use the source URL. @@ -593,10 +610,9 @@ void ExtensionFunctionDispatcher::Dispatch( if (!extension) extension = service->GetExtensionByWebExtent(params.source_url); - scoped_refptr<ExtensionFunction> function(CreateExtensionFunction( - params, extension, profile_, - render_view_host->process()->id(), - render_view_host, render_view_host->routing_id())); + scoped_refptr<ExtensionFunction> function( + CreateExtensionFunction(params, extension, profile(), render_view_host, + render_view_host->routing_id())); if (!function) return; @@ -630,24 +646,8 @@ ExtensionFunction* ExtensionFunctionDispatcher::CreateExtensionFunction( const ExtensionHostMsg_Request_Params& params, const Extension* extension, void* profile, - int render_process_id, IPC::Message::Sender* ipc_sender, int routing_id) { - // TODO(aa): It would be cool to use ExtensionProcessManager to track which - // processes are extension processes rather than ChildProcessSecurityPolicy. - // EPM has richer information: it not only knows which processes contain - // at least one extension, but it knows which extensions are inside and what - // permissions the have. So we would be able to enforce permissions more - // granularly. - if (!ChildProcessSecurityPolicy::GetInstance()->HasExtensionBindings( - render_process_id)) { - // TODO(aa): Allow content scripts access to low-threat extension APIs. - // See: crbug.com/80308. - LOG(ERROR) << "Extension API called from non-extension process."; - SendAccessDenied(ipc_sender, routing_id, params.request_id); - return NULL; - } - if (!extension) { LOG(ERROR) << "Extension does not exist for URL: " << params.source_url.spec(); |