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

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

Issue 4687005: Track permissions granted to extensions in prefs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: incorporate feedback Created 10 years, 1 month 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_EXTENSION_PREFS_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 bool IsExtensionAllowedByPolicy(const std::string& extension_id); 115 bool IsExtensionAllowedByPolicy(const std::string& extension_id);
116 116
117 // Returns the last value set via SetLastPingDay. If there isn't such a 117 // Returns the last value set via SetLastPingDay. If there isn't such a
118 // pref, the returned Time will return true for is_null(). 118 // pref, the returned Time will return true for is_null().
119 base::Time LastPingDay(const std::string& extension_id) const; 119 base::Time LastPingDay(const std::string& extension_id) const;
120 120
121 // The time stored is based on the server's perspective of day start time, not 121 // The time stored is based on the server's perspective of day start time, not
122 // the client's. 122 // the client's.
123 void SetLastPingDay(const std::string& extension_id, const base::Time& time); 123 void SetLastPingDay(const std::string& extension_id, const base::Time& time);
124 124
125 // Gets the |api_permissions| and |host_extent| granted to the extension
126 // with |extension_id|. Returns false if the granted permissions preferences
127 // have not been initialized yet.
128 bool GetGrantedPermissions(const std::string& extension_id,
129 std::set<std::string>* api_permissions,
130 ExtensionExtent* host_extent);
131
132 // Adds the specified |api_permissions| and |host_extent| to the granted
133 // permissions for extension with |extension_id|.
134 void AddGrantedPermissions(const std::string& extension_id,
135 const std::set<std::string>& api_permissions,
136 const ExtensionExtent& host_extent);
137
125 // Similar to the 2 above, but for the extensions blacklist. 138 // Similar to the 2 above, but for the extensions blacklist.
126 base::Time BlacklistLastPingDay() const; 139 base::Time BlacklistLastPingDay() const;
127 void SetBlacklistLastPingDay(const base::Time& time); 140 void SetBlacklistLastPingDay(const base::Time& time);
128 141
129 // Returns true if the user enabled this extension to be loaded in incognito 142 // Returns true if the user enabled this extension to be loaded in incognito
130 // mode. 143 // mode.
131 bool IsIncognitoEnabled(const std::string& extension_id); 144 bool IsIncognitoEnabled(const std::string& extension_id);
132 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled); 145 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled);
133 146
134 // Returns true if the user has chosen to allow this extension to inject 147 // Returns true if the user has chosen to allow this extension to inject
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 227
215 // Sets the pref |key| for extension |id| to |value|. 228 // Sets the pref |key| for extension |id| to |value|.
216 void UpdateExtensionPref(const std::string& id, 229 void UpdateExtensionPref(const std::string& id,
217 const std::string& key, 230 const std::string& key,
218 Value* value); 231 Value* value);
219 232
220 // Deletes the pref dictionary for extension |id|. 233 // Deletes the pref dictionary for extension |id|.
221 void DeleteExtensionPrefs(const std::string& id); 234 void DeleteExtensionPrefs(const std::string& id);
222 235
223 // Reads a boolean pref from |ext| with key |pref_key|. 236 // Reads a boolean pref from |ext| with key |pref_key|.
224 // Return false if the value is false or kPrefBlacklist does not exist. 237 // Return false if the value is false or |pref_key| does not exist.
225 bool ReadBooleanFromPref(DictionaryValue* ext, const std::string& pref_key); 238 bool ReadBooleanFromPref(DictionaryValue* ext, const std::string& pref_key);
226 239
227 // Reads a boolean pref |pref_key| from extension with id |extension_id|. 240 // Reads a boolean pref |pref_key| from extension with id |extension_id|.
228 bool ReadExtensionPrefBoolean(const std::string& extension_id, 241 bool ReadExtensionPrefBoolean(const std::string& extension_id,
229 const std::string& pref_key); 242 const std::string& pref_key);
230 243
231 // Reads an integer pref from |ext| with key |pref_key|. 244 // Reads an integer pref from |ext| with key |pref_key|.
232 // Return false if the value does not exist. 245 // Return false if the value does not exist.
233 bool ReadIntegerFromPref(DictionaryValue* ext, const std::string& pref_key, 246 bool ReadIntegerFromPref(DictionaryValue* ext, const std::string& pref_key,
234 int* out_value); 247 int* out_value);
235 248
236 // Reads an integer pref |pref_key| from extension with id |extension_id|. 249 // Reads an integer pref |pref_key| from extension with id |extension_id|.
237 bool ReadExtensionPrefInteger(const std::string& extension_id, 250 bool ReadExtensionPrefInteger(const std::string& extension_id,
238 const std::string& pref_key, 251 const std::string& pref_key,
239 int* out_value); 252 int* out_value);
240 253
254 // Reads a list pref |pref_key| from extension with id | extension_id|.
255 bool ReadExtensionPrefList(const std::string& extension_id,
256 const std::string& pref_key,
257 ListValue** out_value);
258
259 // Reads a list pref |pref_key| as a string set from the extension with
260 // id |extension_id|.
261 bool ReadExtensionPrefStringSet(const std::string& extension_id,
262 const std::string& pref_key,
263 std::set<std::string>* result);
264
265 // Adds the |added_values| to the value of |pref_key| for the extension
266 // with id |extension_id| (the new value will be the union of the existing
267 // value and |added_values|).
268 void AddToExtensionPrefStringSet(const std::string& extension_id,
269 const std::string& pref_key,
270 const std::set<std::string>& added_values);
271
241 // Ensures and returns a mutable dictionary for extension |id|'s prefs. 272 // Ensures and returns a mutable dictionary for extension |id|'s prefs.
242 DictionaryValue* GetOrCreateExtensionPref(const std::string& id); 273 DictionaryValue* GetOrCreateExtensionPref(const std::string& id);
243 274
244 // Same as above, but returns NULL if it doesn't exist. 275 // Same as above, but returns NULL if it doesn't exist.
245 DictionaryValue* GetExtensionPref(const std::string& id) const; 276 DictionaryValue* GetExtensionPref(const std::string& id) const;
246 277
247 // Serializes the data and schedules a persistent save via the |PrefService|. 278 // Serializes the data and schedules a persistent save via the |PrefService|.
248 // Additionally fires a PREF_CHANGED notification with the top-level 279 // Additionally fires a PREF_CHANGED notification with the top-level
249 // |kExtensionsPref| path set. 280 // |kExtensionsPref| path set.
250 // TODO(andybons): Switch this to EXTENSION_PREF_CHANGED to be more granular. 281 // TODO(andybons): Switch this to EXTENSION_PREF_CHANGED to be more granular.
(...skipping 16 matching lines...) Expand all
267 // Base extensions install directory. 298 // Base extensions install directory.
268 FilePath install_directory_; 299 FilePath install_directory_;
269 300
270 // The URLs of all of the toolstrips. 301 // The URLs of all of the toolstrips.
271 URLList shelf_order_; 302 URLList shelf_order_;
272 303
273 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); 304 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs);
274 }; 305 };
275 306
276 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ 307 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698