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

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

Issue 1349613003: [Extensions] Un-refcount PermissionSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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 <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "extensions/browser/extension_event_histogram_value.h" 11 #include "extensions/browser/extension_event_histogram_value.h"
12 12
13 namespace base { 13 namespace base {
14 class DictionaryValue; 14 class DictionaryValue;
15 } 15 }
16 16
17 namespace content { 17 namespace content {
18 class BrowserContext; 18 class BrowserContext;
19 } 19 }
20 20
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 const PermissionSet* permissions, 62 const PermissionSet* permissions,
63 RemoveType remove_type); 63 RemoveType remove_type);
64 64
65 // Removes the |permissions| from |extension| and makes no effort to determine 65 // Removes the |permissions| from |extension| and makes no effort to determine
66 // if doing so is safe in the slightlest. This method shouldn't be used, 66 // if doing so is safe in the slightlest. This method shouldn't be used,
67 // except for removing permissions totally blacklisted by management. 67 // except for removing permissions totally blacklisted by management.
68 void RemovePermissionsUnsafe(const Extension* extension, 68 void RemovePermissionsUnsafe(const Extension* extension,
69 const PermissionSet* permissions); 69 const PermissionSet* permissions);
70 70
71 // Returns the set of revokable permissions. 71 // Returns the set of revokable permissions.
72 scoped_refptr<const PermissionSet> GetRevokablePermissions( 72 scoped_ptr<const PermissionSet> GetRevokablePermissions(
73 const Extension* extension) const; 73 const Extension* extension) const;
74 74
75 // Adds all permissions in the |extension|'s active permissions to its 75 // Adds all permissions in the |extension|'s active permissions to its
76 // granted permission set. 76 // granted permission set.
77 void GrantActivePermissions(const Extension* extension); 77 void GrantActivePermissions(const Extension* extension);
78 78
79 // Initializes the |extension|'s active permission set to include only 79 // Initializes the |extension|'s active permission set to include only
80 // permissions currently requested by the extension and all the permissions 80 // permissions currently requested by the extension and all the permissions
81 // required by the extension. 81 // required by the extension.
82 void InitializePermissions(const Extension* extension); 82 void InitializePermissions(const Extension* extension);
83 83
84 // Grants any withheld all-hosts (or all-hosts-like) permissions. 84 // Grants any withheld all-hosts (or all-hosts-like) permissions.
85 void GrantWithheldImpliedAllHosts(const Extension* extension); 85 void GrantWithheldImpliedAllHosts(const Extension* extension);
86 86
87 // Revokes any requests all-hosts (or all-hosts-like) permissions. 87 // Revokes any requests all-hosts (or all-hosts-like) permissions.
88 void WithholdImpliedAllHosts(const Extension* extension); 88 void WithholdImpliedAllHosts(const Extension* extension);
89 89
90 private: 90 private:
91 enum EventType { 91 enum EventType {
92 ADDED, 92 ADDED,
93 REMOVED, 93 REMOVED,
94 }; 94 };
95 95
96 // Sets the |extension|'s active permissions to |active| and records the 96 // Sets the |extension|'s active permissions to |active| and records the
97 // change in the prefs. If |withheld| is non-null, also sets the extension's 97 // change in the prefs. If |withheld| is non-null, also sets the extension's
98 // withheld permissions to |withheld|. Otherwise, |withheld| permissions are 98 // withheld permissions to |withheld|. Otherwise, |withheld| permissions are
99 // not changed. 99 // not changed.
100 void SetPermissions(const Extension* extension, 100 void SetPermissions(const Extension* extension,
101 const scoped_refptr<const PermissionSet>& active, 101 scoped_ptr<const PermissionSet> active,
102 scoped_refptr<const PermissionSet> withheld); 102 scoped_ptr<const PermissionSet> withheld);
103 103
104 // Dispatches specified event to the extension. 104 // Dispatches specified event to the extension.
105 void DispatchEvent(const std::string& extension_id, 105 void DispatchEvent(const std::string& extension_id,
106 events::HistogramValue histogram_value, 106 events::HistogramValue histogram_value,
107 const char* event_name, 107 const char* event_name,
108 const PermissionSet* changed_permissions); 108 const PermissionSet& changed_permissions);
109 109
110 // Issues the relevant events, messages and notifications when the 110 // Issues the relevant events, messages and notifications when the
111 // |extension|'s permissions have |changed| (|changed| is the delta). 111 // |extension|'s permissions have |changed| (|changed| is the delta).
112 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification, 112 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification,
113 // the ExtensionMsg_UpdatePermissions IPC message, and fires the 113 // the ExtensionMsg_UpdatePermissions IPC message, and fires the
114 // onAdded/onRemoved events in the extension. 114 // onAdded/onRemoved events in the extension.
115 void NotifyPermissionsUpdated(EventType event_type, 115 void NotifyPermissionsUpdated(EventType event_type,
116 const Extension* extension, 116 const Extension* extension,
117 const PermissionSet* changed); 117 const PermissionSet& changed);
118 118
119 // The associated BrowserContext. 119 // The associated BrowserContext.
120 content::BrowserContext* browser_context_; 120 content::BrowserContext* browser_context_;
121 121
122 // Initialization flag that determines whether prefs is consulted about the 122 // Initialization flag that determines whether prefs is consulted about the
123 // extension. Transient extensions should not have entries in prefs. 123 // extension. Transient extensions should not have entries in prefs.
124 InitFlag init_flag_; 124 InitFlag init_flag_;
125
126 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater);
125 }; 127 };
126 128
127 } // namespace extensions 129 } // namespace extensions
128 130
129 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ 131 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698