summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/active_tab_permission_granter.cc
diff options
context:
space:
mode:
authorrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 20:33:52 +0000
committerrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 20:33:52 +0000
commit78cd68e0d88496f769b46bb789ea19b0ee132e99 (patch)
tree1a3ff301e063ae6c289ee137ed557878db384e50 /chrome/browser/extensions/active_tab_permission_granter.cc
parent98e8c43e83d631c7986f9a97ee3a06d1efe2ef33 (diff)
downloadchromium_src-78cd68e0d88496f769b46bb789ea19b0ee132e99.zip
chromium_src-78cd68e0d88496f769b46bb789ea19b0ee132e99.tar.gz
chromium_src-78cd68e0d88496f769b46bb789ea19b0ee132e99.tar.bz2
Make ActiveScriptController use Active Tab-style permissions
Also make ActiveScriptController used for all extensions with pseudo-all-hosts (e.g., *://*.com/*). Add unittests for ActiveScriptController (to complement the browsertests). BUG=362353 Review URL: https://codereview.chromium.org/293003008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272307 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/active_tab_permission_granter.cc')
-rw-r--r--chrome/browser/extensions/active_tab_permission_granter.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/chrome/browser/extensions/active_tab_permission_granter.cc b/chrome/browser/extensions/active_tab_permission_granter.cc
index 1a67167..1609922 100644
--- a/chrome/browser/extensions/active_tab_permission_granter.cc
+++ b/chrome/browser/extensions/active_tab_permission_granter.cc
@@ -13,6 +13,7 @@
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/user_script.h"
+#include "url/gurl.h"
using content::RenderProcessHost;
using content::WebContentsObserver;
@@ -41,7 +42,19 @@ void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) {
APIPermissionSet new_apis;
URLPatternSet new_hosts;
- if (extension->HasAPIPermission(APIPermission::kActiveTab)) {
+ // If the extension requires action for script execution, we grant it
+ // active tab-style permissions, even if it doesn't have the activeTab
+ // permission in the manifest.
+ // We don't take tab id into account, because we want to know if the extension
+ // should require active tab in general (not for the current tab).
+ bool requires_action_for_script_execution =
+ PermissionsData::RequiresActionForScriptExecution(
+ extension,
+ -1, // No tab id.
+ GURL::EmptyGURL());
+
+ if (extension->HasAPIPermission(APIPermission::kActiveTab) ||
+ requires_action_for_script_execution) {
URLPattern pattern(UserScript::ValidUserScriptSchemes());
// Pattern parsing could fail if this is an unsupported URL e.g. chrome://.
if (pattern.Parse(web_contents()->GetURL().spec()) ==