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

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 permissions tests 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..606d290ff8614616493101d69baf36722c1240d7 100644
--- a/chrome/browser/extensions/active_tab_permission_granter.cc
+++ b/chrome/browser/extensions/active_tab_permission_granter.cc
@@ -37,40 +37,42 @@ ActiveTabPermissionGranter::ActiveTabPermissionGranter(
ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {}
void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) {
- if (!extension->HasAPIPermission(extensions::APIPermission::kActiveTab) &&
- !extension->HasAPIPermission(extensions::APIPermission::kTabCapture)) {
+ if (!extension->HasAPIPermission(APIPermission::kActiveTab) &&
+ !extension->HasAPIPermission(APIPermission::kTabCapture)) {
return;
}
- if (IsGranted(extension))
+ if (granted_extensions_.Contains(extension->id()))
return;
- URLPattern pattern(UserScript::ValidUserScriptSchemes());
- if (pattern.Parse(web_contents()->GetURL().spec()) !=
- URLPattern::PARSE_SUCCESS) {
- // Pattern parsing could fail if this is an unsupported URL e.g. chrome://.
- return;
- }
-
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::kActiveTab)) {
+ URLPattern pattern(UserScript::ValidUserScriptSchemes());
+ // Pattern parsing could fail if this is an unsupported URL e.g. chrome://.
+ if (pattern.Parse(web_contents()->GetURL().spec()) ==
+ URLPattern::PARSE_SUCCESS) {
+ new_hosts.AddPattern(pattern);
+ new_apis.insert(APIPermission::kTab);
not at google - send to devlin 2013/09/13 22:09:45 for consistency with tabCapture I think add this p
justinlin 2013/09/13 22:47:15 OK, I'll do this separately. I'm not really sure w
not at google - send to devlin 2013/09/13 22:48:52 It would mean that extensions could read the title
+ granted_extensions_.Insert(extension);
+ }
+ }
+
+ 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(
@@ -119,4 +121,14 @@ int32 ActiveTabPermissionGranter::GetPageID() {
return web_contents()->GetController().GetVisibleEntry()->GetPageID();
}
+// static
+bool ActiveTabPermissionGranter::IsGrantedForTab(
+ const Extension* extension,
+ const content::WebContents* web_contents) {
+ return PermissionsData::HasAPIPermissionForTab(
+ extension,
+ SessionID::IdForTab(web_contents),
+ APIPermission::kTab);
not at google - send to devlin 2013/09/13 22:09:45 can you just write this check specifically whereve
justinlin 2013/09/13 22:47:15 Done.
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698