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); |
} |
} |
} |