OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 5 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
6 | 6 |
7 #include "chrome/browser/extensions/active_script_controller.h" | 7 #include "chrome/browser/extensions/active_script_controller.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "content/public/browser/navigation_details.h" | 9 #include "content/public/browser/navigation_details.h" |
10 #include "content/public/browser/navigation_entry.h" | 10 #include "content/public/browser/navigation_entry.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 APIPermissionSet new_apis; | 40 APIPermissionSet new_apis; |
41 URLPatternSet new_hosts; | 41 URLPatternSet new_hosts; |
42 | 42 |
43 const PermissionsData* permissions_data = extension->permissions_data(); | 43 const PermissionsData* permissions_data = extension->permissions_data(); |
44 | 44 |
45 // If the extension requested all-hosts but has had it withheld, we grant it | 45 // If the extension requested all-hosts but has had it withheld, we grant it |
46 // active tab-style permissions, even if it doesn't have the activeTab | 46 // active tab-style permissions, even if it doesn't have the activeTab |
47 // permission in the manifest. | 47 // permission in the manifest. |
48 if (permissions_data->HasAPIPermission(APIPermission::kActiveTab) || | 48 if (permissions_data->HasAPIPermission(APIPermission::kActiveTab) || |
49 permissions_data->HasWithheldImpliedAllHosts()) { | 49 permissions_data->HasWithheldImpliedAllHosts()) { |
50 URLPattern pattern(UserScript::ValidUserScriptSchemes()); | 50 // Origin adding could fail if this is an unsupported URL e.g. chrome://. |
not at google - send to devlin
2014/08/12 19:49:27
comment isn't for here (it should be inside the Ad
gpdavis
2014/08/12 21:19:55
Done.
| |
51 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. | 51 new_hosts.AddOrigin(UserScript::ValidUserScriptSchemes(), |
52 if (pattern.Parse(web_contents()->GetURL().spec()) == | 52 web_contents()->GetURL().GetOrigin()); |
not at google - send to devlin
2014/08/12 19:49:27
cleanup: use GetVisibleURL() here.
gpdavis
2014/08/12 21:19:54
Done.
| |
53 URLPattern::PARSE_SUCCESS) { | |
54 new_hosts.AddPattern(pattern); | |
55 } | |
56 new_apis.insert(APIPermission::kTab); | 53 new_apis.insert(APIPermission::kTab); |
57 } | 54 } |
58 | 55 |
59 if (permissions_data->HasAPIPermission(APIPermission::kTabCapture)) | 56 if (permissions_data->HasAPIPermission(APIPermission::kTabCapture)) |
60 new_apis.insert(APIPermission::kTabCaptureForTab); | 57 new_apis.insert(APIPermission::kTabCaptureForTab); |
61 | 58 |
62 if (!new_apis.empty() || !new_hosts.is_empty()) { | 59 if (!new_apis.empty() || !new_hosts.is_empty()) { |
63 granted_extensions_.Insert(extension); | 60 granted_extensions_.Insert(extension); |
64 scoped_refptr<const PermissionSet> new_permissions = | 61 scoped_refptr<const PermissionSet> new_permissions = |
65 new PermissionSet(new_apis, ManifestPermissionSet(), | 62 new PermissionSet(new_apis, ManifestPermissionSet(), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 it != granted_extensions_.end(); ++it) { | 113 it != granted_extensions_.end(); ++it) { |
117 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); | 114 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); |
118 extension_ids.push_back((*it)->id()); | 115 extension_ids.push_back((*it)->id()); |
119 } | 116 } |
120 | 117 |
121 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 118 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
122 granted_extensions_.Clear(); | 119 granted_extensions_.Clear(); |
123 } | 120 } |
124 | 121 |
125 } // namespace extensions | 122 } // namespace extensions |
OLD | NEW |