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

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: Rebased and added important_file_writer CL as dependent patchset 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..ef65b8a332f7e4137321968cf04ed6280774d567 100644
--- a/chrome/browser/prefs/profile_pref_store_manager.cc
+++ b/chrome/browser/prefs/profile_pref_store_manager.cc
@@ -23,6 +23,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 +38,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 +89,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 +129,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 +182,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 +211,24 @@ 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>>*
gab 2016/09/16 19:47:31 Returning raw pointer is almost never correct (i.e
proberge 2016/09/20 21:35:44 Done.
+ProfilePrefStoreManager::GetExternalVerificationPrefHashStorePair() {
+ DCHECK(kPlatformSupportsPreferenceTracking);
+#if defined(OS_WIN)
+ return new std::pair<std::unique_ptr<PrefHashStore>,
+ std::unique_ptr<HashStoreContents>>(std::make_pair(
gab 2016/09/16 19:47:32 Once you return by value I think you can just "ret
proberge 2016/09/20 21:35:44 Done.
+ std::unique_ptr<PrefHashStore>(
+ new PrefHashStoreImpl("ChromeRegistryHashStoreValidationSeed",
gab 2016/09/16 19:47:31 s/std::unique_ptr<Foo>(new FooImpl(...))/base::Mak
proberge 2016/09/20 21:35:44 Done.
+ device_id_, false /* use_super_mac */)),
+ g_preference_validation_registry_path_for_testing != nullptr
+ ? std::unique_ptr<HashStoreContents>(new RegistryHashStoreContentsWin(
+ *g_preference_validation_registry_path_for_testing,
+ profile_path_.BaseName().LossyDisplayName()))
+ : std::unique_ptr<HashStoreContents>(new RegistryHashStoreContentsWin(
+ BrowserDistribution::GetDistribution()->GetRegistryPath(),
+ profile_path_.BaseName().LossyDisplayName()))));
+#else
+ return nullptr;
+#endif
+}

Powered by Google App Engine
This is Rietveld 408576698