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

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

Issue 2882883002: Fix a crash in Content Settings PolicyProvider::UpdateManagedDefaultSetting (Closed)
Patch Set: Fix a crash in Content Settings PolicyProvider::UpdateManagedDefaultSetting Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/content_settings/core/browser/content_settings_policy_provider.cc
diff --git a/components/content_settings/core/browser/content_settings_policy_provider.cc b/components/content_settings/core/browser/content_settings_policy_provider.cc
index bf13551ddb49ef89f5d941252352b82061971264..d9b8cfa98060cd6be5f23d0b02f1cc95112df173 100644
--- a/components/content_settings/core/browser/content_settings_policy_provider.cc
+++ b/components/content_settings/core/browser/content_settings_policy_provider.cc
@@ -336,6 +336,13 @@ void PolicyProvider::ReadManagedDefaultSettings() {
void PolicyProvider::UpdateManagedDefaultSetting(
const PrefsForManagedDefaultMapEntry& entry) {
+ // Not all managed default types are registered on every platform. If they're
+ // not registered, don't update them.
+ const ContentSettingsInfo* info =
+ ContentSettingsRegistry::GetInstance()->Get(entry.content_type);
+ if (!info)
+ return;
+
// If a pref to manage a default-content-setting was not set (NOTICE:
// "HasPrefPath" returns false if no value was set for a registered pref) then
// the default value of the preference is used. The default value of a
@@ -357,9 +364,7 @@ void PolicyProvider::UpdateManagedDefaultSetting(
value_map_.DeleteValue(ContentSettingsPattern::Wildcard(),
ContentSettingsPattern::Wildcard(),
entry.content_type, std::string());
- } else if (ContentSettingsRegistry::GetInstance()
- ->Get(entry.content_type)
- ->IsSettingValid(IntToContentSetting(setting))) {
+ } else if (info->IsSettingValid(IntToContentSetting(setting))) {
// Don't set a timestamp for policy settings.
value_map_.SetValue(ContentSettingsPattern::Wildcard(),
ContentSettingsPattern::Wildcard(), entry.content_type,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698