Chromium Code Reviews| 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..6be9ae372b260c39f420e1f767a4d08bc30859a6 100644 |
| --- a/chrome/browser/extensions/active_tab_permission_granter.cc |
| +++ b/chrome/browser/extensions/active_tab_permission_granter.cc |
| @@ -37,40 +37,50 @@ 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; |
| } |
|
not at google - send to devlin
2013/09/13 03:22:44
this check here isn't worth much anymore
justinlin
2013/09/13 19:27:32
Still need this, otherwise there will be some un-n
not at google - send to devlin
2013/09/13 22:09:45
why? you check new_apis.empty.
justinlin
2013/09/13 22:47:15
Done. Well, now I do :)
|
| - 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; |
| + if (extension->HasAPIPermission(APIPermission::kActiveTab)) { |
| + 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); |
| + Send(new ExtensionMsg_UpdateTabSpecificPermissions(GetPageID(), |
| + tab_id_, |
| + extension->id(), |
| + new_hosts)); |
| } |
| - 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()); |
| + if (extension->HasAPIPermission(APIPermission::kTabCapture)) { |
| + APIPermissionSet new_apis; |
| + new_apis.insert(APIPermission::kTabCaptureForTab); |
| + scoped_refptr<const PermissionSet> new_permissions = |
| + new PermissionSet(new_apis, URLPatternSet(), URLPatternSet()); |
| + PermissionsData::UpdateTabSpecificPermissions(extension, |
| + tab_id_, |
| + new_permissions); |
|
not at google - send to devlin
2013/09/13 03:22:44
could you factor this so that each case shares mor
justinlin
2013/09/13 19:27:32
Done. Fixed a kind of subtle bug too with this sec
|
| + } |
| - 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()); |
| } |
| void ActiveTabPermissionGranter::DidNavigateMainFrame( |