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 class Profile; | |
13 | |
14 namespace base { | 12 namespace base { |
15 class DictionaryValue; | 13 class DictionaryValue; |
16 } | 14 } |
17 | 15 |
16 namespace content { | |
17 class BrowserContext; | |
18 } | |
19 | |
18 namespace extensions { | 20 namespace extensions { |
19 | 21 |
20 class Extension; | 22 class Extension; |
21 class ExtensionPrefs; | 23 class ExtensionPrefs; |
22 class PermissionSet; | 24 class PermissionSet; |
23 | 25 |
24 // Updates an Extension's active and granted permissions in persistent storage | 26 // Updates an Extension's active and granted permissions in persistent storage |
25 // and notifies interested parties of the changes. | 27 // and notifies interested parties of the changes. |
26 class PermissionsUpdater { | 28 class PermissionsUpdater { |
27 public: | 29 public: |
28 explicit PermissionsUpdater(Profile* profile); | 30 explicit PermissionsUpdater(content::BrowserContext* browser_context); |
29 ~PermissionsUpdater(); | 31 ~PermissionsUpdater(); |
30 | 32 |
31 // Adds the set of |permissions| to the |extension|'s active permission set | 33 // Adds the set of |permissions| to the |extension|'s active permission set |
32 // and sends the relevant messages and notifications. This method assumes the | 34 // and sends the relevant messages and notifications. This method assumes the |
33 // user has already been prompted, if necessary, for the extra permissions. | 35 // user has already been prompted, if necessary, for the extra permissions. |
34 void AddPermissions(const Extension* extension, | 36 void AddPermissions(const Extension* extension, |
35 const PermissionSet* permissions); | 37 const PermissionSet* permissions); |
36 | 38 |
37 // Removes the set of |permissions| from the |extension|'s active permission | 39 // Removes the set of |permissions| from the |extension|'s active permission |
38 // set and sends the relevant messages and notifications. | 40 // set and sends the relevant messages and notifications. |
39 void RemovePermissions(const Extension* extension, | 41 void RemovePermissions(const Extension* extension, |
40 const PermissionSet* permissions); | 42 const PermissionSet* permissions); |
41 | 43 |
42 // Adds all permissions in the |extension|'s active permissions to its | 44 // Adds all permissions in the |extension|'s active permissions to its |
43 // granted permission set. | 45 // granted permission set. |
44 void GrantActivePermissions(const Extension* extension); | 46 void GrantActivePermissions(const Extension* extension); |
45 | 47 |
46 // Sets the |extension|'s active permissions to |permissions|. | 48 // Updates the |extension|'s active permission set to include only permissions |
47 void UpdateActivePermissions(const Extension* extension, | 49 // currently requested by the extension and all the permissions required by |
48 const PermissionSet* permissions); | 50 // the extension. |
51 void UpdateActivePermissions(const Extension* extension); | |
Yoyo Zhou
2014/06/20 16:13:39
This only gets called in the flow from AddPermissi
Devlin
2014/06/20 17:05:29
Done.
(I assume you meant "called in the flow fro
| |
49 | 52 |
50 private: | 53 private: |
51 enum EventType { | 54 enum EventType { |
52 ADDED, | 55 ADDED, |
53 REMOVED, | 56 REMOVED, |
54 }; | 57 }; |
55 | 58 |
59 // Sets the |extension|'s active permissions to |permissions| and records the | |
60 // change in the prefs. | |
61 void SetActivePermissions(const Extension* extension, | |
62 const PermissionSet* permisssions); | |
63 | |
56 // Dispatches specified event to the extension. | 64 // Dispatches specified event to the extension. |
57 void DispatchEvent(const std::string& extension_id, | 65 void DispatchEvent(const std::string& extension_id, |
58 const char* event_name, | 66 const char* event_name, |
59 const PermissionSet* changed_permissions); | 67 const PermissionSet* changed_permissions); |
60 | 68 |
61 // Issues the relevant events, messages and notifications when the | 69 // Issues the relevant events, messages and notifications when the |
62 // |extension|'s permissions have |changed| (|changed| is the delta). | 70 // |extension|'s permissions have |changed| (|changed| is the delta). |
63 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification, | 71 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification, |
64 // the ExtensionMsg_UpdatePermissions IPC message, and fires the | 72 // the ExtensionMsg_UpdatePermissions IPC message, and fires the |
65 // onAdded/onRemoved events in the extension. | 73 // onAdded/onRemoved events in the extension. |
66 void NotifyPermissionsUpdated(EventType event_type, | 74 void NotifyPermissionsUpdated(EventType event_type, |
67 const Extension* extension, | 75 const Extension* extension, |
68 const PermissionSet* changed); | 76 const PermissionSet* changed); |
69 | 77 |
70 // Gets the ExtensionPrefs for the associated profile. | 78 // The associated BrowserContext. |
71 ExtensionPrefs* GetExtensionPrefs(); | 79 content::BrowserContext* browser_context_; |
72 | |
73 Profile* profile_; | |
74 }; | 80 }; |
75 | 81 |
76 } // namespace extensions | 82 } // namespace extensions |
77 | 83 |
78 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ | 84 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ |
OLD | NEW |