| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // Changes the default value for a preference. Takes ownership of |value|. | 214 // Changes the default value for a preference. Takes ownership of |value|. |
| 215 // | 215 // |
| 216 // Will cause a pref change notification to be fired if this causes | 216 // Will cause a pref change notification to be fired if this causes |
| 217 // the effective value to change. | 217 // the effective value to change. |
| 218 void SetDefaultPrefValue(const char* path, base::Value* value); | 218 void SetDefaultPrefValue(const char* path, base::Value* value); |
| 219 | 219 |
| 220 // Returns the default value of the given preference. |path| must point to a | 220 // Returns the default value of the given preference. |path| must point to a |
| 221 // registered preference. In that case, will never return NULL. | 221 // registered preference. In that case, will never return NULL. |
| 222 const base::Value* GetDefaultPrefValue(const char* path) const; | 222 const base::Value* GetDefaultPrefValue(const char* path) const; |
| 223 | 223 |
| 224 // Deprecated. Do not add calls to this method. | |
| 225 // Marks that the user store should not prune out empty values for |key| when | |
| 226 // writting to disk. | |
| 227 // TODO(gab): Enforce this at a lower level for all values and remove this | |
| 228 // method. | |
| 229 void MarkUserStoreNeedsEmptyValue(const std::string& key) const; | |
| 230 | |
| 231 // Returns true if a value has been set for the specified path. | 224 // Returns true if a value has been set for the specified path. |
| 232 // NOTE: this is NOT the same as FindPreference. In particular | 225 // NOTE: this is NOT the same as FindPreference. In particular |
| 233 // FindPreference returns whether RegisterXXX has been invoked, where as | 226 // FindPreference returns whether RegisterXXX has been invoked, where as |
| 234 // this checks if a value exists for the path. | 227 // this checks if a value exists for the path. |
| 235 bool HasPrefPath(const char* path) const; | 228 bool HasPrefPath(const char* path) const; |
| 236 | 229 |
| 237 // Returns a dictionary with effective preference values. The ownership | 230 // Returns a dictionary with effective preference values. The ownership |
| 238 // is passed to the caller. | 231 // is passed to the caller. |
| 239 scoped_ptr<base::DictionaryValue> GetPreferenceValues() const; | 232 scoped_ptr<base::DictionaryValue> GetPreferenceValues() const; |
| 240 | 233 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 261 // parameter will be set to true for successful initialization, | 254 // parameter will be set to true for successful initialization, |
| 262 // false for unsuccessful. | 255 // false for unsuccessful. |
| 263 void AddPrefInitObserver(base::Callback<void(bool)> callback); | 256 void AddPrefInitObserver(base::Callback<void(bool)> callback); |
| 264 | 257 |
| 265 // Returns the PrefRegistry object for this service. You should not | 258 // Returns the PrefRegistry object for this service. You should not |
| 266 // use this; the intent is for no registrations to take place after | 259 // use this; the intent is for no registrations to take place after |
| 267 // PrefService has been constructed. | 260 // PrefService has been constructed. |
| 268 PrefRegistry* DeprecatedGetPrefRegistry(); | 261 PrefRegistry* DeprecatedGetPrefRegistry(); |
| 269 | 262 |
| 270 protected: | 263 protected: |
| 271 // Adds the registered preferences from the PrefRegistry instance | |
| 272 // passed to us at construction time. | |
| 273 void AddInitialPreferences(); | |
| 274 | |
| 275 // Updates local caches for a preference registered at |path|. The | |
| 276 // |default_value| must not be NULL as it determines the preference | |
| 277 // value's type. AddRegisteredPreference must not be called twice | |
| 278 // for the same path. | |
| 279 void AddRegisteredPreference(const char* path, | |
| 280 base::Value* default_value); | |
| 281 | |
| 282 // The PrefNotifier handles registering and notifying preference observers. | 264 // The PrefNotifier handles registering and notifying preference observers. |
| 283 // It is created and owned by this PrefService. Subclasses may access it for | 265 // It is created and owned by this PrefService. Subclasses may access it for |
| 284 // unit testing. | 266 // unit testing. |
| 285 scoped_ptr<PrefNotifierImpl> pref_notifier_; | 267 scoped_ptr<PrefNotifierImpl> pref_notifier_; |
| 286 | 268 |
| 287 // The PrefValueStore provides prioritized preference values. It is owned by | 269 // The PrefValueStore provides prioritized preference values. It is owned by |
| 288 // this PrefService. Subclasses may access it for unit testing. | 270 // this PrefService. Subclasses may access it for unit testing. |
| 289 scoped_ptr<PrefValueStore> pref_value_store_; | 271 scoped_ptr<PrefValueStore> pref_value_store_; |
| 290 | 272 |
| 291 scoped_refptr<PrefRegistry> pref_registry_; | 273 scoped_refptr<PrefRegistry> pref_registry_; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 340 |
| 359 // Local cache of registered Preference objects. The pref_registry_ | 341 // Local cache of registered Preference objects. The pref_registry_ |
| 360 // is authoritative with respect to what the types and default values | 342 // is authoritative with respect to what the types and default values |
| 361 // of registered preferences are. | 343 // of registered preferences are. |
| 362 mutable PreferenceMap prefs_map_; | 344 mutable PreferenceMap prefs_map_; |
| 363 | 345 |
| 364 DISALLOW_COPY_AND_ASSIGN(PrefService); | 346 DISALLOW_COPY_AND_ASSIGN(PrefService); |
| 365 }; | 347 }; |
| 366 | 348 |
| 367 #endif // BASE_PREFS_PREF_SERVICE_H_ | 349 #endif // BASE_PREFS_PREF_SERVICE_H_ |
| OLD | NEW |