Index: chrome/renderer/extensions/extension_dispatcher.cc |
diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc |
index be445227cd2011eb0097852fb871f62cd2d5500d..9a5eb2bb142d17ee36fdd5557cd03bcc247714d1 100644 |
--- a/chrome/renderer/extensions/extension_dispatcher.cc |
+++ b/chrome/renderer/extensions/extension_dispatcher.cc |
@@ -77,6 +77,7 @@ using WebKit::WebView; |
using content::RenderThread; |
using content::RenderView; |
using extensions::APIPermission; |
+using extensions::APIPermissionSet; |
using extensions::ApiDefinitionsNatives; |
using extensions::AppWindowCustomBindings; |
using extensions::ContextMenusCustomBindings; |
@@ -932,7 +933,9 @@ void ExtensionDispatcher::OnUpdateTabSpecificPermissions( |
if (!extension) |
return; |
- extension->SetTabSpecificHostPermissions(tab_id, origin_set); |
+ extension->UpdateTabSpecificPermissions( |
+ tab_id, |
+ new PermissionSet(APIPermissionSet(), origin_set, URLPatternSet())); |
} |
void ExtensionDispatcher::OnClearTabSpecificPermissions( |
@@ -942,7 +945,7 @@ void ExtensionDispatcher::OnClearTabSpecificPermissions( |
it != extension_ids.end(); ++it) { |
const Extension* extension = extensions_.GetByID(*it); |
if (extension) |
- extension->ClearTabSpecificHostPermissions(tab_id); |
+ extension->ClearTabSpecificPermissions(tab_id); |
} |
} |
@@ -1043,7 +1046,20 @@ bool ExtensionDispatcher::CheckCurrentContextAccessToExtensionAPI( |
return false; |
} |
- if (!context->extension() || |
+ if (!context->extension()) { |
+ v8::ThrowException( |
+ v8::Exception::Error(v8::String::New("Not in an extension."))); |
+ return false; |
+ } |
+ |
+ // Whitelist tabs.executeScript and tabs.insertCSS since they might be |
+ // controlled by activeTab. The browser will do the relevant access checks. |
+ // We either do this or propagate all tab IDs to renderers with extensions |
+ // that have activeTab. |
+ bool skip_permission_check = (function_name == "tabs.executeScript") || |
+ (function_name == "tabs.insertCSS"); |
+ |
+ if (!skip_permission_check && |
!context->extension()->HasAPIPermission(function_name)) { |
static const char kMessage[] = |
"You do not have permission to use '%s'. Be sure to declare" |