| 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); |
| 36 PermissionsUpdater(content::BrowserContext* browser_context, |
| 37 InitFlag init_flag); |
| 31 ~PermissionsUpdater(); | 38 ~PermissionsUpdater(); |
| 32 | 39 |
| 33 // Adds the set of |permissions| to the |extension|'s active permission set | 40 // Adds the set of |permissions| to the |extension|'s active permission set |
| 34 // and sends the relevant messages and notifications. This method assumes the | 41 // and sends the relevant messages and notifications. This method assumes the |
| 35 // user has already been prompted, if necessary, for the extra permissions. | 42 // user has already been prompted, if necessary, for the extra permissions. |
| 36 void AddPermissions(const Extension* extension, | 43 void AddPermissions(const Extension* extension, |
| 37 const PermissionSet* permissions); | 44 const PermissionSet* permissions); |
| 38 | 45 |
| 39 // Removes the set of |permissions| from the |extension|'s active permission | 46 // Removes the set of |permissions| from the |extension|'s active permission |
| 40 // set and sends the relevant messages and notifications. | 47 // set and sends the relevant messages and notifications. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // |extension|'s permissions have |changed| (|changed| is the delta). | 86 // |extension|'s permissions have |changed| (|changed| is the delta). |
| 80 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification, | 87 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification, |
| 81 // the ExtensionMsg_UpdatePermissions IPC message, and fires the | 88 // the ExtensionMsg_UpdatePermissions IPC message, and fires the |
| 82 // onAdded/onRemoved events in the extension. | 89 // onAdded/onRemoved events in the extension. |
| 83 void NotifyPermissionsUpdated(EventType event_type, | 90 void NotifyPermissionsUpdated(EventType event_type, |
| 84 const Extension* extension, | 91 const Extension* extension, |
| 85 const PermissionSet* changed); | 92 const PermissionSet* changed); |
| 86 | 93 |
| 87 // The associated BrowserContext. | 94 // The associated BrowserContext. |
| 88 content::BrowserContext* browser_context_; | 95 content::BrowserContext* browser_context_; |
| 96 |
| 97 // Initialization flag that determines whether prefs is consulted about the |
| 98 // extension. Transient extensions should not have entries in prefs. |
| 99 InitFlag init_flag_; |
| 89 }; | 100 }; |
| 90 | 101 |
| 91 } // namespace extensions | 102 } // namespace extensions |
| 92 | 103 |
| 93 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ | 104 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ |
| OLD | NEW |