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

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: Updated comments 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 virtual void InitializePermissions(
Andrew T Wilson (Slow) 2017/04/11 11:32:54 Document what exactly InitialPermissions is suppos
Ivan Šandrk 2017/04/11 13:37:27 Devlin gave me the suggestion to use InitializePer
Devlin 2017/04/11 15:03:38 I recommended InitializePermissions to keep symmet
32 const Extension* extension,
33 std::unique_ptr<const PermissionSet>* granted_permissions) = 0;
34 };
35
27 enum InitFlag { 36 enum InitFlag {
28 INIT_FLAG_NONE = 0, 37 INIT_FLAG_NONE = 0,
29 INIT_FLAG_TRANSIENT = 1 << 0, 38 INIT_FLAG_TRANSIENT = 1 << 0,
30 }; 39 };
31 40
32 enum RemoveType { 41 enum RemoveType {
33 REMOVE_SOFT, 42 REMOVE_SOFT,
34 REMOVE_HARD, 43 REMOVE_HARD,
35 }; 44 };
36 45
37 explicit PermissionsUpdater(content::BrowserContext* browser_context); 46 explicit PermissionsUpdater(content::BrowserContext* browser_context);
38 PermissionsUpdater(content::BrowserContext* browser_context, 47 PermissionsUpdater(content::BrowserContext* browser_context,
39 InitFlag init_flag); 48 InitFlag init_flag);
40 ~PermissionsUpdater(); 49 ~PermissionsUpdater();
41 50
51 // Used for platform specific logic as to not litter the code with #ifdefs.
52 static void SetPlatformDelegate(Delegate* delegate);
Andrew T Wilson (Slow) 2017/04/11 11:32:54 I'm surprised to see this as a static function/sta
Ivan Šandrk 2017/04/11 13:37:27 PermissionsUpdater has a short lifetime - just a h
Devlin 2017/04/11 15:03:38 PermissionsUpdater is designed to be a (mostly) si
53
42 // Adds the set of |permissions| to the |extension|'s active permission set 54 // Adds the set of |permissions| to the |extension|'s active permission set
43 // and sends the relevant messages and notifications. This method assumes the 55 // and sends the relevant messages and notifications. This method assumes the
44 // user has already been prompted, if necessary, for the extra permissions. 56 // user has already been prompted, if necessary, for the extra permissions.
45 void AddPermissions(const Extension* extension, 57 void AddPermissions(const Extension* extension,
46 const PermissionSet& permissions); 58 const PermissionSet& permissions);
47 59
48 // Removes the set of |permissions| from the |extension|'s active permission 60 // Removes the set of |permissions| from the |extension|'s active permission
49 // set and sends the relevant messages and notifications. 61 // set and sends the relevant messages and notifications.
50 // If |remove_type| is REMOVE_HARD, this removes the permissions from the 62 // If |remove_type| is REMOVE_HARD, this removes the permissions from the
51 // granted permissions in the prefs (meaning that the extension would have 63 // 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 124 // Initialization flag that determines whether prefs is consulted about the
113 // extension. Transient extensions should not have entries in prefs. 125 // extension. Transient extensions should not have entries in prefs.
114 InitFlag init_flag_; 126 InitFlag init_flag_;
115 127
116 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater); 128 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater);
117 }; 129 };
118 130
119 } // namespace extensions 131 } // namespace extensions
120 132
121 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ 133 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698