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

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: add some comments to test 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..4d100487bd88b7e5dd796cc94cbf4a4de8e42451 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,24 @@ 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 sync
+ // process(this is a clean up after sync). Migration is all finished at this
+ // stage.
+ MIGRATED_AFTER_SYNC,
+};
+
static_assert(
arraysize(kProviderNamesSourceMap) ==
HostContentSettingsMap::NUM_PROVIDER_TYPES,
@@ -183,6 +201,8 @@ void HostContentSettingsMap::RegisterProfilePrefs(
content_settings::ContentSettingsRegistry::GetInstance();
registry->RegisterIntegerPref(prefs::kContentSettingsWindowLastTabIndex, 0);
+ registry->RegisterIntegerPref(prefs::kDomainToOriginMigrationStatus,
+ DomainToOriginMigrationStatus::NOT_MIGRATED);
// Register the prefs for the content settings providers.
content_settings::DefaultProvider::RegisterProfilePrefs(registry);
@@ -497,7 +517,15 @@ void HostContentSettingsMap::MigrateKeygenSettings() {
}
}
-void HostContentSettingsMap::MigrateDomainScopedSettings() {
+void HostContentSettingsMap::MigrateDomainScopedSettings(bool after_sync) {
+ int status = prefs_->GetInteger(prefs::kDomainToOriginMigrationStatus);
+ if (status == MIGRATED_AFTER_SYNC)
+ return;
+ if (status == MIGRATED_BEFORE_SYNC && !after_sync)
+ return;
+ if (status == NOT_MIGRATED && after_sync)
raymes 2016/07/21 00:58:54 This should never happen, right? I think this shou
lshang 2016/07/22 01:33:07 Done.
+ return;
+
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,
+ DomainToOriginMigrationStatus::MIGRATED_BEFORE_SYNC);
+ } else if (status == MIGRATED_BEFORE_SYNC) {
+ prefs_->SetInteger(prefs::kDomainToOriginMigrationStatus,
+ DomainToOriginMigrationStatus::MIGRATED_AFTER_SYNC);
+ }
}
void HostContentSettingsMap::RecordNumberOfExceptions() {

Powered by Google App Engine
This is Rietveld 408576698