| 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 |
| 11 #ifndef BASE_PREFS_PREF_SERVICE_H_ | 11 #ifndef BASE_PREFS_PREF_SERVICE_H_ |
| 12 #define BASE_PREFS_PREF_SERVICE_H_ | 12 #define BASE_PREFS_PREF_SERVICE_H_ |
| 13 | 13 |
| 14 #include <stdint.h> |
| 15 |
| 14 #include <set> | 16 #include <set> |
| 15 #include <string> | 17 #include <string> |
| 16 | 18 |
| 17 #include "base/callback.h" | 19 #include "base/callback.h" |
| 18 #include "base/compiler_specific.h" | 20 #include "base/compiler_specific.h" |
| 19 #include "base/containers/hash_tables.h" | 21 #include "base/containers/hash_tables.h" |
| 22 #include "base/macros.h" |
| 20 #include "base/memory/ref_counted.h" | 23 #include "base/memory/ref_counted.h" |
| 21 #include "base/memory/scoped_ptr.h" | 24 #include "base/memory/scoped_ptr.h" |
| 22 #include "base/observer_list.h" | 25 #include "base/observer_list.h" |
| 23 #include "base/prefs/base_prefs_export.h" | 26 #include "base/prefs/base_prefs_export.h" |
| 24 #include "base/prefs/persistent_pref_store.h" | 27 #include "base/prefs/persistent_pref_store.h" |
| 25 #include "base/threading/non_thread_safe.h" | 28 #include "base/threading/non_thread_safe.h" |
| 26 #include "base/values.h" | 29 #include "base/values.h" |
| 27 | 30 |
| 28 class PrefNotifier; | 31 class PrefNotifier; |
| 29 class PrefNotifierImpl; | 32 class PrefNotifierImpl; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // Preference. | 126 // Preference. |
| 124 bool IsUserModifiable() const; | 127 bool IsUserModifiable() const; |
| 125 | 128 |
| 126 // Returns true if an extension can change the Preference value, which is | 129 // Returns true if an extension can change the Preference value, which is |
| 127 // the case if no higher-priority source than the extension store controls | 130 // the case if no higher-priority source than the extension store controls |
| 128 // the Preference. | 131 // the Preference. |
| 129 bool IsExtensionModifiable() const; | 132 bool IsExtensionModifiable() const; |
| 130 | 133 |
| 131 // Return the registration flags for this pref as a bitmask of | 134 // Return the registration flags for this pref as a bitmask of |
| 132 // PrefRegistry::PrefRegistrationFlags. | 135 // PrefRegistry::PrefRegistrationFlags. |
| 133 uint32 registration_flags() const { return registration_flags_; } | 136 uint32_t registration_flags() const { return registration_flags_; } |
| 134 | 137 |
| 135 private: | 138 private: |
| 136 friend class PrefService; | 139 friend class PrefService; |
| 137 | 140 |
| 138 PrefValueStore* pref_value_store() const { | 141 PrefValueStore* pref_value_store() const { |
| 139 return pref_service_->pref_value_store_.get(); | 142 return pref_service_->pref_value_store_.get(); |
| 140 } | 143 } |
| 141 | 144 |
| 142 const std::string name_; | 145 const std::string name_; |
| 143 | 146 |
| 144 const base::Value::Type type_; | 147 const base::Value::Type type_; |
| 145 | 148 |
| 146 uint32 registration_flags_; | 149 uint32_t registration_flags_; |
| 147 | 150 |
| 148 // Reference to the PrefService in which this pref was created. | 151 // Reference to the PrefService in which this pref was created. |
| 149 const PrefService* pref_service_; | 152 const PrefService* pref_service_; |
| 150 }; | 153 }; |
| 151 | 154 |
| 152 // You may wish to use PrefServiceFactory or one of its subclasses | 155 // You may wish to use PrefServiceFactory or one of its subclasses |
| 153 // for simplified construction. | 156 // for simplified construction. |
| 154 PrefService( | 157 PrefService( |
| 155 PrefNotifierImpl* pref_notifier, | 158 PrefNotifierImpl* pref_notifier, |
| 156 PrefValueStore* pref_value_store, | 159 PrefValueStore* pref_value_store, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 void Set(const std::string& path, const base::Value& value); | 216 void Set(const std::string& path, const base::Value& value); |
| 214 void SetBoolean(const std::string& path, bool value); | 217 void SetBoolean(const std::string& path, bool value); |
| 215 void SetInteger(const std::string& path, int value); | 218 void SetInteger(const std::string& path, int value); |
| 216 void SetDouble(const std::string& path, double value); | 219 void SetDouble(const std::string& path, double value); |
| 217 void SetString(const std::string& path, const std::string& value); | 220 void SetString(const std::string& path, const std::string& value); |
| 218 void SetFilePath(const std::string& path, const base::FilePath& value); | 221 void SetFilePath(const std::string& path, const base::FilePath& value); |
| 219 | 222 |
| 220 // 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. |
| 221 // 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 |
| 222 // Value type will be TYPE_STRING. | 225 // Value type will be TYPE_STRING. |
| 223 void SetInt64(const std::string& path, int64 value); | 226 void SetInt64(const std::string& path, int64_t value); |
| 224 int64 GetInt64(const std::string& path) const; | 227 int64_t GetInt64(const std::string& path) const; |
| 225 | 228 |
| 226 // As above, but for unsigned values. | 229 // As above, but for unsigned values. |
| 227 void SetUint64(const std::string& path, uint64 value); | 230 void SetUint64(const std::string& path, uint64_t value); |
| 228 uint64 GetUint64(const std::string& path) const; | 231 uint64_t GetUint64(const std::string& path) const; |
| 229 | 232 |
| 230 // 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 |
| 231 // 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. |
| 232 const base::Value* GetUserPrefValue(const std::string& path) const; | 235 const base::Value* GetUserPrefValue(const std::string& path) const; |
| 233 | 236 |
| 234 // Changes the default value for a preference. Takes ownership of |value|. | 237 // Changes the default value for a preference. Takes ownership of |value|. |
| 235 // | 238 // |
| 236 // Will cause a pref change notification to be fired if this causes | 239 // Will cause a pref change notification to be fired if this causes |
| 237 // the effective value to change. | 240 // the effective value to change. |
| 238 void SetDefaultPrefValue(const std::string& path, base::Value* value); | 241 void SetDefaultPrefValue(const std::string& path, base::Value* value); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 376 |
| 374 // Local cache of registered Preference objects. The pref_registry_ | 377 // Local cache of registered Preference objects. The pref_registry_ |
| 375 // is authoritative with respect to what the types and default values | 378 // is authoritative with respect to what the types and default values |
| 376 // of registered preferences are. | 379 // of registered preferences are. |
| 377 mutable PreferenceMap prefs_map_; | 380 mutable PreferenceMap prefs_map_; |
| 378 | 381 |
| 379 DISALLOW_COPY_AND_ASSIGN(PrefService); | 382 DISALLOW_COPY_AND_ASSIGN(PrefService); |
| 380 }; | 383 }; |
| 381 | 384 |
| 382 #endif // BASE_PREFS_PREF_SERVICE_H_ | 385 #endif // BASE_PREFS_PREF_SERVICE_H_ |
| OLD | NEW |