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 #ifndef CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ |
6 #define CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "extensions/browser/extension_event_histogram_value.h" | 12 #include "extensions/browser/extension_event_histogram_value.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class DictionaryValue; | 15 class DictionaryValue; |
16 } | 16 } |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 class BrowserContext; | 19 class BrowserContext; |
20 } | 20 } |
21 | 21 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const PermissionSet& permissions, | 63 const PermissionSet& permissions, |
64 RemoveType remove_type); | 64 RemoveType remove_type); |
65 | 65 |
66 // Removes the |permissions| from |extension| and makes no effort to determine | 66 // Removes the |permissions| from |extension| and makes no effort to determine |
67 // if doing so is safe in the slightlest. This method shouldn't be used, | 67 // if doing so is safe in the slightlest. This method shouldn't be used, |
68 // except for removing permissions totally blacklisted by management. | 68 // except for removing permissions totally blacklisted by management. |
69 void RemovePermissionsUnsafe(const Extension* extension, | 69 void RemovePermissionsUnsafe(const Extension* extension, |
70 const PermissionSet& permissions); | 70 const PermissionSet& permissions); |
71 | 71 |
72 // Returns the set of revokable permissions. | 72 // Returns the set of revokable permissions. |
73 scoped_ptr<const PermissionSet> GetRevokablePermissions( | 73 std::unique_ptr<const PermissionSet> GetRevokablePermissions( |
74 const Extension* extension) const; | 74 const Extension* extension) const; |
75 | 75 |
76 // Adds all permissions in the |extension|'s active permissions to its | 76 // Adds all permissions in the |extension|'s active permissions to its |
77 // granted permission set. | 77 // granted permission set. |
78 void GrantActivePermissions(const Extension* extension); | 78 void GrantActivePermissions(const Extension* extension); |
79 | 79 |
80 // Initializes the |extension|'s active permission set to include only | 80 // Initializes the |extension|'s active permission set to include only |
81 // permissions currently requested by the extension and all the permissions | 81 // permissions currently requested by the extension and all the permissions |
82 // required by the extension. | 82 // required by the extension. |
83 void InitializePermissions(const Extension* extension); | 83 void InitializePermissions(const Extension* extension); |
84 | 84 |
85 private: | 85 private: |
86 enum EventType { | 86 enum EventType { |
87 ADDED, | 87 ADDED, |
88 REMOVED, | 88 REMOVED, |
89 }; | 89 }; |
90 | 90 |
91 // Sets the |extension|'s active permissions to |active| and records the | 91 // Sets the |extension|'s active permissions to |active| and records the |
92 // change in the prefs. If |withheld| is non-null, also sets the extension's | 92 // change in the prefs. If |withheld| is non-null, also sets the extension's |
93 // withheld permissions to |withheld|. Otherwise, |withheld| permissions are | 93 // withheld permissions to |withheld|. Otherwise, |withheld| permissions are |
94 // not changed. | 94 // not changed. |
95 void SetPermissions(const Extension* extension, | 95 void SetPermissions(const Extension* extension, |
96 scoped_ptr<const PermissionSet> active, | 96 std::unique_ptr<const PermissionSet> active, |
97 scoped_ptr<const PermissionSet> withheld); | 97 std::unique_ptr<const PermissionSet> withheld); |
98 | 98 |
99 // Dispatches specified event to the extension. | 99 // Dispatches specified event to the extension. |
100 void DispatchEvent(const std::string& extension_id, | 100 void DispatchEvent(const std::string& extension_id, |
101 events::HistogramValue histogram_value, | 101 events::HistogramValue histogram_value, |
102 const char* event_name, | 102 const char* event_name, |
103 const PermissionSet& changed_permissions); | 103 const PermissionSet& changed_permissions); |
104 | 104 |
105 // Issues the relevant events, messages and notifications when the | 105 // Issues the relevant events, messages and notifications when the |
106 // |extension|'s permissions have |changed| (|changed| is the delta). | 106 // |extension|'s permissions have |changed| (|changed| is the delta). |
107 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification, | 107 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification, |
108 // the ExtensionMsg_UpdatePermissions IPC message, and fires the | 108 // the ExtensionMsg_UpdatePermissions IPC message, and fires the |
109 // onAdded/onRemoved events in the extension. | 109 // onAdded/onRemoved events in the extension. |
110 void NotifyPermissionsUpdated(EventType event_type, | 110 void NotifyPermissionsUpdated(EventType event_type, |
111 const Extension* extension, | 111 const Extension* extension, |
112 const PermissionSet& changed); | 112 const PermissionSet& changed); |
113 | 113 |
114 // The associated BrowserContext. | 114 // The associated BrowserContext. |
115 content::BrowserContext* browser_context_; | 115 content::BrowserContext* browser_context_; |
116 | 116 |
117 // Initialization flag that determines whether prefs is consulted about the | 117 // Initialization flag that determines whether prefs is consulted about the |
118 // extension. Transient extensions should not have entries in prefs. | 118 // extension. Transient extensions should not have entries in prefs. |
119 InitFlag init_flag_; | 119 InitFlag init_flag_; |
120 | 120 |
121 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater); | 121 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater); |
122 }; | 122 }; |
123 | 123 |
124 } // namespace extensions | 124 } // namespace extensions |
125 | 125 |
126 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ | 126 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ |
OLD | NEW |