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

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

Issue 17298002: Allow tabCapture API to be granted for chrome:// pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests.. how did it even work before? Created 7 years, 3 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/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 a62b18124f3604e59cdd18e6529aed2360c23efc..d6bce7eedcba00f0c274fa2d477c64bec66dcaf4 100644
--- a/chrome/browser/extensions/active_tab_permission_granter.cc
+++ b/chrome/browser/extensions/active_tab_permission_granter.cc
@@ -37,40 +37,37 @@ ActiveTabPermissionGranter::ActiveTabPermissionGranter(
ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {}
void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) {
- if (!extension->HasAPIPermission(extensions::APIPermission::kActiveTab) &&
- !extension->HasAPIPermission(extensions::APIPermission::kTabCapture)) {
+ if (granted_extensions_.Contains(extension->id()))
return;
- }
- if (IsGranted(extension))
- return;
+ APIPermissionSet new_apis;
+ URLPatternSet new_hosts;
- URLPattern pattern(UserScript::ValidUserScriptSchemes());
- if (pattern.Parse(web_contents()->GetURL().spec()) !=
- URLPattern::PARSE_SUCCESS) {
+ if (extension->HasAPIPermission(APIPermission::kActiveTab)) {
+ URLPattern pattern(UserScript::ValidUserScriptSchemes());
// Pattern parsing could fail if this is an unsupported URL e.g. chrome://.
- return;
+ if (pattern.Parse(web_contents()->GetURL().spec()) ==
+ URLPattern::PARSE_SUCCESS) {
+ new_hosts.AddPattern(pattern);
+ new_apis.insert(APIPermission::kTab);
+ granted_extensions_.Insert(extension);
+ }
}
- APIPermissionSet new_apis;
- new_apis.insert(APIPermission::kTab);
- URLPatternSet new_hosts;
- new_hosts.AddPattern(pattern);
- scoped_refptr<const PermissionSet> new_permissions =
- new PermissionSet(new_apis, new_hosts, URLPatternSet());
-
- PermissionsData::UpdateTabSpecificPermissions(extension,
- tab_id_,
- new_permissions);
- granted_extensions_.Insert(extension);
- Send(new ExtensionMsg_UpdateTabSpecificPermissions(GetPageID(),
- tab_id_,
- extension->id(),
- new_hosts));
-}
-
-bool ActiveTabPermissionGranter::IsGranted(const Extension* extension) {
- return granted_extensions_.Contains(extension->id());
+ if (extension->HasAPIPermission(APIPermission::kTabCapture))
+ new_apis.insert(APIPermission::kTabCaptureForTab);
+
+ if (!new_apis.empty()) {
+ scoped_refptr<const PermissionSet> new_permissions =
+ new PermissionSet(new_apis, new_hosts, URLPatternSet());
+ PermissionsData::UpdateTabSpecificPermissions(extension,
+ tab_id_,
+ new_permissions);
+ Send(new ExtensionMsg_UpdateTabSpecificPermissions(GetPageID(),
+ tab_id_,
+ extension->id(),
+ new_hosts));
+ }
}
void ActiveTabPermissionGranter::DidNavigateMainFrame(
« no previous file with comments | « chrome/browser/extensions/active_tab_permission_granter.h ('k') | chrome/browser/extensions/active_tab_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698