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; |
19 class PersistentPrefStore; | 20 class PersistentPrefStore; |
20 class PrefHashStore; | 21 class PrefHashStore; |
21 class PrefService; | 22 class PrefService; |
22 class TrackedPreferenceValidationDelegate; | 23 class TrackedPreferenceValidationDelegate; |
23 | 24 |
24 namespace base { | 25 namespace base { |
25 class DictionaryValue; | 26 class DictionaryValue; |
26 class SequencedTaskRunner; | 27 class SequencedTaskRunner; |
27 } // namespace base | 28 } // namespace base |
28 | 29 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // |pref_service|. Assumes that |pref_service| is backed by a PrefStore that | 64 // |pref_service|. Assumes that |pref_service| is backed by a PrefStore that |
64 // was built by ProfilePrefStoreManager. | 65 // was built by ProfilePrefStoreManager. |
65 // If no reset has occurred, returns a null |Time|. | 66 // If no reset has occurred, returns a null |Time|. |
66 static base::Time GetResetTime(PrefService* pref_service); | 67 static base::Time GetResetTime(PrefService* pref_service); |
67 | 68 |
68 // Clears the time of the last preference reset event, if any, for | 69 // Clears the time of the last preference reset event, if any, for |
69 // |pref_service|. Assumes that |pref_service| is backed by a PrefStore that | 70 // |pref_service|. Assumes that |pref_service| is backed by a PrefStore that |
70 // was built by ProfilePrefStoreManager. | 71 // was built by ProfilePrefStoreManager. |
71 static void ClearResetTime(PrefService* pref_service); | 72 static void ClearResetTime(PrefService* pref_service); |
72 | 73 |
| 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 |
73 // Creates a PersistentPrefStore providing access to the user preferences of | 82 // Creates a PersistentPrefStore providing access to the user preferences of |
74 // the managed profile. If |on_reset| is provided, it will be invoked if a | 83 // the managed profile. If |on_reset| is provided, it will be invoked if a |
75 // reset occurs as a result of loading the profile's prefs. | 84 // reset occurs as a result of loading the profile's prefs. |
76 // An optional |validation_delegate| will be notified | 85 // An optional |validation_delegate| will be notified |
77 // of the status of each tracked preference as they are checked. | 86 // of the status of each tracked preference as they are checked. |
78 PersistentPrefStore* CreateProfilePrefStore( | 87 PersistentPrefStore* CreateProfilePrefStore( |
79 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, | 88 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, |
80 const base::Closure& on_reset_on_load, | 89 const base::Closure& on_reset_on_load, |
81 TrackedPreferenceValidationDelegate* validation_delegate); | 90 TrackedPreferenceValidationDelegate* validation_delegate); |
82 | 91 |
83 // Initializes the preferences for the managed profile with the preference | 92 // Initializes the preferences for the managed profile with the preference |
84 // values in |master_prefs|. Acts synchronously, including blocking IO. | 93 // values in |master_prefs|. Acts synchronously, including blocking IO. |
85 // Returns true on success. | 94 // Returns true on success. |
86 bool InitializePrefsFromMasterPrefs( | 95 bool InitializePrefsFromMasterPrefs( |
87 const base::DictionaryValue& master_prefs); | 96 const base::DictionaryValue& master_prefs); |
88 | 97 |
89 // Creates a single-file PrefStore as was used in M34 and earlier. Used only | 98 // Creates a single-file PrefStore as was used in M34 and earlier. Used only |
90 // for testing migration. | 99 // for testing migration. |
91 PersistentPrefStore* CreateDeprecatedCombinedProfilePrefStore( | 100 PersistentPrefStore* CreateDeprecatedCombinedProfilePrefStore( |
92 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); | 101 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); |
93 | 102 |
94 private: | 103 private: |
95 // Returns a PrefHashStore for the managed profile. Should only be called | 104 // Returns a PrefHashStore for the managed profile. Should only be called |
96 // if |kPlatformSupportsPreferenceTracking|. |use_super_mac| determines | 105 // if |kPlatformSupportsPreferenceTracking|. |use_super_mac| determines |
97 // whether the returned object will calculate, store, and validate super MACs | 106 // whether the returned object will calculate, store, and validate super MACs |
98 // (and, by extension, accept non-null newly protected preferences as | 107 // (and, by extension, accept non-null newly protected preferences as |
99 // TrustedInitialized). | 108 // TrustedInitialized). |
100 std::unique_ptr<PrefHashStore> GetPrefHashStore(bool use_super_mac); | 109 std::unique_ptr<PrefHashStore> GetPrefHashStore(bool use_super_mac); |
101 | 110 |
| 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 |
102 const base::FilePath profile_path_; | 117 const base::FilePath profile_path_; |
103 const std::vector<PrefHashFilter::TrackedPreferenceMetadata> | 118 const std::vector<PrefHashFilter::TrackedPreferenceMetadata> |
104 tracking_configuration_; | 119 tracking_configuration_; |
105 const size_t reporting_ids_count_; | 120 const size_t reporting_ids_count_; |
106 const std::string seed_; | 121 const std::string seed_; |
107 const std::string device_id_; | 122 const std::string device_id_; |
108 PrefService* local_state_; | 123 PrefService* local_state_; |
109 | 124 |
110 DISALLOW_COPY_AND_ASSIGN(ProfilePrefStoreManager); | 125 DISALLOW_COPY_AND_ASSIGN(ProfilePrefStoreManager); |
111 }; | 126 }; |
112 | 127 |
113 #endif // CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_ | 128 #endif // CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_ |
OLD | NEW |