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 14 matching lines...) Expand all Loading... |
25 class DictionaryValue; | 25 class DictionaryValue; |
26 class SequencedTaskRunner; | 26 class SequencedTaskRunner; |
27 } // namespace base | 27 } // namespace base |
28 | 28 |
29 namespace prefs { | 29 namespace prefs { |
30 namespace mojom { | 30 namespace mojom { |
31 class TrackedPreferenceValidationDelegate; | 31 class TrackedPreferenceValidationDelegate; |
32 } | 32 } |
33 } | 33 } |
34 | 34 |
| 35 namespace service_manager { |
| 36 class Connector; |
| 37 } |
| 38 |
35 namespace user_prefs { | 39 namespace user_prefs { |
36 class PrefRegistrySyncable; | 40 class PrefRegistrySyncable; |
37 } // namespace user_prefs | 41 } // namespace user_prefs |
38 | 42 |
39 // Provides a facade through which the user preference store may be accessed and | 43 // Provides a facade through which the user preference store may be accessed and |
40 // managed. | 44 // managed. |
41 class ProfilePrefStoreManager { | 45 class ProfilePrefStoreManager { |
42 public: | 46 public: |
43 // Instantiates a ProfilePrefStoreManager with the configuration required to | 47 // Instantiates a ProfilePrefStoreManager with the configuration required to |
44 // manage the user preferences of the profile at |profile_path|. | 48 // manage the user preferences of the profile at |profile_path|. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #endif | 88 #endif |
85 | 89 |
86 // Creates a PersistentPrefStore providing access to the user preferences of | 90 // 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 | 91 // 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. | 92 // reset occurs as a result of loading the profile's prefs. |
89 // An optional |validation_delegate| will be notified | 93 // An optional |validation_delegate| will be notified |
90 // of the status of each tracked preference as they are checked. | 94 // of the status of each tracked preference as they are checked. |
91 PersistentPrefStore* CreateProfilePrefStore( | 95 PersistentPrefStore* CreateProfilePrefStore( |
92 scoped_refptr<base::SequencedTaskRunner> io_task_runner, | 96 scoped_refptr<base::SequencedTaskRunner> io_task_runner, |
93 const base::Closure& on_reset_on_load, | 97 const base::Closure& on_reset_on_load, |
94 prefs::mojom::TrackedPreferenceValidationDelegate* validation_delegate); | 98 std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate>* |
| 99 validation_delegate, |
| 100 service_manager::Connector* connector); |
95 | 101 |
96 // Initializes the preferences for the managed profile with the preference | 102 // Initializes the preferences for the managed profile with the preference |
97 // values in |master_prefs|. Acts synchronously, including blocking IO. | 103 // values in |master_prefs|. Acts synchronously, including blocking IO. |
98 // Returns true on success. | 104 // Returns true on success. |
99 bool InitializePrefsFromMasterPrefs( | 105 bool InitializePrefsFromMasterPrefs( |
100 std::unique_ptr<base::DictionaryValue> master_prefs); | 106 std::unique_ptr<base::DictionaryValue> master_prefs); |
101 | 107 |
102 // Creates a single-file PrefStore as was used in M34 and earlier. Used only | 108 // Creates a single-file PrefStore as was used in M34 and earlier. Used only |
103 // for testing migration. | 109 // for testing migration. |
104 PersistentPrefStore* CreateDeprecatedCombinedProfilePrefStore( | 110 PersistentPrefStore* CreateDeprecatedCombinedProfilePrefStore( |
105 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); | 111 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); |
106 | 112 |
107 private: | 113 private: |
108 // Returns a PrefHashStore for the managed profile. Should only be called | 114 // Returns a PrefHashStore for the managed profile. Should only be called |
109 // if |kPlatformSupportsPreferenceTracking|. | 115 // if |kPlatformSupportsPreferenceTracking|. |
110 std::unique_ptr<PrefHashStore> GetPrefHashStore(); | 116 std::unique_ptr<PrefHashStore> GetPrefHashStore(); |
111 | 117 |
112 // Returns a PrefHashStore and HashStoreContents which can be be used for | 118 // Returns a PrefHashStore and HashStoreContents which can be be used for |
113 // extra out-of-band verifications, or nullptrs if not available on this | 119 // extra out-of-band verifications, or nullptrs if not available on this |
114 // platform. | 120 // platform. |
115 std::pair<std::unique_ptr<PrefHashStore>, std::unique_ptr<HashStoreContents>> | 121 std::pair<std::unique_ptr<PrefHashStore>, std::unique_ptr<HashStoreContents>> |
116 GetExternalVerificationPrefHashStorePair(); | 122 GetExternalVerificationPrefHashStorePair(); |
117 | 123 |
| 124 // Connects to the pref service over mojo and configures it. |
| 125 void ConfigurePrefService( |
| 126 const base::Closure& on_reset_on_load, |
| 127 std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> |
| 128 validation_delegate, |
| 129 service_manager::Connector* connector); |
| 130 |
118 const base::FilePath profile_path_; | 131 const base::FilePath profile_path_; |
119 const std::vector<PrefHashFilter::TrackedPreferenceMetadata> | 132 const std::vector<PrefHashFilter::TrackedPreferenceMetadata> |
120 tracking_configuration_; | 133 tracking_configuration_; |
121 const size_t reporting_ids_count_; | 134 const size_t reporting_ids_count_; |
122 const std::string seed_; | 135 const std::string seed_; |
123 const std::string legacy_device_id_; | 136 const std::string legacy_device_id_; |
124 PrefService* local_state_; | 137 PrefService* local_state_; |
125 | 138 |
126 DISALLOW_COPY_AND_ASSIGN(ProfilePrefStoreManager); | 139 DISALLOW_COPY_AND_ASSIGN(ProfilePrefStoreManager); |
127 }; | 140 }; |
128 | 141 |
129 #endif // CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_ | 142 #endif // CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_ |
OLD | NEW |