OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PROFILE_PREF_STORE_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_ |
6 #define CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_ | 6 #define CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "components/user_prefs/tracked/pref_hash_filter.h" | 17 #include "components/user_prefs/tracked/pref_hash_filter.h" |
18 | 18 |
19 class HashStoreContents; | |
20 class PersistentPrefStore; | 19 class PersistentPrefStore; |
21 class PrefHashStore; | 20 class PrefHashStore; |
22 class PrefService; | 21 class PrefService; |
23 class TrackedPreferenceValidationDelegate; | 22 class TrackedPreferenceValidationDelegate; |
24 | 23 |
25 namespace base { | 24 namespace base { |
26 class DictionaryValue; | 25 class DictionaryValue; |
27 class SequencedTaskRunner; | 26 class SequencedTaskRunner; |
28 } // namespace base | 27 } // namespace base |
29 | 28 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // |pref_service|. Assumes that |pref_service| is backed by a PrefStore that | 63 // |pref_service|. Assumes that |pref_service| is backed by a PrefStore that |
65 // was built by ProfilePrefStoreManager. | 64 // was built by ProfilePrefStoreManager. |
66 // If no reset has occurred, returns a null |Time|. | 65 // If no reset has occurred, returns a null |Time|. |
67 static base::Time GetResetTime(PrefService* pref_service); | 66 static base::Time GetResetTime(PrefService* pref_service); |
68 | 67 |
69 // Clears the time of the last preference reset event, if any, for | 68 // Clears the time of the last preference reset event, if any, for |
70 // |pref_service|. Assumes that |pref_service| is backed by a PrefStore that | 69 // |pref_service|. Assumes that |pref_service| is backed by a PrefStore that |
71 // was built by ProfilePrefStoreManager. | 70 // was built by ProfilePrefStoreManager. |
72 static void ClearResetTime(PrefService* pref_service); | 71 static void ClearResetTime(PrefService* pref_service); |
73 | 72 |
74 #if defined(OS_WIN) | |
75 // Call before startup tasks kick in to use a different registry path for | |
76 // storing and validating tracked preference MACs. Callers are responsible | |
77 // for ensuring that the key is deleted on shutdown. For testing only. | |
78 static void SetPreferenceValidationRegistryPathForTesting( | |
79 const base::string16* path); | |
80 #endif | |
81 | |
82 // Creates a PersistentPrefStore providing access to the user preferences of | 73 // Creates a PersistentPrefStore providing access to the user preferences of |
83 // the managed profile. If |on_reset| is provided, it will be invoked if a | 74 // the managed profile. If |on_reset| is provided, it will be invoked if a |
84 // reset occurs as a result of loading the profile's prefs. | 75 // reset occurs as a result of loading the profile's prefs. |
85 // An optional |validation_delegate| will be notified | 76 // An optional |validation_delegate| will be notified |
86 // of the status of each tracked preference as they are checked. | 77 // of the status of each tracked preference as they are checked. |
87 PersistentPrefStore* CreateProfilePrefStore( | 78 PersistentPrefStore* CreateProfilePrefStore( |
88 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, | 79 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, |
89 const base::Closure& on_reset_on_load, | 80 const base::Closure& on_reset_on_load, |
90 TrackedPreferenceValidationDelegate* validation_delegate); | 81 TrackedPreferenceValidationDelegate* validation_delegate); |
91 | 82 |
92 // Initializes the preferences for the managed profile with the preference | 83 // Initializes the preferences for the managed profile with the preference |
93 // values in |master_prefs|. Acts synchronously, including blocking IO. | 84 // values in |master_prefs|. Acts synchronously, including blocking IO. |
94 // Returns true on success. | 85 // Returns true on success. |
95 bool InitializePrefsFromMasterPrefs( | 86 bool InitializePrefsFromMasterPrefs( |
96 const base::DictionaryValue& master_prefs); | 87 const base::DictionaryValue& master_prefs); |
97 | 88 |
98 // Creates a single-file PrefStore as was used in M34 and earlier. Used only | 89 // Creates a single-file PrefStore as was used in M34 and earlier. Used only |
99 // for testing migration. | 90 // for testing migration. |
100 PersistentPrefStore* CreateDeprecatedCombinedProfilePrefStore( | 91 PersistentPrefStore* CreateDeprecatedCombinedProfilePrefStore( |
101 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); | 92 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); |
102 | 93 |
103 private: | 94 private: |
104 // Returns a PrefHashStore for the managed profile. Should only be called | 95 // Returns a PrefHashStore for the managed profile. Should only be called |
105 // if |kPlatformSupportsPreferenceTracking|. |use_super_mac| determines | 96 // if |kPlatformSupportsPreferenceTracking|. |use_super_mac| determines |
106 // whether the returned object will calculate, store, and validate super MACs | 97 // whether the returned object will calculate, store, and validate super MACs |
107 // (and, by extension, accept non-null newly protected preferences as | 98 // (and, by extension, accept non-null newly protected preferences as |
108 // TrustedInitialized). | 99 // TrustedInitialized). |
109 std::unique_ptr<PrefHashStore> GetPrefHashStore(bool use_super_mac); | 100 std::unique_ptr<PrefHashStore> GetPrefHashStore(bool use_super_mac); |
110 | 101 |
111 // Returns a PrefHashStore and HashStoreContents which can be be used for | |
112 // extra out-of-band verifications, or nullptrs if not available on this | |
113 // platform. | |
114 std::pair<std::unique_ptr<PrefHashStore>, std::unique_ptr<HashStoreContents>> | |
115 GetExternalVerificationPrefHashStorePair(); | |
116 | |
117 const base::FilePath profile_path_; | 102 const base::FilePath profile_path_; |
118 const std::vector<PrefHashFilter::TrackedPreferenceMetadata> | 103 const std::vector<PrefHashFilter::TrackedPreferenceMetadata> |
119 tracking_configuration_; | 104 tracking_configuration_; |
120 const size_t reporting_ids_count_; | 105 const size_t reporting_ids_count_; |
121 const std::string seed_; | 106 const std::string seed_; |
122 const std::string device_id_; | 107 const std::string device_id_; |
123 PrefService* local_state_; | 108 PrefService* local_state_; |
124 | 109 |
125 DISALLOW_COPY_AND_ASSIGN(ProfilePrefStoreManager); | 110 DISALLOW_COPY_AND_ASSIGN(ProfilePrefStoreManager); |
126 }; | 111 }; |
127 | 112 |
128 #endif // CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_ | 113 #endif // CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_ |
OLD | NEW |