summaryrefslogtreecommitdiffstats
path: root/chrome/browser/content_settings/host_content_settings_map.cc
diff options
context:
space:
mode:
authorxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 17:00:53 +0000
committerxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 17:00:53 +0000
commit4afde5c8aaf0a8b0557c8627a1d633361be79190 (patch)
treecba802056227b4c9176abd2497bb9d7bc722da51 /chrome/browser/content_settings/host_content_settings_map.cc
parentc1788f0e4ddda9a36b88731a786243f194394282 (diff)
downloadchromium_src-4afde5c8aaf0a8b0557c8627a1d633361be79190.zip
chromium_src-4afde5c8aaf0a8b0557c8627a1d633361be79190.tar.gz
chromium_src-4afde5c8aaf0a8b0557c8627a1d633361be79190.tar.bz2
Feature1:
User goes to http://neave.com/webcam/html5/ The url displayed is the security origin, just like maps.google.com User needs to allow or deny access to his camera and microphone. Some sites will require only the mic or only the webcam. User can open an options drop down. The drop down needs to be clicked for every modification. A divide line separates microphones and webcams. User can also decide to Always allow. The decision will also remember the devices chosen. Details: The "Always allow" option will remember both the decision and the devices chosen. If "Always allow" is selected and Deny is pressed, access is denied. Upon the next visit, the infobar will be displayed again. If a a website is Allowed and "Always allowed": ...And devices disappears from the computer. It will show the infobar and ask the user to choose devices. Feature2: Settings => Privacy => Content Settings We want to add a new section called Media to cover the getUserMedia decisions. And we are able to see and remove the exception lists there. BUG=132075,10532048 TEST=go to https://apprtc.appspot.com; click "always allow this site to use this device" option; go to content setting/privacy/media, try ask/block settings and remove exceptions. Review URL: https://chromiumcodereview.appspot.com/10537099 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143918 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/content_settings/host_content_settings_map.cc')
-rw-r--r--chrome/browser/content_settings/host_content_settings_map.cc37
1 files changed, 25 insertions, 12 deletions
diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc
index 2081b03..1392294 100644
--- a/chrome/browser/content_settings/host_content_settings_map.cc
+++ b/chrome/browser/content_settings/host_content_settings_map.cc
@@ -66,13 +66,6 @@ COMPILE_ASSERT(arraysize(kProviderSourceMap) ==
HostContentSettingsMap::NUM_PROVIDER_TYPES,
kProviderSourceMap_has_incorrect_size);
-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;
-}
-
// Returns true if the |content_type| supports a resource identifier.
// Resource identifiers are supported (but not required) for plug-ins.
bool SupportsResourceIdentifier(ContentSettingsType content_type) {
@@ -167,8 +160,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();
@@ -237,7 +228,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;
@@ -328,7 +318,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);
}
@@ -367,12 +357,23 @@ 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;
}
}
+// static
+bool HostContentSettingsMap::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 ||
+ type == CONTENT_SETTINGS_TYPE_MEDIASTREAM);
+}
+
void HostContentSettingsMap::OnContentSettingChanged(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
@@ -468,9 +469,21 @@ void HostContentSettingsMap::AddSettingsForOneType(
incognito));
while (rule_iterator->HasNext()) {
const content_settings::Rule& rule = rule_iterator->Next();
+ ContentSetting setting_value = CONTENT_SETTING_DEFAULT;
+ // TODO(bauerb): Return rules as a list of values, not content settings.
+ // Handle the case using compound values for its exceptions and arbitrary
+ // values for its default setting. Here we assume all the exceptions
+ // are granted as |CONTENT_SETTING_ALLOW|.
+ if (ContentTypeHasCompoundValue(content_type) &&
+ rule.value.get() &&
+ rule.primary_pattern != ContentSettingsPattern::Wildcard()) {
+ 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));
}