| Index: services/preferences/tracked/tracked_persistent_pref_store_factory.cc
|
| diff --git a/services/preferences/tracked/tracked_persistent_pref_store_factory.cc b/services/preferences/tracked/tracked_persistent_pref_store_factory.cc
|
| index ffb5ab2e9ace0d1b576c8901a1ad3603a422ac1d..be4ce2da0ed2ffa5e03a603719309a5f50534e30 100644
|
| --- a/services/preferences/tracked/tracked_persistent_pref_store_factory.cc
|
| +++ b/services/preferences/tracked/tracked_persistent_pref_store_factory.cc
|
| @@ -16,9 +16,12 @@
|
| #include "services/preferences/tracked/pref_hash_filter.h"
|
| #include "services/preferences/tracked/pref_hash_store_impl.h"
|
| #include "services/preferences/tracked/segregated_pref_store.h"
|
| +#include "services/preferences/tracked/temp_scoped_dir_cleaner.h"
|
| #include "services/preferences/tracked/tracked_preferences_migration.h"
|
|
|
| #if defined(OS_WIN)
|
| +#include "base/files/scoped_temp_dir.h"
|
| +#include "base/strings/string_util.h"
|
| #include "services/preferences/tracked/registry_hash_store_contents_win.h"
|
| #endif
|
|
|
| @@ -41,16 +44,18 @@ std::unique_ptr<PrefHashStore> CreatePrefHashStore(
|
|
|
| std::pair<std::unique_ptr<PrefHashStore>, std::unique_ptr<HashStoreContents>>
|
| GetExternalVerificationPrefHashStorePair(
|
| - const prefs::mojom::TrackedPersistentPrefStoreConfiguration& config) {
|
| + const prefs::mojom::TrackedPersistentPrefStoreConfiguration& config,
|
| + scoped_refptr<TempScopedDirCleaner> temp_dir_cleaner) {
|
| #if defined(OS_WIN)
|
| - return std::make_pair(
|
| - base::MakeUnique<PrefHashStoreImpl>(config.registry_seed,
|
| - config.legacy_device_id,
|
| - false /* use_super_mac */),
|
| - base::MakeUnique<RegistryHashStoreContentsWin>(
|
| - config.registry_path, config.unprotected_pref_filename.DirName()
|
| - .BaseName()
|
| - .LossyDisplayName()));
|
| + return std::make_pair(base::MakeUnique<PrefHashStoreImpl>(
|
| + config.registry_seed, config.legacy_device_id,
|
| + false /* use_super_mac */),
|
| + base::MakeUnique<RegistryHashStoreContentsWin>(
|
| + config.registry_path,
|
| + config.unprotected_pref_filename.DirName()
|
| + .BaseName()
|
| + .LossyDisplayName(),
|
| + std::move(temp_dir_cleaner)));
|
| #else
|
| return std::make_pair(nullptr, nullptr);
|
| #endif
|
| @@ -82,15 +87,33 @@ PersistentPrefStore* CreateTrackedPersistentPrefStore(
|
| }
|
| config->tracking_configuration.clear();
|
|
|
| + scoped_refptr<TempScopedDirCleaner> temp_scoped_dir_cleaner;
|
| +#if defined(OS_WIN)
|
| + // For tests that create a profile in a ScopedTempDir, share a ref_counted
|
| + // object between the unprotected and protected hash filter's
|
| + // RegistryHashStoreContentsWin which will clear the registry keys when
|
| + // destroyed. (https://crbug.com/721245)
|
| + if (base::StartsWith(config->unprotected_pref_filename.DirName()
|
| + .BaseName()
|
| + .LossyDisplayName(),
|
| + base::ScopedTempDir::GetTempDirPrefix(),
|
| + base::CompareCase::INSENSITIVE_ASCII)) {
|
| + temp_scoped_dir_cleaner =
|
| + base::MakeRefCounted<TempScopedDirRegistryCleaner>();
|
| + }
|
| +#endif
|
| +
|
| std::unique_ptr<PrefHashFilter> unprotected_pref_hash_filter(
|
| new PrefHashFilter(CreatePrefHashStore(*config, false),
|
| - GetExternalVerificationPrefHashStorePair(*config),
|
| + GetExternalVerificationPrefHashStorePair(
|
| + *config, temp_scoped_dir_cleaner),
|
| unprotected_configuration, nullptr,
|
| config->validation_delegate.get(),
|
| config->reporting_ids_count, false));
|
| std::unique_ptr<PrefHashFilter> protected_pref_hash_filter(new PrefHashFilter(
|
| CreatePrefHashStore(*config, true),
|
| - GetExternalVerificationPrefHashStorePair(*config),
|
| + GetExternalVerificationPrefHashStorePair(*config,
|
| + temp_scoped_dir_cleaner),
|
| protected_configuration, std::move(config->reset_on_load_observer),
|
| config->validation_delegate.get(), config->reporting_ids_count, true));
|
|
|
| @@ -125,9 +148,10 @@ PersistentPrefStore* CreateTrackedPersistentPrefStore(
|
| void InitializeMasterPrefsTracking(
|
| prefs::mojom::TrackedPersistentPrefStoreConfigurationPtr configuration,
|
| base::DictionaryValue* master_prefs) {
|
| - PrefHashFilter(CreatePrefHashStore(*configuration, false),
|
| - GetExternalVerificationPrefHashStorePair(*configuration),
|
| - configuration->tracking_configuration, nullptr, nullptr,
|
| - configuration->reporting_ids_count, false)
|
| + PrefHashFilter(
|
| + CreatePrefHashStore(*configuration, false),
|
| + GetExternalVerificationPrefHashStorePair(*configuration, nullptr),
|
| + configuration->tracking_configuration, nullptr, nullptr,
|
| + configuration->reporting_ids_count, false)
|
| .Initialize(master_prefs);
|
| }
|
|
|