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/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 APIPermissionSet new_apis; | 43 APIPermissionSet new_apis; |
44 URLPatternSet new_hosts; | 44 URLPatternSet new_hosts; |
45 | 45 |
46 if (extension->HasAPIPermission(APIPermission::kActiveTab)) { | 46 if (extension->HasAPIPermission(APIPermission::kActiveTab)) { |
47 URLPattern pattern(UserScript::ValidUserScriptSchemes()); | 47 URLPattern pattern(UserScript::ValidUserScriptSchemes()); |
48 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. | 48 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. |
49 if (pattern.Parse(web_contents()->GetURL().spec()) == | 49 if (pattern.Parse(web_contents()->GetURL().spec()) == |
50 URLPattern::PARSE_SUCCESS) { | 50 URLPattern::PARSE_SUCCESS) { |
51 new_hosts.AddPattern(pattern); | 51 new_hosts.AddPattern(pattern); |
52 new_apis.insert(APIPermission::kTab); | |
53 granted_extensions_.Insert(extension); | |
54 } | 52 } |
| 53 new_apis.insert(APIPermission::kTab); |
55 } | 54 } |
56 | 55 |
57 if (extension->HasAPIPermission(APIPermission::kTabCapture)) | 56 if (extension->HasAPIPermission(APIPermission::kTabCapture)) |
58 new_apis.insert(APIPermission::kTabCaptureForTab); | 57 new_apis.insert(APIPermission::kTabCaptureForTab); |
59 | 58 |
60 if (!new_apis.empty()) { | 59 if (!new_apis.empty() || !new_hosts.is_empty()) { |
| 60 granted_extensions_.Insert(extension); |
61 scoped_refptr<const PermissionSet> new_permissions = | 61 scoped_refptr<const PermissionSet> new_permissions = |
62 new PermissionSet(new_apis, new_hosts, URLPatternSet()); | 62 new PermissionSet(new_apis, new_hosts, URLPatternSet()); |
63 PermissionsData::UpdateTabSpecificPermissions(extension, | 63 PermissionsData::UpdateTabSpecificPermissions(extension, |
64 tab_id_, | 64 tab_id_, |
65 new_permissions); | 65 new_permissions); |
66 Send(new ExtensionMsg_UpdateTabSpecificPermissions(GetPageID(), | 66 Send(new ExtensionMsg_UpdateTabSpecificPermissions(GetPageID(), |
67 tab_id_, | 67 tab_id_, |
68 extension->id(), | 68 extension->id(), |
69 new_hosts)); | 69 new_hosts)); |
70 } | 70 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 111 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
112 granted_extensions_.Clear(); | 112 granted_extensions_.Clear(); |
113 } | 113 } |
114 | 114 |
115 int32 ActiveTabPermissionGranter::GetPageID() { | 115 int32 ActiveTabPermissionGranter::GetPageID() { |
116 return web_contents()->GetController().GetVisibleEntry()->GetPageID(); | 116 return web_contents()->GetController().GetVisibleEntry()->GetPageID(); |
117 } | 117 } |
118 | 118 |
119 } // namespace extensions | 119 } // namespace extensions |
OLD | NEW |