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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Returns a dictionary with effective preference values. |
254 scoped_ptr<base::DictionaryValue> GetPreferenceValues() const; | 254 scoped_ptr<base::DictionaryValue> GetPreferenceValues() const; |
255 | 255 |
256 // Returns a dictionary with effective preference values, omitting prefs that | 256 // Returns a dictionary with effective preference values, omitting prefs that |
257 // are at their default values. | 257 // are at their default values. |
258 scoped_ptr<base::DictionaryValue> GetPreferenceValuesOmitDefaults() const; | 258 scoped_ptr<base::DictionaryValue> GetPreferenceValuesOmitDefaults() const; |
259 | 259 |
| 260 // Same as GetPreferenceValuesOmitDefaults, but also filters out preferences |
| 261 // keys that do not match one of the prefixes in |whitelisted_prefixes|. |
| 262 scoped_ptr<base::DictionaryValue> GetWhitelistedPreferenceValuesOmitDefaults( |
| 263 const std::vector<std::string>& whitelisted_prefixes) const; |
| 264 |
260 // Returns a dictionary with effective preference values. Contrary to | 265 // Returns a dictionary with effective preference values. Contrary to |
261 // GetPreferenceValues(), the paths of registered preferences are not split on | 266 // GetPreferenceValues(), the paths of registered preferences are not split on |
262 // '.' characters. If a registered preference stores a dictionary, however, | 267 // '.' characters. If a registered preference stores a dictionary, however, |
263 // the hierarchical structure inside the preference will be preserved. | 268 // the hierarchical structure inside the preference will be preserved. |
264 // For example, if "foo.bar" is a registered preference, the result could look | 269 // For example, if "foo.bar" is a registered preference, the result could look |
265 // like this: | 270 // like this: |
266 // {"foo.bar": {"a": {"b": true}}}. | 271 // {"foo.bar": {"a": {"b": true}}}. |
267 scoped_ptr<base::DictionaryValue> GetPreferenceValuesWithoutPathExpansion() | 272 scoped_ptr<base::DictionaryValue> GetPreferenceValuesWithoutPathExpansion() |
268 const; | 273 const; |
269 | 274 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 // | 346 // |
342 // If the pref at the given path changes, we call the observer's | 347 // If the pref at the given path changes, we call the observer's |
343 // OnPreferenceChanged method. Note that observers should not call | 348 // OnPreferenceChanged method. Note that observers should not call |
344 // these methods directly but rather use a PrefChangeRegistrar to | 349 // these methods directly but rather use a PrefChangeRegistrar to |
345 // make sure the observer gets cleaned up properly. | 350 // make sure the observer gets cleaned up properly. |
346 // | 351 // |
347 // Virtual for testing. | 352 // Virtual for testing. |
348 virtual void AddPrefObserver(const std::string& path, PrefObserver* obs); | 353 virtual void AddPrefObserver(const std::string& path, PrefObserver* obs); |
349 virtual void RemovePrefObserver(const std::string& path, PrefObserver* obs); | 354 virtual void RemovePrefObserver(const std::string& path, PrefObserver* obs); |
350 | 355 |
| 356 // Helper function that adds a preference value to a dictionary if it is not |
| 357 // at its default value. |
| 358 void SetPreferenceOmitdefault(const std::string& pref_name, |
| 359 base::DictionaryValue* out) const; |
| 360 |
351 // Sends notification of a changed preference. This needs to be called by | 361 // Sends notification of a changed preference. This needs to be called by |
352 // a ScopedUserPrefUpdate if a DictionaryValue or ListValue is changed. | 362 // a ScopedUserPrefUpdate if a DictionaryValue or ListValue is changed. |
353 void ReportUserPrefChanged(const std::string& key); | 363 void ReportUserPrefChanged(const std::string& key); |
354 | 364 |
355 // Sets the value for this pref path in the user pref store and informs the | 365 // Sets the value for this pref path in the user pref store and informs the |
356 // PrefNotifier of the change. | 366 // PrefNotifier of the change. |
357 void SetUserPrefValue(const std::string& path, base::Value* new_value); | 367 void SetUserPrefValue(const std::string& path, base::Value* new_value); |
358 | 368 |
359 // Load preferences from storage, attempting to diagnose and handle errors. | 369 // Load preferences from storage, attempting to diagnose and handle errors. |
360 // This should only be called from the constructor. | 370 // This should only be called from the constructor. |
(...skipping 18 matching lines...) Expand all Loading... |
379 | 389 |
380 // Local cache of registered Preference objects. The pref_registry_ | 390 // Local cache of registered Preference objects. The pref_registry_ |
381 // is authoritative with respect to what the types and default values | 391 // is authoritative with respect to what the types and default values |
382 // of registered preferences are. | 392 // of registered preferences are. |
383 mutable PreferenceMap prefs_map_; | 393 mutable PreferenceMap prefs_map_; |
384 | 394 |
385 DISALLOW_COPY_AND_ASSIGN(PrefService); | 395 DISALLOW_COPY_AND_ASSIGN(PrefService); |
386 }; | 396 }; |
387 | 397 |
388 #endif // COMPONENTS_PREFS_PREF_SERVICE_H_ | 398 #endif // COMPONENTS_PREFS_PREF_SERVICE_H_ |
OLD | NEW |