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 CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_ |
6 #define CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/containers/scoped_ptr_hash_map.h" | 15 #include "base/containers/scoped_ptr_hash_map.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/prefs/pref_filter.h" | 17 #include "base/prefs/pref_filter.h" |
18 #include "chrome/browser/prefs/pref_hash_store.h" | 18 #include "chrome/browser/prefs/pref_hash_store.h" |
19 #include "chrome/browser/prefs/tracked/tracked_preference.h" | 19 #include "chrome/browser/prefs/tracked/tracked_preference.h" |
20 | 20 |
| 21 class PersistentPrefStore; |
21 class PrefService; | 22 class PrefService; |
22 class PrefStore; | 23 class PrefStore; |
23 | 24 |
24 namespace base { | 25 namespace base { |
25 class DictionaryValue; | 26 class DictionaryValue; |
26 class Time; | 27 class Time; |
27 class Value; | 28 class Value; |
28 } // namespace base | 29 } // namespace base |
29 | 30 |
30 namespace user_prefs { | 31 namespace user_prefs { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 static base::Time GetResetTime(PrefService* user_prefs); | 77 static base::Time GetResetTime(PrefService* user_prefs); |
77 | 78 |
78 // Clears the time of the last reset event, if any, for the provided user | 79 // Clears the time of the last reset event, if any, for the provided user |
79 // preferences. | 80 // preferences. |
80 static void ClearResetTime(PrefService* user_prefs); | 81 static void ClearResetTime(PrefService* user_prefs); |
81 | 82 |
82 // Initializes the PrefHashStore with hashes of the tracked preferences in | 83 // Initializes the PrefHashStore with hashes of the tracked preferences in |
83 // |pref_store|. | 84 // |pref_store|. |
84 void Initialize(const PrefStore& pref_store); | 85 void Initialize(const PrefStore& pref_store); |
85 | 86 |
| 87 // Migrates protected values from |source| to |destination|. Values are |
| 88 // migrated if they are protected according to this filter's configuration, |
| 89 // the corresponding key has no value in |destination|, and the value in |
| 90 // |source| is trusted according to this filter's PrefHashStore. Regardless of |
| 91 // the state of |destination| or the trust status, the protected values will |
| 92 // be removed from |source|. |
| 93 void MigrateValues(PersistentPrefStore* source, |
| 94 PersistentPrefStore* destination); |
| 95 |
86 // PrefFilter implementation. | 96 // PrefFilter implementation. |
87 virtual void FilterOnLoad(base::DictionaryValue* pref_store_contents) | 97 virtual void FilterOnLoad(base::DictionaryValue* pref_store_contents) |
88 OVERRIDE; | 98 OVERRIDE; |
89 virtual void FilterUpdate(const std::string& path) OVERRIDE; | 99 virtual void FilterUpdate(const std::string& path) OVERRIDE; |
90 virtual void FilterSerializeData( | 100 virtual void FilterSerializeData( |
91 const base::DictionaryValue* pref_store_contents) OVERRIDE; | 101 const base::DictionaryValue* pref_store_contents) OVERRIDE; |
92 | 102 |
93 private: | 103 private: |
94 // A map of paths to TrackedPreferences; this map owns this individual | 104 // A map of paths to TrackedPreferences; this map owns this individual |
95 // TrackedPreference objects. | 105 // TrackedPreference objects. |
96 typedef base::ScopedPtrHashMap<std::string, TrackedPreference> | 106 typedef base::ScopedPtrHashMap<std::string, TrackedPreference> |
97 TrackedPreferencesMap; | 107 TrackedPreferencesMap; |
98 // A map from changed paths to their corresponding TrackedPreferences (which | 108 // A map from changed paths to their corresponding TrackedPreferences (which |
99 // aren't owned by this map). | 109 // aren't owned by this map). |
100 typedef std::map<std::string, const TrackedPreference*> ChangedPathsMap; | 110 typedef std::map<std::string, const TrackedPreference*> ChangedPathsMap; |
101 | 111 |
102 scoped_ptr<PrefHashStore> pref_hash_store_; | 112 scoped_ptr<PrefHashStore> pref_hash_store_; |
103 | 113 |
104 TrackedPreferencesMap tracked_paths_; | 114 TrackedPreferencesMap tracked_paths_; |
105 | 115 |
106 // The set of all paths whose value has changed since the last call to | 116 // The set of all paths whose value has changed since the last call to |
107 // FilterSerializeData. | 117 // FilterSerializeData. |
108 ChangedPathsMap changed_paths_; | 118 ChangedPathsMap changed_paths_; |
109 | 119 |
110 DISALLOW_COPY_AND_ASSIGN(PrefHashFilter); | 120 DISALLOW_COPY_AND_ASSIGN(PrefHashFilter); |
111 }; | 121 }; |
112 | 122 |
113 #endif // CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_ | 123 #endif // CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_ |
OLD | NEW |