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..aa7abc8a765110f16db9b69bb6f5275c0792b7e6 100644 |
--- a/components/content_settings/core/browser/host_content_settings_map.cc |
+++ b/components/content_settings/core/browser/host_content_settings_map.cc |
@@ -171,8 +171,10 @@ HostContentSettingsMap::HostContentSettingsMap(PrefService* prefs, |
default_provider->AddObserver(this); |
content_settings_providers_[DEFAULT_PROVIDER] = default_provider; |
+// ios doean't have KEYGEN to be migrated. |
+#if !defined(OS_IOS) |
MigrateOldSettings(); |
raymes
2016/05/20 19:10:16
Maybe we can just rename this to MigrateKeygenSett
lshang
2016/05/24 11:55:45
Good suggestion! I made a separate CL(https://code
|
- |
+#endif |
RecordNumberOfExceptions(); |
} |
@@ -474,40 +476,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); |
} |
} |
} |