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

Unified Diff: components/content_settings/core/browser/host_content_settings_map.cc

Issue 2158743002: Register a pref to control migration status (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@change_scoping_type
Patch Set: address review comments Created 4 years, 5 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: components/content_settings/core/browser/host_content_settings_map.cc
diff --git a/components/content_settings/core/browser/host_content_settings_map.cc b/components/content_settings/core/browser/host_content_settings_map.cc
index 3dbb4f57c2e635169c58ad0faade19a2efb967ee..4be9e65c0b818e337a0e47c10f5d6318ea2b5abb 100644
--- a/components/content_settings/core/browser/host_content_settings_map.cc
+++ b/components/content_settings/core/browser/host_content_settings_map.cc
@@ -58,6 +58,23 @@ const ProviderNamesSourceMapEntry kProviderNamesSourceMap[] = {
{"default", content_settings::SETTING_SOURCE_USER},
};
+// Enum describing the status of domain to origin migration of content settings.
+// Migration will be done twice: once upon construction of the
+// HostContentSettingsMap (before syncing any content settings) and once after
+// sync has finished. We always migrate before sync to ensure that settings will
+// get migrated even if a user doesn't have sync enabled. We migrate after sync
+// to ensure that any sync'd settings will be migrated. Once these events have
+// occurred, we won't perform migration again.
+enum DomainToOriginMigrationStatus {
+ // Haven't been migrated at all.
+ NOT_MIGRATED,
+ // Have done migration in the constructor of HostContentSettingsMap.
+ MIGRATED_BEFORE_SYNC,
+ // Have done migration both in HostContentSettingsMap construction and and
+ // after sync is finished. No migration will happen after this point.
+ MIGRATED_AFTER_SYNC,
+};
+
static_assert(
arraysize(kProviderNamesSourceMap) ==
HostContentSettingsMap::NUM_PROVIDER_TYPES,
@@ -183,6 +200,8 @@ void HostContentSettingsMap::RegisterProfilePrefs(
content_settings::ContentSettingsRegistry::GetInstance();
registry->RegisterIntegerPref(prefs::kContentSettingsWindowLastTabIndex, 0);
+ registry->RegisterIntegerPref(prefs::kDomainToOriginMigrationStatus,
+ NOT_MIGRATED);
// Register the prefs for the content settings providers.
content_settings::DefaultProvider::RegisterProfilePrefs(registry);
@@ -497,7 +516,16 @@ void HostContentSettingsMap::MigrateKeygenSettings() {
}
}
-void HostContentSettingsMap::MigrateDomainScopedSettings() {
+void HostContentSettingsMap::MigrateDomainScopedSettings(bool after_sync) {
+ DomainToOriginMigrationStatus status =
+ static_cast<DomainToOriginMigrationStatus>(
+ prefs_->GetInteger(prefs::kDomainToOriginMigrationStatus));
+ if (status == MIGRATED_AFTER_SYNC)
+ return;
+ if (status == MIGRATED_BEFORE_SYNC && !after_sync)
+ return;
+ DCHECK(status != NOT_MIGRATED || !after_sync);
+
const ContentSettingsType kDomainScopedTypes[] = {
CONTENT_SETTINGS_TYPE_COOKIES,
CONTENT_SETTINGS_TYPE_IMAGES,
@@ -562,6 +590,14 @@ void HostContentSettingsMap::MigrateDomainScopedSettings() {
CONTENT_SETTING_ALLOW);
}
}
+
+ if (status == NOT_MIGRATED) {
+ prefs_->SetInteger(prefs::kDomainToOriginMigrationStatus,
+ MIGRATED_BEFORE_SYNC);
+ } else if (status == MIGRATED_BEFORE_SYNC) {
+ prefs_->SetInteger(prefs::kDomainToOriginMigrationStatus,
+ MIGRATED_AFTER_SYNC);
+ }
}
void HostContentSettingsMap::RecordNumberOfExceptions() {

Powered by Google App Engine
This is Rietveld 408576698