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

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

Issue 1991623005: Only Register() platform specific content settings types on different platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 67321bd14d92e837c430cad08ea72eb808450eb9..2fe83f75c2b94d3f09eef97e6d4fc44f2da347d2 100644
--- a/components/content_settings/core/browser/host_content_settings_map.cc
+++ b/components/content_settings/core/browser/host_content_settings_map.cc
@@ -474,40 +474,42 @@ void HostContentSettingsMap::MigrateOldSettings() {
// migrated.
CONTENT_SETTINGS_TYPE_KEYGEN};
for (const ContentSettingsType& type : kMigrateContentSettingTypes) {
- WebsiteSettingsInfo::ScopingType scoping_type =
- content_settings::ContentSettingsRegistry::GetInstance()
- ->Get(type)
- ->website_settings_info()
- ->scoping_type();
- DCHECK_NE(
- scoping_type,
- WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE);
-
- ContentSettingsForOneType settings;
- GetSettingsForOneType(type, std::string(), &settings);
- for (const ContentSettingPatternSource& setting_entry : settings) {
- // Migrate user preference settings only.
- if (setting_entry.source != "preference")
- continue;
- // Migrate old-format settings only.
- if (setting_entry.secondary_pattern !=
- ContentSettingsPattern::Wildcard()) {
- GURL url(setting_entry.primary_pattern.ToString());
- // Pull out the value of the old-format setting. Only do this if the
- // patterns are as we expect them to be, otherwise the setting will just
- // be removed for safety.
- ContentSetting content_setting = CONTENT_SETTING_DEFAULT;
- if (setting_entry.primary_pattern == setting_entry.secondary_pattern &&
- url.is_valid()) {
- content_setting = GetContentSetting(url, url, type, std::string());
+ const content_settings::ContentSettingsInfo* info =
+ content_settings::ContentSettingsRegistry::GetInstance()->Get(type);
+ if (info) {
+ WebsiteSettingsInfo::ScopingType scoping_type =
+ info->website_settings_info()->scoping_type();
+ DCHECK_NE(
+ scoping_type,
+ WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE);
+
+ ContentSettingsForOneType settings;
+ GetSettingsForOneType(type, std::string(), &settings);
+ for (const ContentSettingPatternSource& setting_entry : settings) {
+ // Migrate user preference settings only.
+ if (setting_entry.source != "preference")
+ continue;
+ // Migrate old-format settings only.
+ if (setting_entry.secondary_pattern !=
+ ContentSettingsPattern::Wildcard()) {
+ GURL url(setting_entry.primary_pattern.ToString());
+ // Pull out the value of the old-format setting. Only do this if the
+ // patterns are as we expect them to be, otherwise the setting will
+ // just be removed for safety.
+ ContentSetting content_setting = CONTENT_SETTING_DEFAULT;
+ if (setting_entry.primary_pattern ==
+ setting_entry.secondary_pattern &&
+ url.is_valid()) {
+ content_setting = GetContentSetting(url, url, type, std::string());
+ }
+ // Remove the old pattern.
+ SetContentSettingCustomScope(setting_entry.primary_pattern,
+ setting_entry.secondary_pattern, type,
+ std::string(), CONTENT_SETTING_DEFAULT);
+ // Set the new pattern.
+ SetContentSettingDefaultScope(url, GURL(), type, std::string(),
+ content_setting);
}
- // Remove the old pattern.
- SetContentSettingCustomScope(setting_entry.primary_pattern,
- setting_entry.secondary_pattern, type, std::string(),
- CONTENT_SETTING_DEFAULT);
- // Set the new pattern.
- SetContentSettingDefaultScope(url, GURL(), type, std::string(),
- content_setting);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698