| OLD | NEW |
| 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 // This provides a way to access the application's current preferences. | 5 // This provides a way to access the application's current preferences. |
| 6 | 6 |
| 7 // Chromium settings and storage represent user-selected preferences and | 7 // Chromium settings and storage represent user-selected preferences and |
| 8 // information and MUST not be extracted, overwritten or modified except | 8 // information and MUST not be extracted, overwritten or modified except |
| 9 // through Chromium defined APIs. | 9 // through Chromium defined APIs. |
| 10 | 10 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // ListPrefUpdate or DictionaryPrefUpdate from scoped_user_pref_update.h. | 215 // ListPrefUpdate or DictionaryPrefUpdate from scoped_user_pref_update.h. |
| 216 void Set(const std::string& path, const base::Value& value); | 216 void Set(const std::string& path, const base::Value& value); |
| 217 void SetBoolean(const std::string& path, bool value); | 217 void SetBoolean(const std::string& path, bool value); |
| 218 void SetInteger(const std::string& path, int value); | 218 void SetInteger(const std::string& path, int value); |
| 219 void SetDouble(const std::string& path, double value); | 219 void SetDouble(const std::string& path, double value); |
| 220 void SetString(const std::string& path, const std::string& value); | 220 void SetString(const std::string& path, const std::string& value); |
| 221 void SetFilePath(const std::string& path, const base::FilePath& value); | 221 void SetFilePath(const std::string& path, const base::FilePath& value); |
| 222 | 222 |
| 223 // Int64 helper methods that actually store the given value as a string. | 223 // Int64 helper methods that actually store the given value as a string. |
| 224 // Note that if obtaining the named value via GetDictionary or GetList, the | 224 // Note that if obtaining the named value via GetDictionary or GetList, the |
| 225 // Value type will be TYPE_STRING. | 225 // Value type will be Type::STRING. |
| 226 void SetInt64(const std::string& path, int64_t value); | 226 void SetInt64(const std::string& path, int64_t value); |
| 227 int64_t GetInt64(const std::string& path) const; | 227 int64_t GetInt64(const std::string& path) const; |
| 228 | 228 |
| 229 // As above, but for unsigned values. | 229 // As above, but for unsigned values. |
| 230 void SetUint64(const std::string& path, uint64_t value); | 230 void SetUint64(const std::string& path, uint64_t value); |
| 231 uint64_t GetUint64(const std::string& path) const; | 231 uint64_t GetUint64(const std::string& path) const; |
| 232 | 232 |
| 233 // Returns the value of the given preference, from the user pref store. If | 233 // Returns the value of the given preference, from the user pref store. If |
| 234 // the preference is not set in the user pref store, returns NULL. | 234 // the preference is not set in the user pref store, returns NULL. |
| 235 const base::Value* GetUserPrefValue(const std::string& path) const; | 235 const base::Value* GetUserPrefValue(const std::string& path) const; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 void SetUserPrefValue(const std::string& path, base::Value* new_value); | 358 void SetUserPrefValue(const std::string& path, base::Value* new_value); |
| 359 | 359 |
| 360 // Load preferences from storage, attempting to diagnose and handle errors. | 360 // Load preferences from storage, attempting to diagnose and handle errors. |
| 361 // This should only be called from the constructor. | 361 // This should only be called from the constructor. |
| 362 void InitFromStorage(bool async); | 362 void InitFromStorage(bool async); |
| 363 | 363 |
| 364 // Used to set the value of dictionary or list values in the user pref store. | 364 // Used to set the value of dictionary or list values in the user pref store. |
| 365 // This will create a dictionary or list if one does not exist in the user | 365 // This will create a dictionary or list if one does not exist in the user |
| 366 // pref store. This method returns NULL only if you're requesting an | 366 // pref store. This method returns NULL only if you're requesting an |
| 367 // unregistered pref or a non-dict/non-list pref. | 367 // unregistered pref or a non-dict/non-list pref. |
| 368 // |type| may only be Values::TYPE_DICTIONARY or Values::TYPE_LIST and | 368 // |type| may only be Values::Type::DICTIONARY or Values::Type::LIST and |
| 369 // |path| must point to a registered preference of type |type|. | 369 // |path| must point to a registered preference of type |type|. |
| 370 // Ownership of the returned value remains at the user pref store. | 370 // Ownership of the returned value remains at the user pref store. |
| 371 base::Value* GetMutableUserPref(const std::string& path, | 371 base::Value* GetMutableUserPref(const std::string& path, |
| 372 base::Value::Type type); | 372 base::Value::Type type); |
| 373 | 373 |
| 374 // GetPreferenceValue is the equivalent of FindPreference(path)->GetValue(), | 374 // GetPreferenceValue is the equivalent of FindPreference(path)->GetValue(), |
| 375 // it has been added for performance. If is faster because it does | 375 // it has been added for performance. If is faster because it does |
| 376 // not need to find or create a Preference object to get the | 376 // not need to find or create a Preference object to get the |
| 377 // value (GetValue() calls back though the preference service to | 377 // value (GetValue() calls back though the preference service to |
| 378 // actually get the value.). | 378 // actually get the value.). |
| 379 const base::Value* GetPreferenceValue(const std::string& path) const; | 379 const base::Value* GetPreferenceValue(const std::string& path) const; |
| 380 | 380 |
| 381 // Local cache of registered Preference objects. The pref_registry_ | 381 // Local cache of registered Preference objects. The pref_registry_ |
| 382 // is authoritative with respect to what the types and default values | 382 // is authoritative with respect to what the types and default values |
| 383 // of registered preferences are. | 383 // of registered preferences are. |
| 384 mutable PreferenceMap prefs_map_; | 384 mutable PreferenceMap prefs_map_; |
| 385 | 385 |
| 386 DISALLOW_COPY_AND_ASSIGN(PrefService); | 386 DISALLOW_COPY_AND_ASSIGN(PrefService); |
| 387 }; | 387 }; |
| 388 | 388 |
| 389 #endif // COMPONENTS_PREFS_PREF_SERVICE_H_ | 389 #endif // COMPONENTS_PREFS_PREF_SERVICE_H_ |
| OLD | NEW |