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