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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__
6 #define CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__
10 #include "base/memory/ref_counted.h"
15 class DictionaryValue
;
18 namespace extensions
{
24 // Updates an Extension's active and granted permissions in persistent storage
25 // and notifies interested parties of the changes.
26 class PermissionsUpdater
{
28 explicit PermissionsUpdater(Profile
* profile
);
29 ~PermissionsUpdater();
31 // Adds the set of |permissions| to the |extension|'s active permission set
32 // and sends the relevant messages and notifications. This method assumes the
33 // user has already been prompted, if necessary, for the extra permissions.
34 void AddPermissions(const Extension
* extension
,
35 const PermissionSet
* permissions
);
37 // Removes the set of |permissions| from the |extension|'s active permission
38 // set and sends the relevant messages and notifications.
39 void RemovePermissions(const Extension
* extension
,
40 const PermissionSet
* permissions
);
42 // Adds all permissions in the |extension|'s active permissions to its
43 // granted permission set.
44 void GrantActivePermissions(const Extension
* extension
);
46 // Sets the |extension|'s active permissions to |permissions|.
47 void UpdateActivePermissions(const Extension
* extension
,
48 const PermissionSet
* permissions
);
56 // Dispatches specified event to the extension.
57 void DispatchEvent(const std::string
& extension_id
,
58 const char* event_name
,
59 const PermissionSet
* changed_permissions
);
61 // Issues the relevant events, messages and notifications when the
62 // |extension|'s permissions have |changed| (|changed| is the delta).
63 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification,
64 // the ExtensionMsg_UpdatePermissions IPC message, and fires the
65 // onAdded/onRemoved events in the extension.
66 void NotifyPermissionsUpdated(EventType event_type
,
67 const Extension
* extension
,
68 const PermissionSet
* changed
);
70 // Gets the ExtensionPrefs for the associated profile.
71 ExtensionPrefs
* GetExtensionPrefs();
76 } // namespace extensions
78 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__