OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef BASE_PREFS_PREF_FILTER_H_ | 5 #ifndef BASE_PREFS_PREF_FILTER_H_ |
6 #define BASE_PREFS_PREF_FILTER_H_ | 6 #define BASE_PREFS_PREF_FILTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/prefs/base_prefs_export.h" | 10 #include "base/prefs/base_prefs_export.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class DictionaryValue; | 13 class DictionaryValue; |
14 class Value; | 14 class Value; |
15 } // namespace base | 15 } // namespace base |
16 | 16 |
17 // Filters preferences as they are loaded from disk or updated at runtime. | 17 // Filters preferences as they are loaded from disk or updated at runtime. |
18 // Currently supported only by JsonPrefStore. | 18 // Currently supported only by JsonPrefStore. |
19 class BASE_PREFS_EXPORT PrefFilter { | 19 class BASE_PREFS_EXPORT PrefFilter { |
20 public: | 20 public: |
21 virtual ~PrefFilter() {} | 21 virtual ~PrefFilter() {} |
22 | 22 |
23 // Receives notification when the pref store data has been loaded but before | 23 // Receives notification when the pref store data has been loaded but before |
24 // Observers are notified. | 24 // Observers are notified. |
25 // Changes made by a PrefFilter during FilterOnLoad do not result in | 25 // Changes made by a PrefFilter during FilterOnLoad do not result in |
26 // notifications to |PrefStore::Observer|s. | 26 // notifications to |PrefStore::Observer|s. |
27 virtual void FilterOnLoad(base::DictionaryValue* pref_store_contents) = 0; | 27 // Implementations should return true if they modify the dictionary, to allow |
| 28 // the changes to be persisted. |
| 29 virtual bool FilterOnLoad(base::DictionaryValue* pref_store_contents) = 0; |
28 | 30 |
29 // Receives notification when a pref store value is changed, before Observers | 31 // Receives notification when a pref store value is changed, before Observers |
30 // are notified. | 32 // are notified. |
31 virtual void FilterUpdate(const std::string& path) = 0; | 33 virtual void FilterUpdate(const std::string& path) = 0; |
32 | 34 |
33 // Receives notification when the pref store is about to serialize data | 35 // Receives notification when the pref store is about to serialize data |
34 // contained in |pref_store_contents| to a string. | 36 // contained in |pref_store_contents| to a string. |
35 virtual void FilterSerializeData( | 37 virtual void FilterSerializeData( |
36 const base::DictionaryValue* pref_store_contents) = 0; | 38 const base::DictionaryValue* pref_store_contents) = 0; |
37 }; | 39 }; |
38 | 40 |
39 #endif // BASE_PREFS_PREF_FILTER_H_ | 41 #endif // BASE_PREFS_PREF_FILTER_H_ |
OLD | NEW |