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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 // Returns the default value of the given preference. |path| must point to a | 243 // Returns the default value of the given preference. |path| must point to a |
244 // registered preference. In that case, will never return NULL. | 244 // registered preference. In that case, will never return NULL. |
245 const base::Value* GetDefaultPrefValue(const std::string& path) const; | 245 const base::Value* GetDefaultPrefValue(const std::string& path) const; |
246 | 246 |
247 // Returns true if a value has been set for the specified path. | 247 // Returns true if a value has been set for the specified path. |
248 // NOTE: this is NOT the same as FindPreference. In particular | 248 // NOTE: this is NOT the same as FindPreference. In particular |
249 // FindPreference returns whether RegisterXXX has been invoked, where as | 249 // FindPreference returns whether RegisterXXX has been invoked, where as |
250 // this checks if a value exists for the path. | 250 // this checks if a value exists for the path. |
251 bool HasPrefPath(const std::string& path) const; | 251 bool HasPrefPath(const std::string& path) const; |
252 | 252 |
253 // Returns a dictionary with effective preference values. | 253 // Issues a callback for every preference value. The preferences must not be |
254 std::unique_ptr<base::DictionaryValue> GetPreferenceValues() const; | 254 // mutated during iteration. |
255 void IteratePreferenceValues( | |
256 base::RepeatingCallback<void(const std::string& key, | |
257 const base::Value& value)> callback) const; | |
255 | 258 |
256 // Returns a dictionary with effective preference values, omitting prefs that | 259 // Returns a dictionary with effective preference values. This is an expensive |
257 // are at their default values. | 260 // operation which does a deep copy. Use only if you really need the results |
258 std::unique_ptr<base::DictionaryValue> GetPreferenceValuesOmitDefaults() | 261 // in a base::Value (for example, for JSON serialization). Otherwise use |
259 const; | 262 // IteratePreferenceValues above to avoid the copies. |
260 | 263 // |
261 // Returns a dictionary with effective preference values. Contrary to | 264 // If include_defaults is set, preferences set to their default values will |
262 // GetPreferenceValues(), the paths of registered preferences are not split on | 265 // be included. Otherwise, these will be omitted from the returned |
263 // '.' characters. If a registered preference stores a dictionary, however, | 266 // dictionary. |
264 // the hierarchical structure inside the preference will be preserved. | 267 std::unique_ptr<base::DictionaryValue> GetPreferenceValues( |
265 // For example, if "foo.bar" is a registered preference, the result could look | 268 bool include_defaults) const; |
Roger Tawa OOO till Jul 10th
2017/04/11 21:04:29
Would be better if this were an enum instead of a
brettw
2017/04/18 19:28:38
Done
| |
266 // like this: | |
267 // {"foo.bar": {"a": {"b": true}}}. | |
268 std::unique_ptr<base::DictionaryValue> | |
269 GetPreferenceValuesWithoutPathExpansion() const; | |
270 | 269 |
271 bool ReadOnly() const; | 270 bool ReadOnly() const; |
272 | 271 |
273 PrefInitializationStatus GetInitializationStatus() const; | 272 PrefInitializationStatus GetInitializationStatus() const; |
274 | 273 |
275 // Tell our PrefValueStore to update itself to |command_line_store|. | 274 // Tell our PrefValueStore to update itself to |command_line_store|. |
276 // Takes ownership of the store. | 275 // Takes ownership of the store. |
277 virtual void UpdateCommandLinePrefStore(PrefStore* command_line_store); | 276 virtual void UpdateCommandLinePrefStore(PrefStore* command_line_store); |
278 | 277 |
279 // We run the callback once, when initialization completes. The bool | 278 // We run the callback once, when initialization completes. The bool |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 | 380 |
382 // Local cache of registered Preference objects. The pref_registry_ | 381 // Local cache of registered Preference objects. The pref_registry_ |
383 // is authoritative with respect to what the types and default values | 382 // is authoritative with respect to what the types and default values |
384 // of registered preferences are. | 383 // of registered preferences are. |
385 mutable PreferenceMap prefs_map_; | 384 mutable PreferenceMap prefs_map_; |
386 | 385 |
387 DISALLOW_COPY_AND_ASSIGN(PrefService); | 386 DISALLOW_COPY_AND_ASSIGN(PrefService); |
388 }; | 387 }; |
389 | 388 |
390 #endif // COMPONENTS_PREFS_PREF_SERVICE_H_ | 389 #endif // COMPONENTS_PREFS_PREF_SERVICE_H_ |
OLD | NEW |