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

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

Powered by Google App Engine
This is Rietveld 408576698