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

Unified Diff: chrome/browser/content_settings/host_content_settings_map.cc

Issue 10537099: add "always allow" option to the mediastream infobar and allow user to allow/not allow acces to devi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Check the exceptions before the default setting, sites in the exceptions list can access the device… Created 8 years, 6 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: chrome/browser/content_settings/host_content_settings_map.cc
diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc
index 49f7700e7f74bcde4d8608c7f0029d24782cfe00..d796d3402ed7a1b047ee4f1c87c0ed483f7d02cb 100644
--- a/chrome/browser/content_settings/host_content_settings_map.cc
+++ b/chrome/browser/content_settings/host_content_settings_map.cc
@@ -70,7 +70,8 @@ bool ContentTypeHasCompoundValue(ContentSettingsType type) {
// Values for content type CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE are
// of type dictionary/map. Compound types like dictionaries can't be mapped to
// the type |ContentSetting|.
- return type == CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE;
+ return (type == CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE ||
+ type == CONTENT_SETTINGS_TYPE_MEDIASTREAM);
}
// Returns true if the |content_type| supports a resource identifier.
@@ -185,8 +186,6 @@ ContentSetting HostContentSettingsMap::GetDefaultContentSettingFromProvider(
ContentSetting HostContentSettingsMap::GetDefaultContentSetting(
ContentSettingsType content_type,
std::string* provider_id) const {
- DCHECK(!ContentTypeHasCompoundValue(content_type));
-
// Iterate through the list of providers and return the first non-NULL value
// that matches |primary_url| and |secondary_url|.
for (ConstProviderIterator provider = content_settings_providers_.begin();
@@ -255,7 +254,6 @@ void HostContentSettingsMap::GetSettingsForOneType(
void HostContentSettingsMap::SetDefaultContentSetting(
ContentSettingsType content_type,
ContentSetting setting) {
- DCHECK(!ContentTypeHasCompoundValue(content_type));
DCHECK(IsSettingAllowedForType(prefs_, setting, content_type));
base::Value* value = NULL;
@@ -346,7 +344,7 @@ void HostContentSettingsMap::ClearSettingsForOneType(
bool HostContentSettingsMap::IsValueAllowedForType(
PrefService* prefs, const base::Value* value, ContentSettingsType type) {
- return IsSettingAllowedForType(
+ return ContentTypeHasCompoundValue(type) || IsSettingAllowedForType(
prefs, content_settings::ValueToContentSetting(value), type);
}
@@ -381,6 +379,7 @@ bool HostContentSettingsMap::IsSettingAllowedForType(
case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
case CONTENT_SETTINGS_TYPE_INTENTS:
case CONTENT_SETTINGS_TYPE_MOUSELOCK:
+ case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
return setting == CONTENT_SETTING_ASK;
default:
return false;
@@ -482,9 +481,17 @@ void HostContentSettingsMap::AddSettingsForOneType(
incognito));
while (rule_iterator->HasNext()) {
const content_settings::Rule& rule = rule_iterator->Next();
+ ContentSetting setting_value = CONTENT_SETTING_DEFAULT;
+ // For the cases using compound value, we assume it is valid as long as
+ // the value is not NULL.
+ if (ContentTypeHasCompoundValue(content_type) && rule.value.get()) {
+ setting_value = CONTENT_SETTING_ALLOW;
+ } else {
+ setting_value = content_settings::ValueToContentSetting(rule.value.get());
+ }
settings->push_back(ContentSettingPatternSource(
rule.primary_pattern, rule.secondary_pattern,
- content_settings::ValueToContentSetting(rule.value.get()),
+ setting_value,
kProviderNames[provider_type],
incognito));
}

Powered by Google App Engine
This is Rietveld 408576698