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

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

Issue 1320673013: Remove HostContentSettingsMap::IsSettingAllowedForType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-issetting-allowed
Patch Set: Created 5 years, 3 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/content_settings_pref.cc
diff --git a/components/content_settings/core/browser/content_settings_pref.cc b/components/content_settings/core/browser/content_settings_pref.cc
index 6e3d2d9450100b7292c5630431b10a81d13c8490..06ce44dcaf2cfa8bc6e95c30842e4e93dbcc2eb5 100644
--- a/components/content_settings/core/browser/content_settings_pref.cc
+++ b/components/content_settings/core/browser/content_settings_pref.cc
@@ -33,6 +33,23 @@ bool SupportsResourceIdentifiers(ContentSettingsType content_type) {
return content_type == CONTENT_SETTINGS_TYPE_PLUGINS;
}
+bool IsValueAllowedForType(const base::Value* value, ContentSettingsType type) {
+ const content_settings::ContentSettingsInfo* info =
+ content_settings::ContentSettingsRegistry::GetInstance()->Get(type);
+ if (info) {
+ int setting;
+ if (!value->GetAsInteger(&setting))
+ return false;
+ if (setting == CONTENT_SETTING_DEFAULT)
+ return false;
+ return info->IsSettingValid(IntToContentSetting(setting));
+ } else {
Bernhard Bauer 2015/09/28 18:46:09 You don't need the else if you return in the previ
raymes 2015/09/29 05:51:26 Done.
+ // TODO(raymes): We should permit different types of base::Value for
+ // website settings.
+ return value->GetType() == base::Value::TYPE_DICTIONARY;
+ }
+}
+
} // namespace
namespace content_settings {
@@ -78,6 +95,7 @@ bool ContentSettingsPref::SetWebsiteSetting(
const ContentSettingsPattern& secondary_pattern,
const ResourceIdentifier& resource_identifier,
base::Value* in_value) {
+ DCHECK(!in_value || IsValueAllowedForType(in_value, content_type_));
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(prefs_);
DCHECK(primary_pattern != ContentSettingsPattern::Wildcard() ||
@@ -303,8 +321,7 @@ void ContentSettingsPref::ReadContentSettingsFromPref() {
settings_dictionary->GetWithoutPathExpansion(kSettingPath, &value);
if (value) {
- DCHECK(HostContentSettingsMap::IsValueAllowedForType(value,
- content_type_));
+ DCHECK(IsValueAllowedForType(value, content_type_));
value_map_.SetValue(pattern_pair.first,
pattern_pair.second,
content_type_,

Powered by Google App Engine
This is Rietveld 408576698