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> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // (possibly greater than |tracking_configuration.size()|). | 47 // (possibly greater than |tracking_configuration.size()|). |
48 // |seed| and |legacy_device_id| are used to track preference value changes | 48 // |seed| and |legacy_device_id| are used to track preference value changes |
49 // and must be the same on each launch in order to verify loaded preference | 49 // and must be the same on each launch in order to verify loaded preference |
50 // values. | 50 // values. |
51 ProfilePrefStoreManager( | 51 ProfilePrefStoreManager( |
52 const base::FilePath& profile_path, | 52 const base::FilePath& profile_path, |
53 const std::vector<PrefHashFilter::TrackedPreferenceMetadata>& | 53 const std::vector<PrefHashFilter::TrackedPreferenceMetadata>& |
54 tracking_configuration, | 54 tracking_configuration, |
55 size_t reporting_ids_count, | 55 size_t reporting_ids_count, |
56 const std::string& seed, | 56 const std::string& seed, |
57 const std::string& legacy_device_id, | 57 const std::string& legacy_device_id); |
58 PrefService* local_state); | |
59 | 58 |
60 ~ProfilePrefStoreManager(); | 59 ~ProfilePrefStoreManager(); |
61 | 60 |
62 static const bool kPlatformSupportsPreferenceTracking; | 61 static const bool kPlatformSupportsPreferenceTracking; |
63 | 62 |
64 // Register user prefs used by the profile preferences system. | 63 // Register user prefs used by the profile preferences system. |
65 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 64 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
66 | 65 |
67 // Retrieves the time of the last preference reset event, if any, for | 66 // Retrieves the time of the last preference reset event, if any, for |
68 // |pref_service|. Assumes that |pref_service| is backed by a PrefStore that | 67 // |pref_service|. Assumes that |pref_service| is backed by a PrefStore that |
(...skipping 13 matching lines...) Expand all Loading... |
82 static void SetPreferenceValidationRegistryPathForTesting( | 81 static void SetPreferenceValidationRegistryPathForTesting( |
83 const base::string16* path); | 82 const base::string16* path); |
84 #endif | 83 #endif |
85 | 84 |
86 // Creates a PersistentPrefStore providing access to the user preferences of | 85 // Creates a PersistentPrefStore providing access to the user preferences of |
87 // the managed profile. If |on_reset| is provided, it will be invoked if a | 86 // the managed profile. If |on_reset| is provided, it will be invoked if a |
88 // reset occurs as a result of loading the profile's prefs. | 87 // reset occurs as a result of loading the profile's prefs. |
89 // An optional |validation_delegate| will be notified | 88 // An optional |validation_delegate| will be notified |
90 // of the status of each tracked preference as they are checked. | 89 // of the status of each tracked preference as they are checked. |
91 PersistentPrefStore* CreateProfilePrefStore( | 90 PersistentPrefStore* CreateProfilePrefStore( |
92 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, | 91 scoped_refptr<base::SequencedTaskRunner> io_task_runner, |
93 const base::Closure& on_reset_on_load, | 92 const base::Closure& on_reset_on_load, |
94 prefs::mojom::TrackedPreferenceValidationDelegate* validation_delegate); | 93 prefs::mojom::TrackedPreferenceValidationDelegate* validation_delegate); |
95 | 94 |
96 // Initializes the preferences for the managed profile with the preference | 95 // Initializes the preferences for the managed profile with the preference |
97 // values in |master_prefs|. Acts synchronously, including blocking IO. | 96 // values in |master_prefs|. Acts synchronously, including blocking IO. |
98 // Returns true on success. | 97 // Returns true on success. |
99 bool InitializePrefsFromMasterPrefs( | 98 bool InitializePrefsFromMasterPrefs( |
100 std::unique_ptr<base::DictionaryValue> master_prefs); | 99 std::unique_ptr<base::DictionaryValue> master_prefs); |
101 | 100 |
102 // Creates a single-file PrefStore as was used in M34 and earlier. Used only | 101 // Creates a single-file PrefStore as was used in M34 and earlier. Used only |
103 // for testing migration. | 102 // for testing migration. |
104 PersistentPrefStore* CreateDeprecatedCombinedProfilePrefStore( | 103 PersistentPrefStore* CreateDeprecatedCombinedProfilePrefStore( |
105 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); | 104 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); |
106 | 105 |
107 private: | 106 private: |
108 // Returns a PrefHashStore for the managed profile. Should only be called | |
109 // if |kPlatformSupportsPreferenceTracking|. |use_super_mac| determines | |
110 // whether the returned object will calculate, store, and validate super MACs | |
111 // (and, by extension, accept non-null newly protected preferences as | |
112 // TrustedInitialized). | |
113 std::unique_ptr<PrefHashStore> GetPrefHashStore(bool use_super_mac); | |
114 | |
115 // Returns a PrefHashStore and HashStoreContents which can be be used for | 107 // Returns a PrefHashStore and HashStoreContents which can be be used for |
116 // extra out-of-band verifications, or nullptrs if not available on this | 108 // extra out-of-band verifications, or nullptrs if not available on this |
117 // platform. | 109 // platform. |
118 std::pair<std::unique_ptr<PrefHashStore>, std::unique_ptr<HashStoreContents>> | 110 std::pair<std::unique_ptr<PrefHashStore>, std::unique_ptr<HashStoreContents>> |
119 GetExternalVerificationPrefHashStorePair(); | 111 GetExternalVerificationPrefHashStorePair(); |
120 | 112 |
121 const base::FilePath profile_path_; | 113 const base::FilePath profile_path_; |
122 const std::vector<PrefHashFilter::TrackedPreferenceMetadata> | 114 const std::vector<PrefHashFilter::TrackedPreferenceMetadata> |
123 tracking_configuration_; | 115 tracking_configuration_; |
124 const size_t reporting_ids_count_; | 116 const size_t reporting_ids_count_; |
125 const std::string seed_; | 117 const std::string seed_; |
126 const std::string legacy_device_id_; | 118 const std::string legacy_device_id_; |
127 PrefService* local_state_; | |
128 | 119 |
129 DISALLOW_COPY_AND_ASSIGN(ProfilePrefStoreManager); | 120 DISALLOW_COPY_AND_ASSIGN(ProfilePrefStoreManager); |
130 }; | 121 }; |
131 | 122 |
132 #endif // CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_ | 123 #endif // CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_ |
OLD | NEW |