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_manager.h" | 5 #include "chrome/browser/extensions/active_tab_permission_manager.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/extensions/extension_system.h" | 8 #include "chrome/browser/extensions/extension_system.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sessions/session_id.h" | 10 #include "chrome/browser/sessions/session_id.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 if (pattern.Parse(web_contents()->GetURL().spec()) != | 46 if (pattern.Parse(web_contents()->GetURL().spec()) != |
47 URLPattern::PARSE_SUCCESS) { | 47 URLPattern::PARSE_SUCCESS) { |
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 return; | 49 return; |
50 } | 50 } |
51 | 51 |
52 APIPermissionSet new_apis; | 52 APIPermissionSet new_apis; |
53 new_apis.insert(APIPermission::kTab); | 53 new_apis.insert(APIPermission::kTab); |
54 URLPatternSet new_hosts; | 54 URLPatternSet new_hosts; |
55 new_hosts.AddPattern(pattern); | 55 new_hosts.AddPattern(pattern); |
| 56 scoped_refptr<const PermissionSet> new_permissions = |
| 57 new PermissionSet(new_apis, new_hosts, URLPatternSet()); |
56 | 58 |
57 extension->UpdateTabSpecificPermissions( | 59 extension->UpdateTabSpecificPermissions(tab_id_, new_permissions); |
58 tab_id_, new PermissionSet(new_apis, new_hosts, URLPatternSet())); | |
59 granted_extensions_.Insert(extension); | 60 granted_extensions_.Insert(extension); |
60 Send(new ExtensionMsg_UpdateTabSpecificPermissions(GetPageID(), | 61 Send(new ExtensionMsg_UpdateTabSpecificPermissions(GetPageID(), |
61 tab_id_, | 62 tab_id_, |
62 extension->id(), | 63 extension->id(), |
63 new_hosts)); | 64 new_hosts)); |
64 } | 65 } |
65 | 66 |
66 bool ActiveTabPermissionManager::IsGranted(const Extension* extension) { | 67 bool ActiveTabPermissionManager::IsGranted(const Extension* extension) { |
67 return granted_extensions_.Contains(extension->id()); | 68 return granted_extensions_.Contains(extension->id()); |
68 } | 69 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 108 |
108 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 109 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
109 granted_extensions_.Clear(); | 110 granted_extensions_.Clear(); |
110 } | 111 } |
111 | 112 |
112 int32 ActiveTabPermissionManager::GetPageID() { | 113 int32 ActiveTabPermissionManager::GetPageID() { |
113 return web_contents()->GetController().GetActiveEntry()->GetPageID(); | 114 return web_contents()->GetController().GetActiveEntry()->GetPageID(); |
114 } | 115 } |
115 | 116 |
116 } // namespace extensions | 117 } // namespace extensions |
OLD | NEW |