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

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: 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 bool IsExtensionAllowedByPolicy(const std::string& extension_id); 111 bool IsExtensionAllowedByPolicy(const std::string& extension_id);
112 112
113 // Returns the last value set via SetLastPingDay. If there isn't such a 113 // Returns the last value set via SetLastPingDay. If there isn't such a
114 // pref, the returned Time will return true for is_null(). 114 // pref, the returned Time will return true for is_null().
115 base::Time LastPingDay(const std::string& extension_id) const; 115 base::Time LastPingDay(const std::string& extension_id) const;
116 116
117 // The time stored is based on the server's perspective of day start time, not 117 // The time stored is based on the server's perspective of day start time, not
118 // the client's. 118 // the client's.
119 void SetLastPingDay(const std::string& extension_id, const base::Time& time); 119 void SetLastPingDay(const std::string& extension_id, const base::Time& time);
120 120
121 // Gets the |api_permissions| and |host_permissions| granted to the extension
122 // with |extension_id|. Returns false if no permissions were granted yet.
123 bool GetGrantedPermissions(const std::string& extension_id,
124 std::set<std::string>* api_permissions,
125 std::set<std::string>* host_permissions);
126
127 // Grants the specified |api_permissions| and |host_permissions|
128 // to the extension with |extension_id|.
129 void GrantPermissions(const std::string& extension_id,
Aaron Boodman 2010/11/12 00:05:24 Nit: how about "SetLastGrantedPermissions" and "Ge
jstritar 2010/11/19 21:38:36 I didn't include "Last" in the name since these ho
Aaron Boodman 2010/11/22 07:57:53 Neat!
130 const std::set<std::string>& api_permissions,
131 const std::set<std::string>& host_permissions);
132
121 // Similar to the 2 above, but for the extensions blacklist. 133 // Similar to the 2 above, but for the extensions blacklist.
122 base::Time BlacklistLastPingDay() const; 134 base::Time BlacklistLastPingDay() const;
123 void SetBlacklistLastPingDay(const base::Time& time); 135 void SetBlacklistLastPingDay(const base::Time& time);
124 136
125 // Returns true if the user enabled this extension to be loaded in incognito 137 // Returns true if the user enabled this extension to be loaded in incognito
126 // mode. 138 // mode.
127 bool IsIncognitoEnabled(const std::string& extension_id); 139 bool IsIncognitoEnabled(const std::string& extension_id);
128 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled); 140 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled);
129 141
130 // Returns true if the user has chosen to allow this extension to inject 142 // Returns true if the user has chosen to allow this extension to inject
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 215
204 // Sets the pref |key| for extension |id| to |value|. 216 // Sets the pref |key| for extension |id| to |value|.
205 void UpdateExtensionPref(const std::string& id, 217 void UpdateExtensionPref(const std::string& id,
206 const std::string& key, 218 const std::string& key,
207 Value* value); 219 Value* value);
208 220
209 // Deletes the pref dictionary for extension |id|. 221 // Deletes the pref dictionary for extension |id|.
210 void DeleteExtensionPrefs(const std::string& id); 222 void DeleteExtensionPrefs(const std::string& id);
211 223
212 // Reads a boolean pref from |ext| with key |pref_key|. 224 // Reads a boolean pref from |ext| with key |pref_key|.
213 // Return false if the value is false or kPrefBlacklist does not exist. 225 // Return false if the value is false or |pref_key| does not exist.
214 bool ReadBooleanFromPref(DictionaryValue* ext, const std::string& pref_key); 226 bool ReadBooleanFromPref(DictionaryValue* ext, const std::string& pref_key);
215 227
216 // Reads a boolean pref |pref_key| from extension with id |extension_id|. 228 // Reads a boolean pref |pref_key| from extension with id |extension_id|.
217 bool ReadExtensionPrefBoolean(const std::string& extension_id, 229 bool ReadExtensionPrefBoolean(const std::string& extension_id,
218 const std::string& pref_key); 230 const std::string& pref_key);
219 231
220 // Reads an integer pref from |ext| with key |pref_key|. 232 // Reads an integer pref from |ext| with key |pref_key|.
221 // Return false if the value does not exist. 233 // Return false if the value does not exist.
222 bool ReadIntegerFromPref(DictionaryValue* ext, const std::string& pref_key, 234 bool ReadIntegerFromPref(DictionaryValue* ext, const std::string& pref_key,
223 int* out_value); 235 int* out_value);
224 236
225 // Reads an integer pref |pref_key| from extension with id |extension_id|. 237 // Reads an integer pref |pref_key| from extension with id |extension_id|.
226 bool ReadExtensionPrefInteger(const std::string& extension_id, 238 bool ReadExtensionPrefInteger(const std::string& extension_id,
227 const std::string& pref_key, 239 const std::string& pref_key,
228 int* out_value); 240 int* out_value);
229 241
242 // Reads a list pref |pref_key| from extension with id | extension_id|.
243 bool ReadExtensionPrefList(const std::string& extension_id,
244 const std::string& pref_key,
245 ListValue** out_value);
246
247 // Reads a list pref |pref_key| as a string set from the extension with
248 // id |extension_id|.
249 bool ReadExtensionPrefStringSet(const std::string& extension_id,
250 const std::string& pref_key,
251 std::set<std::string>* result);
252
253 // Adds the |added_values| to the list preference at |pref_key| for the
254 // extension with id |extension_id|.
255 void AddToExtensionPrefStringSet(const std::string& extension_id,
256 const std::string& pref_key,
257 const std::set<std::string>& added_values);
258
230 // Ensures and returns a mutable dictionary for extension |id|'s prefs. 259 // Ensures and returns a mutable dictionary for extension |id|'s prefs.
231 DictionaryValue* GetOrCreateExtensionPref(const std::string& id); 260 DictionaryValue* GetOrCreateExtensionPref(const std::string& id);
232 261
233 // Same as above, but returns NULL if it doesn't exist. 262 // Same as above, but returns NULL if it doesn't exist.
234 DictionaryValue* GetExtensionPref(const std::string& id) const; 263 DictionaryValue* GetExtensionPref(const std::string& id) const;
235 264
236 // Serializes the data and schedules a persistent save via the |PrefService|. 265 // Serializes the data and schedules a persistent save via the |PrefService|.
237 // Additionally fires a PREF_CHANGED notification with the top-level 266 // Additionally fires a PREF_CHANGED notification with the top-level
238 // |kExtensionsPref| path set. 267 // |kExtensionsPref| path set.
239 // TODO(andybons): Switch this to EXTENSION_PREF_CHANGED to be more granular. 268 // TODO(andybons): Switch this to EXTENSION_PREF_CHANGED to be more granular.
(...skipping 16 matching lines...) Expand all
256 // Base extensions install directory. 285 // Base extensions install directory.
257 FilePath install_directory_; 286 FilePath install_directory_;
258 287
259 // The URLs of all of the toolstrips. 288 // The URLs of all of the toolstrips.
260 URLList shelf_order_; 289 URLList shelf_order_;
261 290
262 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); 291 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs);
263 }; 292 };
264 293
265 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ 294 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698