| 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 virtual void InitializePermissions(PermissionsUpdater* permissions_updater, |
| 32 const Extension* extension) = 0; |
| 33 }; |
| 34 |
| 27 enum InitFlag { | 35 enum InitFlag { |
| 28 INIT_FLAG_NONE = 0, | 36 INIT_FLAG_NONE = 0, |
| 29 INIT_FLAG_TRANSIENT = 1 << 0, | 37 INIT_FLAG_TRANSIENT = 1 << 0, |
| 30 }; | 38 }; |
| 31 | 39 |
| 32 enum RemoveType { | 40 enum RemoveType { |
| 33 REMOVE_SOFT, | 41 REMOVE_SOFT, |
| 34 REMOVE_HARD, | 42 REMOVE_HARD, |
| 35 }; | 43 }; |
| 36 | 44 |
| 37 explicit PermissionsUpdater(content::BrowserContext* browser_context); | 45 explicit PermissionsUpdater(content::BrowserContext* browser_context); |
| 38 PermissionsUpdater(content::BrowserContext* browser_context, | 46 PermissionsUpdater(content::BrowserContext* browser_context, |
| 39 InitFlag init_flag); | 47 InitFlag init_flag); |
| 40 ~PermissionsUpdater(); | 48 ~PermissionsUpdater(); |
| 41 | 49 |
| 50 // Used for platform specific logic as to not litter the code with #ifdefs. |
| 51 static void SetPlatformDelegate(Delegate* delegate); |
| 52 |
| 42 // Adds the set of |permissions| to the |extension|'s active permission set | 53 // Adds the set of |permissions| to the |extension|'s active permission set |
| 43 // and sends the relevant messages and notifications. This method assumes the | 54 // and sends the relevant messages and notifications. This method assumes the |
| 44 // user has already been prompted, if necessary, for the extra permissions. | 55 // user has already been prompted, if necessary, for the extra permissions. |
| 45 void AddPermissions(const Extension* extension, | 56 void AddPermissions(const Extension* extension, |
| 46 const PermissionSet& permissions); | 57 const PermissionSet& permissions); |
| 47 | 58 |
| 48 // Removes the set of |permissions| from the |extension|'s active permission | 59 // Removes the set of |permissions| from the |extension|'s active permission |
| 49 // set and sends the relevant messages and notifications. | 60 // set and sends the relevant messages and notifications. |
| 50 // If |remove_type| is REMOVE_HARD, this removes the permissions from the | 61 // If |remove_type| is REMOVE_HARD, this removes the permissions from the |
| 51 // granted permissions in the prefs (meaning that the extension would have | 62 // 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 | 123 // Initialization flag that determines whether prefs is consulted about the |
| 113 // extension. Transient extensions should not have entries in prefs. | 124 // extension. Transient extensions should not have entries in prefs. |
| 114 InitFlag init_flag_; | 125 InitFlag init_flag_; |
| 115 | 126 |
| 116 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater); | 127 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater); |
| 117 }; | 128 }; |
| 118 | 129 |
| 119 } // namespace extensions | 130 } // namespace extensions |
| 120 | 131 |
| 121 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ | 132 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ |
| OLD | NEW |