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

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: . Created 9 years 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) 2011 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 class PermissionsUpdater {
Aaron Boodman 2011/12/14 01:00:14 Unit test for this class? Also a class-level comme
jstritar 2012/01/04 21:53:32 Done.
24 public:
25 explicit PermissionsUpdater(Profile* profile);
26 ~PermissionsUpdater();
27
28 // Adds the set of |permissions| to the |extension|'s active permission set
29 // and sends the relevant messages and notifications. This method assumes the
30 // user has already been prompted, if necessary, for the extra permissions.
31 void AddPermissions(const Extension* extension,
32 const ExtensionPermissionSet* permissions);
33
34 // Removes the set of |permissions| from the |extension|'s active permission
35 // set and sends the relevant messages and notifications.
36 void RemovePermissions(const Extension* extension,
37 const ExtensionPermissionSet* permissions);
38
39 // Adds all permissions in the |extension|'s active permissions to its
40 // granted permission set.
41 void GrantActivePermissions(const Extension* extension);
42
43 // Sets the |extension|'s active permissions to |permissions|.
44 void UpdateActivePermissions(const Extension* extension,
45 const ExtensionPermissionSet* permissions);
46
47 private:
48 enum EventType {
49 ADDED,
50 REMOVED,
51 };
52
53 // Dispatches specified event to the extension.
54 void DispatchEvent(const std::string& extension_id,
55 const char* event_name,
56 const ExtensionPermissionSet* changed_permissions);
57
58 // Issues the relevant events, messages and notifications when the
59 // |extension|'s permissions have |changed| (|changed| is the delta).
60 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification,
61 // the ExtensionMsg_UpdatePermissions IPC message, and fires the
62 // onAdded/onRemoved events in the extension.
63 void NotifyPermissionsUpdated(EventType event_type,
64 const Extension* extension,
65 const ExtensionPermissionSet* changed);
66
67 // Gets the ExtensionPrefs for the associated profile.
68 ExtensionPrefs* GetExtensionPrefs();
69
70 Profile* profile_;
71 };
72
73 } // namespace extensions
74
75 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698