Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1031)

Unified Diff: chrome/browser/extensions/extension_function_dispatcher.cc

Issue 3263007: Reland r57788 - Expose Extension Bindings to Component Applications (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: don't hide gallery url in omnibar Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_function_dispatcher.cc
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 51cc8feb1eb8fa5a30fb835bd99f49be462ba2eb..a8253cf20a5d98067057951b1867e1403bbe284c 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -333,7 +333,13 @@ ExtensionFunctionDispatcher* ExtensionFunctionDispatcher::Create(
render_view_host->process()->profile()->GetExtensionsService();
DCHECK(service);
+ if (!service->ExtensionBindingsAllowed(url))
+ return NULL;
+
Extension* extension = service->GetExtensionByURL(url);
+ if (!extension)
+ extension = service->GetExtensionByWebExtent(url);
+
if (extension)
return new ExtensionFunctionDispatcher(render_view_host, delegate,
extension, url);
@@ -350,10 +356,12 @@ ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
render_view_host_(render_view_host),
delegate_(delegate),
url_(url),
+ extension_id_(extension->id()),
ALLOW_THIS_IN_INITIALIZER_LIST(peer_(new Peer(this))) {
// TODO(erikkay) should we do something for these errors in Release?
- DCHECK(url.SchemeIs(chrome::kExtensionScheme));
DCHECK(extension);
+ DCHECK(url.SchemeIs(chrome::kExtensionScheme) ||
+ extension->location() == Extension::COMPONENT);
// Notify the ExtensionProcessManager that the view was created.
ExtensionProcessManager* epm = profile()->GetExtensionProcessManager();
@@ -448,6 +456,17 @@ void ExtensionFunctionDispatcher::HandleRequest(
DCHECK(extension);
function->set_include_incognito(service->IsIncognitoEnabled(extension));
+ std::string permission_name = function->name();
+ size_t separator = permission_name.find_first_of("./");
+ if (separator != std::string::npos)
+ permission_name = permission_name.substr(0, separator);
+
+ if (!service->ExtensionBindingsAllowed(function->source_url()) ||
+ !extension->HasApiPermission(permission_name)) {
+ render_view_host_->BlockExtensionRequest(function->request_id());
+ return;
+ }
+
ExtensionsQuotaService* quota = service->quota_service();
if (quota->Assess(extension_id(), function, &params.arguments,
base::TimeTicks::Now())) {
« no previous file with comments | « chrome/browser/extensions/extension_function_dispatcher.h ('k') | chrome/browser/extensions/extension_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698