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 new_hosts.AddOrigin(UserScript::ValidUserScriptSchemes(), |
51 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. | 51 web_contents()->GetVisibleURL().GetOrigin()); |
52 if (pattern.Parse(web_contents()->GetURL().spec()) == | |
53 URLPattern::PARSE_SUCCESS) { | |
54 new_hosts.AddPattern(pattern); | |
55 } | |
56 new_apis.insert(APIPermission::kTab); | 52 new_apis.insert(APIPermission::kTab); |
57 } | 53 } |
58 | 54 |
59 if (permissions_data->HasAPIPermission(APIPermission::kTabCapture)) | 55 if (permissions_data->HasAPIPermission(APIPermission::kTabCapture)) |
60 new_apis.insert(APIPermission::kTabCaptureForTab); | 56 new_apis.insert(APIPermission::kTabCaptureForTab); |
61 | 57 |
62 if (!new_apis.empty() || !new_hosts.is_empty()) { | 58 if (!new_apis.empty() || !new_hosts.is_empty()) { |
63 granted_extensions_.Insert(extension); | 59 granted_extensions_.Insert(extension); |
64 scoped_refptr<const PermissionSet> new_permissions = | 60 scoped_refptr<const PermissionSet> new_permissions = |
65 new PermissionSet(new_apis, ManifestPermissionSet(), | 61 new PermissionSet(new_apis, ManifestPermissionSet(), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 it != granted_extensions_.end(); ++it) { | 112 it != granted_extensions_.end(); ++it) { |
117 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); | 113 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); |
118 extension_ids.push_back((*it)->id()); | 114 extension_ids.push_back((*it)->id()); |
119 } | 115 } |
120 | 116 |
121 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 117 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
122 granted_extensions_.Clear(); | 118 granted_extensions_.Clear(); |
123 } | 119 } |
124 | 120 |
125 } // namespace extensions | 121 } // namespace extensions |
OLD | NEW |