Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(846)

Side by Side Diff: chrome/browser/extensions/permissions_updater.h

Issue 8493017: Cleanup extension permissions module. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__
6 #define CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__
7 #pragma once
8
9 #include <string>
10
11 #include "base/memory/ref_counted.h"
12
13 namespace base {
14 class DictionaryValue;
15 }
16 class Extension;
17 class ExtensionPermissionSet;
18 class ExtensionPrefs;
19 class Profile;
20
21 namespace extensions {
22
23 // Updates an Extension's active and granted permissions in persistent storage
24 // and notifies interested parties of the changes.
25 class PermissionsUpdater {
26 public:
27 explicit PermissionsUpdater(Profile* profile);
28 ~PermissionsUpdater();
29
30 // Adds the set of |permissions| to the |extension|'s active permission set
31 // and sends the relevant messages and notifications. This method assumes the
32 // user has already been prompted, if necessary, for the extra permissions.
33 void AddPermissions(const Extension* extension,
34 const ExtensionPermissionSet* permissions);
35
36 // Removes the set of |permissions| from the |extension|'s active permission
37 // set and sends the relevant messages and notifications.
38 void RemovePermissions(const Extension* extension,
39 const ExtensionPermissionSet* permissions);
40
41 // Adds all permissions in the |extension|'s active permissions to its
42 // granted permission set.
43 void GrantActivePermissions(const Extension* extension);
44
45 // Sets the |extension|'s active permissions to |permissions|.
46 void UpdateActivePermissions(const Extension* extension,
47 const ExtensionPermissionSet* permissions);
48
49 private:
50 enum EventType {
51 ADDED,
52 REMOVED,
53 };
54
55 // Dispatches specified event to the extension.
56 void DispatchEvent(const std::string& extension_id,
57 const char* event_name,
58 const ExtensionPermissionSet* changed_permissions);
59
60 // Issues the relevant events, messages and notifications when the
61 // |extension|'s permissions have |changed| (|changed| is the delta).
62 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification,
63 // the ExtensionMsg_UpdatePermissions IPC message, and fires the
64 // onAdded/onRemoved events in the extension.
65 void NotifyPermissionsUpdated(EventType event_type,
66 const Extension* extension,
67 const ExtensionPermissionSet* changed);
68
69 // Gets the ExtensionPrefs for the associated profile.
70 ExtensionPrefs* GetExtensionPrefs();
71
72 Profile* profile_;
73 };
74
75 } // namespace extensions
76
77 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__
OLDNEW
« no previous file with comments | « chrome/browser/extensions/permissions_apitest.cc ('k') | chrome/browser/extensions/permissions_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698