Chromium Code Reviews| Index: chrome/browser/ui/webui/options2/content_settings_handler2.cc |
| diff --git a/chrome/browser/ui/webui/options2/content_settings_handler2.cc b/chrome/browser/ui/webui/options2/content_settings_handler2.cc |
| index 7d3dcd455f55381929f423b430245b613e4a8300..6442084632be1bb7cb0cd5989d5265f6934f7647 100644 |
| --- a/chrome/browser/ui/webui/options2/content_settings_handler2.cc |
| +++ b/chrome/browser/ui/webui/options2/content_settings_handler2.cc |
| @@ -194,6 +194,19 @@ bool HostedAppHasPermission( |
| return extension.is_hosted_app() && extension.HasAPIPermission(permission); |
| } |
| +// Create a DictionaryValue* that will act as a data source for a single row |
| +// in the Media Stream exceptions table. Ownership of the pointer is |
| +// passed to the caller. |
| +DictionaryValue* GetMediaStreamExceptionForPage( |
| + const ContentSettingsPattern& pattern) { |
| + DictionaryValue* exception = new DictionaryValue(); |
| + exception->SetString(kDisplayPattern, pattern.ToString()); |
| + exception->SetString(kSetting, ContentSettingToString(CONTENT_SETTING_ALLOW)); |
| + exception->SetString(kOrigin, pattern.ToString()); |
| + exception->SetString(kSource, std::string()); |
| + return exception; |
| +} |
| + |
| // Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from |
| // the web extent of a hosted |app|. |
| void AddExceptionForHostedApp(const std::string& url_pattern, |
| @@ -337,6 +350,7 @@ const ContentSettingsHandler::ExContentSettingsTypeNameEntry |
| {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"}, |
| {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"}, |
| {EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC, "pepper-flash-cameramic"}, |
| + {CONTENT_SETTINGS_TYPE_MEDIASTREAM, "media-stream"}, |
| }; |
| ContentSettingsHandler::ContentSettingsHandler() { |
| @@ -431,6 +445,11 @@ void ContentSettingsHandler::GetLocalizedValues( |
| { "protectedContentInfo", IDS_PROTECTED_CONTENT_INFO }, |
| { "protectedContentEnable", IDS_PROTECTED_CONTENT_ENABLE}, |
| #endif // defined(OS_CHROMEOS) |
| + // Media stream capture device filter. |
| + { "mediaStreamTabLabel", IDS_MEDIA_STREAM_TAB_LABEL }, |
| + { "media-stream_header", IDS_MEDIA_STREAM_HEADER }, |
| + { "mediaStreamAsk", IDS_MEDIA_STREAM_ASK_RADIO }, |
| + { "mediaStreamBlock", IDS_MEDIA_STREAM_BLOCK_RADIO }, |
| }; |
| RegisterStrings(localized_strings, resources, arraysize(resources)); |
| @@ -459,6 +478,8 @@ void ContentSettingsHandler::GetLocalizedValues( |
| IDS_MOUSE_LOCK_TAB_LABEL); |
| RegisterTitle(localized_strings, "pepper-flash-cameramic", |
| IDS_PEPPER_FLASH_CAMERAMIC_TAB_LABEL); |
| + RegisterTitle(localized_strings, "medias-tream", |
| + IDS_MEDIA_STREAM_TAB_LABEL); |
| Profile* profile = Profile::FromWebUI(web_ui()); |
| localized_strings->SetBoolean( |
| @@ -678,6 +699,8 @@ void ContentSettingsHandler::UpdateExceptionsViewFromModel( |
| break; |
| case EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC: |
| UpdateFlashCameraMicExceptionsView(); |
| + case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
| + UpdateMediaStreamExceptionsView(); |
| break; |
| default: |
| UpdateExceptionsViewFromHostContentSettingsMap( |
| @@ -695,6 +718,9 @@ void ContentSettingsHandler::UpdateOTRExceptionsViewFromModel( |
| case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE: |
| case EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC: |
| break; |
| + case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
| + // TODO(xians): Add MediaStream support to OTRExceptionsView. |
| + break; |
| default: |
| UpdateExceptionsViewFromOTRHostContentSettingsMap( |
| type.ToContentSettingsType()); |
| @@ -837,6 +863,35 @@ void ContentSettingsHandler::UpdateFlashCameraMicExceptionsView() { |
| ExContentSettingsType(EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC)); |
| } |
| +void ContentSettingsHandler::UpdateMediaStreamExceptionsView() { |
| + ContentSettingsForOneType entries; |
| + GetContentSettingsMap()->GetSettingsForOneType( |
| + CONTENT_SETTINGS_TYPE_MEDIASTREAM, "", &entries); |
| + |
| + ListValue exceptions; |
| + for (size_t i = 0; i < entries.size(); ++i) { |
| + // Don't add default settings. |
| + if (entries[i].primary_pattern == ContentSettingsPattern::Wildcard() && |
| + entries[i].secondary_pattern == ContentSettingsPattern::Wildcard() && |
| + entries[i].source != "preference") { |
| + continue; |
| + } |
| + |
| + exceptions.Append( |
| + GetMediaStreamExceptionForPage(entries[i].primary_pattern)); |
| + } |
| + |
| + StringValue type_string(ContentSettingsTypeToGroupName( |
| + CONTENT_SETTINGS_TYPE_MEDIASTREAM)); |
| + web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, |
| + exceptions); |
| + |
| + // This is mainly here to keep this function ideologically parallel to |
| + // UpdateExceptionsViewFromHostContentSettingsMap(). |
| + UpdateSettingDefaultFromModel( |
| + ExContentSettingsType(CONTENT_SETTINGS_TYPE_MEDIASTREAM)); |
| +} |
| + |
| void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( |
| ContentSettingsType type) { |
| ContentSettingsForOneType entries; |
| @@ -1047,6 +1102,10 @@ void ContentSettingsHandler::SetContentFilter(const ListValue* args) { |
| content::RecordAction( |
| UserMetricsAction("Options_DefaultFlashCameraMicSettingChanged")); |
| break; |
| + case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
| + content::RecordAction( |
| + UserMetricsAction("Options_DefaultMediaStreamSettingChanged")); |
| + break; |
| default: |
| break; |
| } |
| @@ -1117,15 +1176,24 @@ void ContentSettingsHandler::RemoveException(const ListValue* args) { |
| HostContentSettingsMap* settings_map = |
| mode == "normal" ? GetContentSettingsMap() : |
| GetOTRContentSettingsMap(); |
| - // The settings map could be null if the mode was OTR but the OTR profile |
| - // got destroyed before we received this message. |
| if (settings_map) { |
| - settings_map->SetContentSetting( |
| - ContentSettingsPattern::FromString(pattern), |
| - ContentSettingsPattern::Wildcard(), |
| - type.ToContentSettingsType(), |
| - "", |
| - CONTENT_SETTING_DEFAULT); |
| + // MediaStream is using compound value, so we need to use |
| + // SetWebsiteSetting instead of SetContentSetting. |
|
Bernhard Bauer
2012/06/18 17:38:15
I think you *can* use SetWebsiteSetting for simple
no longer working on chromium
2012/06/19 12:23:17
Done.
|
| + if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { |
| + settings_map->SetWebsiteSetting( |
| + ContentSettingsPattern::FromString(pattern), |
| + ContentSettingsPattern::Wildcard(), |
| + type.ToContentSettingsType(), |
| + "", |
| + NULL); |
| + } else { |
| + settings_map->SetContentSetting( |
| + ContentSettingsPattern::FromString(pattern), |
| + ContentSettingsPattern::Wildcard(), |
| + type.ToContentSettingsType(), |
| + "", |
| + CONTENT_SETTING_DEFAULT); |
| + } |
| } |
| } |
| } |
| @@ -1144,7 +1212,8 @@ void ContentSettingsHandler::SetException(const ListValue* args) { |
| ExContentSettingsType type = ExContentSettingsTypeFromGroupName(type_string); |
| if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || |
| - type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| + type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS || |
| + type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { |
| NOTREACHED(); |
| } else if (type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) { |
| DCHECK(IsValidHost(pattern)); |