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

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

Issue 293003008: Make ActiveScriptController use Active Tab-style permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest master for CQ Created 6 years, 7 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
« no previous file with comments | « chrome/browser/extensions/active_script_controller_unittest.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/active_tab_permission_granter.cc
diff --git a/chrome/browser/extensions/active_tab_permission_granter.cc b/chrome/browser/extensions/active_tab_permission_granter.cc
index 1a671671730ed6cea41728a1f1fee82a8eb45ff0..16099220957a21243dace3eb369836e7d795d89c 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()) ==
« no previous file with comments | « chrome/browser/extensions/active_script_controller_unittest.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698