Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(711)

Unified Diff: chrome/browser/prefs/profile_pref_store_manager.cc

Issue 2204943002: Integrate registry_hash_store_contents with the rest of tracked prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply fixes from #10 Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prefs/profile_pref_store_manager.cc
diff --git a/chrome/browser/prefs/profile_pref_store_manager.cc b/chrome/browser/prefs/profile_pref_store_manager.cc
index 63d7dbe6f5e9da1880f620bc09378b78cc9415ab..88475a768d00753574d384eb1f76035629ded0f2 100644
--- a/chrome/browser/prefs/profile_pref_store_manager.cc
+++ b/chrome/browser/prefs/profile_pref_store_manager.cc
@@ -11,6 +11,7 @@
#include "base/files/file_util.h"
#include "base/json/json_file_value_serializer.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/sequenced_task_runner.h"
#include "build/build_config.h"
@@ -23,6 +24,11 @@
#include "components/user_prefs/tracked/segregated_pref_store.h"
#include "components/user_prefs/tracked/tracked_preferences_migration.h"
+#if defined(OS_WIN)
+#include "chrome/installer/util/browser_distribution.h"
+#include "components/user_prefs/tracked/registry_hash_store_contents_win.h"
+#endif
+
namespace {
void RemoveValueSilently(const base::WeakPtr<JsonPrefStore> pref_store,
@@ -33,6 +39,13 @@ void RemoveValueSilently(const base::WeakPtr<JsonPrefStore> pref_store,
}
}
+#if defined(OS_WIN)
+// Whether we are in testing mode; can be enabled via
+// UseTestingPreferenceValidationRegistryPath(). Forces a different registry key
+// to be used for storing preference validation MACs.
+base::string16* g_preference_validation_registry_path_for_testing = nullptr;
+#endif // OS_WIN
+
} // namespace
// Preference tracking and protection is not required on platforms where other
@@ -77,6 +90,15 @@ void ProfilePrefStoreManager::ClearResetTime(PrefService* pref_service) {
PrefHashFilter::ClearResetTime(pref_service);
}
+#if defined(OS_WIN)
+// static
+void ProfilePrefStoreManager::SetPreferenceValidationRegistryPathForTesting(
+ const base::string16& path) {
+ DCHECK(!path.empty());
+ g_preference_validation_registry_path_for_testing = new base::string16(path);
+}
+#endif // OS_WIN
+
PersistentPrefStore* ProfilePrefStoreManager::CreateProfilePrefStore(
const scoped_refptr<base::SequencedTaskRunner>& io_task_runner,
const base::Closure& on_reset_on_load,
@@ -108,12 +130,14 @@ PersistentPrefStore* ProfilePrefStoreManager::CreateProfilePrefStore(
}
std::unique_ptr<PrefHashFilter> unprotected_pref_hash_filter(
- new PrefHashFilter(GetPrefHashStore(false), unprotected_configuration,
- base::Closure(), validation_delegate,
- reporting_ids_count_, false));
+ new PrefHashFilter(GetPrefHashStore(false),
+ GetExternalVerificationPrefHashStorePair(),
+ unprotected_configuration, base::Closure(),
+ validation_delegate, reporting_ids_count_, false));
std::unique_ptr<PrefHashFilter> protected_pref_hash_filter(new PrefHashFilter(
- GetPrefHashStore(true), protected_configuration, on_reset_on_load,
- validation_delegate, reporting_ids_count_, true));
+ GetPrefHashStore(true), GetExternalVerificationPrefHashStorePair(),
+ protected_configuration, on_reset_on_load, validation_delegate,
+ reporting_ids_count_, true));
PrefHashFilter* raw_unprotected_pref_hash_filter =
unprotected_pref_hash_filter.get();
@@ -159,11 +183,10 @@ bool ProfilePrefStoreManager::InitializePrefsFromMasterPrefs(
copy.reset(master_prefs.DeepCopy());
to_serialize = copy.get();
PrefHashFilter(GetPrefHashStore(false),
- tracking_configuration_,
- base::Closure(),
- NULL,
- reporting_ids_count_,
- false).Initialize(copy.get());
+ GetExternalVerificationPrefHashStorePair(),
+ tracking_configuration_, base::Closure(), NULL,
+ reporting_ids_count_, false)
+ .Initialize(copy.get());
}
// This will write out to a single combined file which will be immediately
@@ -189,3 +212,23 @@ std::unique_ptr<PrefHashStore> ProfilePrefStoreManager::GetPrefHashStore(
return std::unique_ptr<PrefHashStore>(
new PrefHashStoreImpl(seed_, device_id_, use_super_mac));
}
+
+std::pair<std::unique_ptr<PrefHashStore>, std::unique_ptr<HashStoreContents>>
+ProfilePrefStoreManager::GetExternalVerificationPrefHashStorePair() {
+ DCHECK(kPlatformSupportsPreferenceTracking);
+#if defined(OS_WIN)
+ return std::make_pair(
+ base::MakeUnique<PrefHashStoreImpl>(
+ "ChromeRegistryHashStoreValidationSeed", device_id_,
+ false /* use_super_mac */),
+ g_preference_validation_registry_path_for_testing != nullptr
gab 2016/09/21 17:55:30 Drop "!= nullptr", the ternary operator implies a
proberge 2016/09/21 21:09:24 Done.
+ ? base::MakeUnique<RegistryHashStoreContentsWin>(
+ *g_preference_validation_registry_path_for_testing,
+ profile_path_.BaseName().LossyDisplayName())
+ : base::MakeUnique<RegistryHashStoreContentsWin>(
+ BrowserDistribution::GetDistribution()->GetRegistryPath(),
+ profile_path_.BaseName().LossyDisplayName()));
+#else
+ return std::make_pair(nullptr, nullptr);
+#endif
+}

Powered by Google App Engine
This is Rietveld 408576698