Make ActiveTabPermissionManager also grant the tabs permission for
that tab; only respected for tabs.executeScript and tabs.insertCSS.
This involved converting tabs.executeScript/insertCSS to use JSON
schema compiler.
BUG=137643
[email protected]
Review URL: https://chromiumcodereview.appspot.com/10815028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149631 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 2e2935d..565c1248 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -136,7 +136,7 @@
extension_info_map->process_map(),
g_global_io_data.Get().api.get(),
profile,
- ipc_sender, routing_id));
+ ipc_sender, NULL, routing_id));
if (!function) {
LogFailure(extension, params.name, kAccessDenied);
return;
@@ -193,7 +193,7 @@
render_view_host->GetProcess()->GetID(),
*(service->process_map()),
extensions::ExtensionAPI::GetSharedInstance(),
- profile(), render_view_host,
+ profile(), render_view_host, render_view_host,
render_view_host->GetRoutingID()));
if (!function) {
LogFailure(extension, params.name, kAccessDenied);
@@ -206,7 +206,6 @@
NOTREACHED();
return;
}
- function_ui->SetRenderViewHost(render_view_host);
function_ui->set_dispatcher(AsWeakPtr());
function_ui->set_profile(profile_);
function->set_include_incognito(service->CanCrossIncognito(extension));
@@ -251,6 +250,7 @@
extensions::ExtensionAPI* api,
void* profile,
IPC::Sender* ipc_sender,
+ RenderViewHost* render_view_host,
int routing_id) {
if (!extension) {
LOG(ERROR) << "Specified extension does not exist.";
@@ -267,13 +267,6 @@
return NULL;
}
- if (!extension->HasAPIPermission(params.name)) {
- LOG(ERROR) << "Extension " << extension->id() << " does not have "
- << "permission to function: " << params.name;
- SendAccessDenied(ipc_sender, routing_id, params.request_id);
- return NULL;
- }
-
ExtensionFunction* function =
ExtensionFunctionRegistry::GetInstance()->NewFunction(params.name);
function->SetArgs(¶ms.arguments);
@@ -283,6 +276,20 @@
function->set_user_gesture(params.user_gesture);
function->set_extension(extension);
function->set_profile_id(profile);
+
+ UIThreadExtensionFunction* function_ui =
+ function->AsUIThreadExtensionFunction();
+ if (function_ui) {
+ function_ui->SetRenderViewHost(render_view_host);
+ }
+
+ if (!function->HasPermission()) {
+ LOG(ERROR) << "Extension " << extension->id() << " does not have "
+ << "permission to function: " << params.name;
+ SendAccessDenied(ipc_sender, routing_id, params.request_id);
+ return NULL;
+ }
+
return function;
}