| 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 <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "extensions/browser/extension_event_histogram_value.h" | 12 #include "extensions/browser/extension_event_histogram_value.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class BrowserContext; | 15 class BrowserContext; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 | 19 |
| 20 class Extension; | 20 class Extension; |
| 21 class PermissionSet; | 21 class PermissionSet; |
| 22 | 22 |
| 23 // Updates an Extension's active and granted permissions in persistent storage | 23 // Updates an Extension's active and granted permissions in persistent storage |
| 24 // and notifies interested parties of the changes. | 24 // and notifies interested parties of the changes. |
| 25 class PermissionsUpdater { | 25 class PermissionsUpdater { |
| 26 public: | 26 public: |
| 27 // Platform specific delegate. |
| 28 class Delegate { |
| 29 public: |
| 30 virtual ~Delegate() {} |
| 31 // Platform specific initialization of |extension|'s permissions (does any |
| 32 // necessary filtering of permissions or similar). |
| 33 virtual void InitializePermissions( |
| 34 const Extension* extension, |
| 35 std::unique_ptr<const PermissionSet>* granted_permissions) = 0; |
| 36 }; |
| 37 |
| 27 enum InitFlag { | 38 enum InitFlag { |
| 28 INIT_FLAG_NONE = 0, | 39 INIT_FLAG_NONE = 0, |
| 29 INIT_FLAG_TRANSIENT = 1 << 0, | 40 INIT_FLAG_TRANSIENT = 1 << 0, |
| 30 }; | 41 }; |
| 31 | 42 |
| 32 enum RemoveType { | 43 enum RemoveType { |
| 33 REMOVE_SOFT, | 44 REMOVE_SOFT, |
| 34 REMOVE_HARD, | 45 REMOVE_HARD, |
| 35 }; | 46 }; |
| 36 | 47 |
| 37 explicit PermissionsUpdater(content::BrowserContext* browser_context); | 48 explicit PermissionsUpdater(content::BrowserContext* browser_context); |
| 38 PermissionsUpdater(content::BrowserContext* browser_context, | 49 PermissionsUpdater(content::BrowserContext* browser_context, |
| 39 InitFlag init_flag); | 50 InitFlag init_flag); |
| 40 ~PermissionsUpdater(); | 51 ~PermissionsUpdater(); |
| 41 | 52 |
| 53 // Sets a delegate to provide platform-specific logic. This should be set |
| 54 // during startup (to ensure all extensions are initialized through the |
| 55 // delegate). |
| 56 // |delegate| is a singleton instance and is leaked. |
| 57 static void SetPlatformDelegate(Delegate* delegate); |
| 58 |
| 42 // Adds the set of |permissions| to the |extension|'s active permission set | 59 // Adds the set of |permissions| to the |extension|'s active permission set |
| 43 // and sends the relevant messages and notifications. This method assumes the | 60 // and sends the relevant messages and notifications. This method assumes the |
| 44 // user has already been prompted, if necessary, for the extra permissions. | 61 // user has already been prompted, if necessary, for the extra permissions. |
| 45 void AddPermissions(const Extension* extension, | 62 void AddPermissions(const Extension* extension, |
| 46 const PermissionSet& permissions); | 63 const PermissionSet& permissions); |
| 47 | 64 |
| 48 // Removes the set of |permissions| from the |extension|'s active permission | 65 // Removes the set of |permissions| from the |extension|'s active permission |
| 49 // set and sends the relevant messages and notifications. | 66 // set and sends the relevant messages and notifications. |
| 50 // If |remove_type| is REMOVE_HARD, this removes the permissions from the | 67 // If |remove_type| is REMOVE_HARD, this removes the permissions from the |
| 51 // granted permissions in the prefs (meaning that the extension would have | 68 // granted permissions in the prefs (meaning that the extension would have |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // Initialization flag that determines whether prefs is consulted about the | 129 // Initialization flag that determines whether prefs is consulted about the |
| 113 // extension. Transient extensions should not have entries in prefs. | 130 // extension. Transient extensions should not have entries in prefs. |
| 114 InitFlag init_flag_; | 131 InitFlag init_flag_; |
| 115 | 132 |
| 116 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater); | 133 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater); |
| 117 }; | 134 }; |
| 118 | 135 |
| 119 } // namespace extensions | 136 } // namespace extensions |
| 120 | 137 |
| 121 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ | 138 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ |
| OLD | NEW |