Chromium Code Reviews| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 class DictionaryValue; | 13 class DictionaryValue; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class BrowserContext; | 17 class BrowserContext; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 | 21 |
| 22 class Extension; | 22 class Extension; |
| 23 class ExtensionPrefs; | 23 class ExtensionPrefs; |
| 24 class PermissionSet; | 24 class PermissionSet; |
| 25 | 25 |
| 26 // Updates an Extension's active and granted permissions in persistent storage | 26 // Updates an Extension's active and granted permissions in persistent storage |
| 27 // and notifies interested parties of the changes. | 27 // and notifies interested parties of the changes. |
| 28 class PermissionsUpdater { | 28 class PermissionsUpdater { |
| 29 public: | 29 public: |
| 30 enum InitFlag { | |
| 31 INIT_FLAG_NONE = 0, | |
| 32 INIT_FLAG_TRANSIENT = 1 << 0, | |
| 33 }; | |
| 34 | |
| 30 explicit PermissionsUpdater(content::BrowserContext* browser_context); | 35 explicit PermissionsUpdater(content::BrowserContext* browser_context); |
| 31 ~PermissionsUpdater(); | 36 ~PermissionsUpdater(); |
| 32 | 37 |
| 33 // Adds the set of |permissions| to the |extension|'s active permission set | 38 // Adds the set of |permissions| to the |extension|'s active permission set |
| 34 // and sends the relevant messages and notifications. This method assumes the | 39 // and sends the relevant messages and notifications. This method assumes the |
| 35 // user has already been prompted, if necessary, for the extra permissions. | 40 // user has already been prompted, if necessary, for the extra permissions. |
| 36 void AddPermissions(const Extension* extension, | 41 void AddPermissions(const Extension* extension, |
| 37 const PermissionSet* permissions); | 42 const PermissionSet* permissions); |
| 38 | 43 |
| 39 // Removes the set of |permissions| from the |extension|'s active permission | 44 // Removes the set of |permissions| from the |extension|'s active permission |
| 40 // set and sends the relevant messages and notifications. | 45 // set and sends the relevant messages and notifications. |
| 41 void RemovePermissions(const Extension* extension, | 46 void RemovePermissions(const Extension* extension, |
| 42 const PermissionSet* permissions); | 47 const PermissionSet* permissions); |
| 43 | 48 |
| 44 // Adds all permissions in the |extension|'s active permissions to its | 49 // Adds all permissions in the |extension|'s active permissions to its |
| 45 // granted permission set. | 50 // granted permission set. |
| 46 void GrantActivePermissions(const Extension* extension); | 51 void GrantActivePermissions(const Extension* extension); |
| 47 | 52 |
| 48 // Initializes the |extension|'s active permission set to include only | 53 // Initializes the |extension|'s active permission set to include only |
| 49 // permissions currently requested by the extension and all the permissions | 54 // permissions currently requested by the extension and all the permissions |
| 50 // required by the extension. | 55 // required by the extension. |
| 51 void InitializePermissions(const Extension* extension); | 56 void InitializePermissions(const Extension* extension); |
| 57 void InitializePermissions(const Extension* extension, InitFlag init_flag); | |
|
gpdavis
2014/08/29 01:12:16
Should we be updating the comment here? I didn't
| |
| 52 | 58 |
| 53 // Grants any withheld all-hosts (or all-hosts-like) permissions. | 59 // Grants any withheld all-hosts (or all-hosts-like) permissions. |
| 54 void GrantWithheldImpliedAllHosts(const Extension* extension); | 60 void GrantWithheldImpliedAllHosts(const Extension* extension); |
| 55 | 61 |
| 56 // Revokes any requests all-hosts (or all-hosts-like) permissions. | 62 // Revokes any requests all-hosts (or all-hosts-like) permissions. |
| 57 void WithholdImpliedAllHosts(const Extension* extension); | 63 void WithholdImpliedAllHosts(const Extension* extension); |
| 58 | 64 |
| 59 private: | 65 private: |
| 60 enum EventType { | 66 enum EventType { |
| 61 ADDED, | 67 ADDED, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 84 const Extension* extension, | 90 const Extension* extension, |
| 85 const PermissionSet* changed); | 91 const PermissionSet* changed); |
| 86 | 92 |
| 87 // The associated BrowserContext. | 93 // The associated BrowserContext. |
| 88 content::BrowserContext* browser_context_; | 94 content::BrowserContext* browser_context_; |
| 89 }; | 95 }; |
| 90 | 96 |
| 91 } // namespace extensions | 97 } // namespace extensions |
| 92 | 98 |
| 93 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ | 99 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ |
| OLD | NEW |