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

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

Issue 2794803003: PS - Remove Clipboard Read permission from extensions in Public Sessions (except for whitelisted on… (Closed)
Patch Set: Fixed test crash Created 3 years, 8 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
OLDNEW
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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "extensions/browser/extension_event_histogram_value.h" 12 #include "extensions/browser/extension_event_histogram_value.h"
13 13
14 namespace content { 14 namespace content {
15 class BrowserContext; 15 class BrowserContext;
16 } 16 }
17 17
18 namespace extensions { 18 namespace extensions {
19 19
20 class Extension; 20 class Extension;
21 class PermissionSet; 21 class PermissionSet;
22 22
23 // Updates an Extension's active and granted permissions in persistent storage 23 // Updates an Extension's active and granted permissions in persistent storage
24 // and notifies interested parties of the changes. 24 // and notifies interested parties of the changes.
25 class PermissionsUpdater { 25 class PermissionsUpdater {
26 public: 26 public:
27 // Platform specific delegate.
28 class Delegate {
29 public:
30 virtual ~Delegate() {}
31 // Platform specific initialization of |extension|'s permissions (does any
32 // necessary filtering of permissions or similar).
33 virtual void InitializePermissions(
34 const Extension* extension,
35 std::unique_ptr<const PermissionSet>* granted_permissions) = 0;
36 };
37
27 enum InitFlag { 38 enum InitFlag {
28 INIT_FLAG_NONE = 0, 39 INIT_FLAG_NONE = 0,
29 INIT_FLAG_TRANSIENT = 1 << 0, 40 INIT_FLAG_TRANSIENT = 1 << 0,
30 }; 41 };
31 42
32 enum RemoveType { 43 enum RemoveType {
33 REMOVE_SOFT, 44 REMOVE_SOFT,
34 REMOVE_HARD, 45 REMOVE_HARD,
35 }; 46 };
36 47
37 explicit PermissionsUpdater(content::BrowserContext* browser_context); 48 explicit PermissionsUpdater(content::BrowserContext* browser_context);
38 PermissionsUpdater(content::BrowserContext* browser_context, 49 PermissionsUpdater(content::BrowserContext* browser_context,
39 InitFlag init_flag); 50 InitFlag init_flag);
40 ~PermissionsUpdater(); 51 ~PermissionsUpdater();
41 52
53 // Used for platform specific logic as to not litter the code with #ifdefs.
54 // |delegate| is created and set during creation of browser process and its
55 // lifetime is for the whole duration of the browser process - it is never
56 // freed but this is fine since it will go away together with the browser
Devlin 2017/04/11 15:06:22 I'm not quite sure I follow the "this is fine sinc
Ivan Šandrk 2017/04/11 15:11:16 You would summarize the whole "|delegate| is creat
Devlin 2017/04/11 15:15:02 Pretty much... suggested alternative: // Sets a de
Ivan Šandrk 2017/04/12 13:57:47 Done.
57 // process.
58 static void SetPlatformDelegate(Delegate* delegate);
59
42 // Adds the set of |permissions| to the |extension|'s active permission set 60 // Adds the set of |permissions| to the |extension|'s active permission set
43 // and sends the relevant messages and notifications. This method assumes the 61 // and sends the relevant messages and notifications. This method assumes the
44 // user has already been prompted, if necessary, for the extra permissions. 62 // user has already been prompted, if necessary, for the extra permissions.
45 void AddPermissions(const Extension* extension, 63 void AddPermissions(const Extension* extension,
46 const PermissionSet& permissions); 64 const PermissionSet& permissions);
47 65
48 // Removes the set of |permissions| from the |extension|'s active permission 66 // Removes the set of |permissions| from the |extension|'s active permission
49 // set and sends the relevant messages and notifications. 67 // set and sends the relevant messages and notifications.
50 // If |remove_type| is REMOVE_HARD, this removes the permissions from the 68 // If |remove_type| is REMOVE_HARD, this removes the permissions from the
51 // granted permissions in the prefs (meaning that the extension would have 69 // granted permissions in the prefs (meaning that the extension would have
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // Initialization flag that determines whether prefs is consulted about the 130 // Initialization flag that determines whether prefs is consulted about the
113 // extension. Transient extensions should not have entries in prefs. 131 // extension. Transient extensions should not have entries in prefs.
114 InitFlag init_flag_; 132 InitFlag init_flag_;
115 133
116 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater); 134 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater);
117 }; 135 };
118 136
119 } // namespace extensions 137 } // namespace extensions
120 138
121 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ 139 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc ('k') | chrome/browser/extensions/permissions_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698