| OLD | NEW |
| 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 Loading... |
| 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 permissions (|api_permissions|, |host_extent| and |full_access|) |
| 127 // granted to the extension with |extension_id|. |full_access| will be true |
| 128 // if the extension has all effective permissions (like from an NPAPI plugin). |
| 129 // Returns false if the granted permissions haven't been initialized yet. |
| 130 // TODO(jstritar): Refractor the permissions into a class that encapsulates |
| 131 // all granted permissions, can be initialized from preferences or |
| 132 // a manifest file, and can be compared to each other. |
| 133 bool GetGrantedPermissions(const std::string& extension_id, |
| 134 bool* full_access, |
| 135 std::set<std::string>* api_permissions, |
| 136 ExtensionExtent* host_extent); |
| 137 |
| 138 // Adds the specified |api_permissions|, |host_extent| and |full_access| |
| 139 // to the granted permissions for extension with |extension_id|. |
| 140 // |full_access| should be set to true if the extension effectively has all |
| 141 // permissions (such as by having an NPAPI plugin). |
| 142 void AddGrantedPermissions(const std::string& extension_id, |
| 143 const bool full_access, |
| 144 const std::set<std::string>& api_permissions, |
| 145 const ExtensionExtent& host_extent); |
| 146 |
| 126 // Similar to the 2 above, but for the extensions blacklist. | 147 // Similar to the 2 above, but for the extensions blacklist. |
| 127 base::Time BlacklistLastPingDay() const; | 148 base::Time BlacklistLastPingDay() const; |
| 128 void SetBlacklistLastPingDay(const base::Time& time); | 149 void SetBlacklistLastPingDay(const base::Time& time); |
| 129 | 150 |
| 130 // Returns true if the user enabled this extension to be loaded in incognito | 151 // Returns true if the user enabled this extension to be loaded in incognito |
| 131 // mode. | 152 // mode. |
| 132 bool IsIncognitoEnabled(const std::string& extension_id); | 153 bool IsIncognitoEnabled(const std::string& extension_id); |
| 133 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled); | 154 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled); |
| 134 | 155 |
| 135 // Returns true if the user has chosen to allow this extension to inject | 156 // 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 Loading... |
| 215 | 236 |
| 216 // Sets the pref |key| for extension |id| to |value|. | 237 // Sets the pref |key| for extension |id| to |value|. |
| 217 void UpdateExtensionPref(const std::string& id, | 238 void UpdateExtensionPref(const std::string& id, |
| 218 const std::string& key, | 239 const std::string& key, |
| 219 Value* value); | 240 Value* value); |
| 220 | 241 |
| 221 // Deletes the pref dictionary for extension |id|. | 242 // Deletes the pref dictionary for extension |id|. |
| 222 void DeleteExtensionPrefs(const std::string& id); | 243 void DeleteExtensionPrefs(const std::string& id); |
| 223 | 244 |
| 224 // Reads a boolean pref from |ext| with key |pref_key|. | 245 // Reads a boolean pref from |ext| with key |pref_key|. |
| 225 // Return false if the value is false or kPrefBlacklist does not exist. | 246 // Return false if the value is false or |pref_key| does not exist. |
| 226 bool ReadBooleanFromPref(DictionaryValue* ext, const std::string& pref_key); | 247 bool ReadBooleanFromPref(DictionaryValue* ext, const std::string& pref_key); |
| 227 | 248 |
| 228 // Reads a boolean pref |pref_key| from extension with id |extension_id|. | 249 // Reads a boolean pref |pref_key| from extension with id |extension_id|. |
| 229 bool ReadExtensionPrefBoolean(const std::string& extension_id, | 250 bool ReadExtensionPrefBoolean(const std::string& extension_id, |
| 230 const std::string& pref_key); | 251 const std::string& pref_key); |
| 231 | 252 |
| 232 // Reads an integer pref from |ext| with key |pref_key|. | 253 // Reads an integer pref from |ext| with key |pref_key|. |
| 233 // Return false if the value does not exist. | 254 // Return false if the value does not exist. |
| 234 bool ReadIntegerFromPref(DictionaryValue* ext, const std::string& pref_key, | 255 bool ReadIntegerFromPref(DictionaryValue* ext, const std::string& pref_key, |
| 235 int* out_value); | 256 int* out_value); |
| 236 | 257 |
| 237 // Reads an integer pref |pref_key| from extension with id |extension_id|. | 258 // Reads an integer pref |pref_key| from extension with id |extension_id|. |
| 238 bool ReadExtensionPrefInteger(const std::string& extension_id, | 259 bool ReadExtensionPrefInteger(const std::string& extension_id, |
| 239 const std::string& pref_key, | 260 const std::string& pref_key, |
| 240 int* out_value); | 261 int* out_value); |
| 241 | 262 |
| 263 // Reads a list pref |pref_key| from extension with id | extension_id|. |
| 264 bool ReadExtensionPrefList(const std::string& extension_id, |
| 265 const std::string& pref_key, |
| 266 ListValue** out_value); |
| 267 |
| 268 // Reads a list pref |pref_key| as a string set from the extension with |
| 269 // id |extension_id|. |
| 270 bool ReadExtensionPrefStringSet(const std::string& extension_id, |
| 271 const std::string& pref_key, |
| 272 std::set<std::string>* result); |
| 273 |
| 274 // Adds the |added_values| to the value of |pref_key| for the extension |
| 275 // with id |extension_id| (the new value will be the union of the existing |
| 276 // value and |added_values|). |
| 277 void AddToExtensionPrefStringSet(const std::string& extension_id, |
| 278 const std::string& pref_key, |
| 279 const std::set<std::string>& added_values); |
| 280 |
| 242 // Ensures and returns a mutable dictionary for extension |id|'s prefs. | 281 // Ensures and returns a mutable dictionary for extension |id|'s prefs. |
| 243 DictionaryValue* GetOrCreateExtensionPref(const std::string& id); | 282 DictionaryValue* GetOrCreateExtensionPref(const std::string& id); |
| 244 | 283 |
| 245 // Same as above, but returns NULL if it doesn't exist. | 284 // Same as above, but returns NULL if it doesn't exist. |
| 246 DictionaryValue* GetExtensionPref(const std::string& id) const; | 285 DictionaryValue* GetExtensionPref(const std::string& id) const; |
| 247 | 286 |
| 248 // Serializes the data and schedules a persistent save via the |PrefService|. | 287 // Serializes the data and schedules a persistent save via the |PrefService|. |
| 249 // Additionally fires a PREF_CHANGED notification with the top-level | 288 // Additionally fires a PREF_CHANGED notification with the top-level |
| 250 // |kExtensionsPref| path set. | 289 // |kExtensionsPref| path set. |
| 251 // TODO(andybons): Switch this to EXTENSION_PREF_CHANGED to be more granular. | 290 // TODO(andybons): Switch this to EXTENSION_PREF_CHANGED to be more granular. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 268 // Base extensions install directory. | 307 // Base extensions install directory. |
| 269 FilePath install_directory_; | 308 FilePath install_directory_; |
| 270 | 309 |
| 271 // The URLs of all of the toolstrips. | 310 // The URLs of all of the toolstrips. |
| 272 URLList shelf_order_; | 311 URLList shelf_order_; |
| 273 | 312 |
| 274 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 313 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
| 275 }; | 314 }; |
| 276 | 315 |
| 277 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ | 316 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
| OLD | NEW |