| 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 1e27409db825e8f04ec5d4183aa9471479896527..a28d73fbcf01384d8736fbfb45e4cd9e0f6c2abe 100644
|
| --- a/chrome/browser/ui/webui/options2/content_settings_handler2.cc
|
| +++ b/chrome/browser/ui/webui/options2/content_settings_handler2.cc
|
| @@ -80,6 +80,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
|
| {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"},
|
| {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"},
|
| {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"},
|
| + {CONTENT_SETTINGS_TYPE_MEDIASTREAM, "mediastream"},
|
| };
|
| COMPILE_ASSERT(arraysize(kContentSettingsTypeGroupNames) ==
|
| CONTENT_SETTINGS_NUM_TYPES,
|
| @@ -197,6 +198,19 @@ DictionaryValue* GetNotificationExceptionForPage(
|
| return exception;
|
| }
|
|
|
| +// Create a DictionaryValue* that will act as a data source for a single row
|
| +// in the mediastream 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,
|
| @@ -334,6 +348,11 @@ void ContentSettingsHandler::GetLocalizedValues(
|
| { "protectedContentInfo", IDS_PROTECTED_CONTENT_INFO },
|
| { "protectedContentEnable", IDS_PROTECTED_CONTENT_ENABLE},
|
| #endif // defined(OS_CHROMEOS)
|
| + // Media stream capture device filter.
|
| + { "mediastream_tab_label", IDS_MEDIA_STREAM_TAB_LABEL },
|
| + { "mediastream_header", IDS_MEDIA_STREAM_HEADER },
|
| + { "mediastream_ask", IDS_MEDIA_STREAM_ASK_RADIO },
|
| + { "mediastream_block", IDS_MEDIA_STREAM_BLOCK_RADIO },
|
| };
|
|
|
| RegisterStrings(localized_strings, resources, arraysize(resources));
|
| @@ -360,6 +379,8 @@ void ContentSettingsHandler::GetLocalizedValues(
|
| IDS_FULLSCREEN_TAB_LABEL);
|
| RegisterTitle(localized_strings, "mouselock",
|
| IDS_MOUSE_LOCK_TAB_LABEL);
|
| + RegisterTitle(localized_strings, "mediastream",
|
| + IDS_MEDIA_STREAM_TAB_LABEL);
|
|
|
| Profile* profile = Profile::FromWebUI(web_ui());
|
| localized_strings->SetBoolean(
|
| @@ -536,6 +557,9 @@ void ContentSettingsHandler::UpdateExceptionsViewFromModel(
|
| case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
|
| UpdateNotificationExceptionsView();
|
| break;
|
| + case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
|
| + UpdateMediaStreamExceptionsView();
|
| + break;
|
| default:
|
| UpdateExceptionsViewFromHostContentSettingsMap(type);
|
| break;
|
| @@ -549,6 +573,8 @@ void ContentSettingsHandler::UpdateOTRExceptionsViewFromModel(
|
| case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
|
| case CONTENT_SETTINGS_TYPE_INTENTS:
|
| case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE:
|
| + case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
|
| + // TODO(xians): Add MediaStream support to OTRExceptionsView.
|
| break;
|
| default:
|
| UpdateExceptionsViewFromOTRHostContentSettingsMap(type);
|
| @@ -663,6 +689,34 @@ void ContentSettingsHandler::UpdateNotificationExceptionsView() {
|
| UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
|
| }
|
|
|
| +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(CONTENT_SETTINGS_TYPE_MEDIASTREAM);
|
| +}
|
| +
|
| void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap(
|
| ContentSettingsType type) {
|
| ContentSettingsForOneType entries;
|
| @@ -857,6 +911,10 @@ void ContentSettingsHandler::SetContentFilter(const ListValue* args) {
|
| content::RecordAction(
|
| UserMetricsAction("Options_DefaultMouseLockSettingChanged"));
|
| break;
|
| + case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
|
| + content::RecordAction(
|
| + UserMetricsAction("Options_DefaultMediaStreamSettingChanged"));
|
| + break;
|
| default:
|
| break;
|
| }
|
| @@ -911,12 +969,23 @@ void ContentSettingsHandler::RemoveException(const ListValue* args) {
|
| // 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(),
|
| - ContentSettingsTypeFromGroupName(type_string),
|
| - "",
|
| - CONTENT_SETTING_DEFAULT);
|
| + // MediaStream is using compound value, so we need to use
|
| + // SetWebsiteSetting instead of SetContentSetting.
|
| + if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
|
| + settings_map->SetWebsiteSetting(
|
| + ContentSettingsPattern::FromString(pattern),
|
| + ContentSettingsPattern::Wildcard(),
|
| + ContentSettingsTypeFromGroupName(type_string),
|
| + "",
|
| + NULL);
|
| + } else {
|
| + settings_map->SetContentSetting(
|
| + ContentSettingsPattern::FromString(pattern),
|
| + ContentSettingsPattern::Wildcard(),
|
| + ContentSettingsTypeFromGroupName(type_string),
|
| + "",
|
| + CONTENT_SETTING_DEFAULT);
|
| + }
|
| }
|
| }
|
| }
|
| @@ -934,7 +1003,8 @@ void ContentSettingsHandler::SetException(const ListValue* args) {
|
|
|
| ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string);
|
| if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION ||
|
| - type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
|
| + type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS ||
|
| + type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
|
| NOTREACHED();
|
| return;
|
| }
|
|
|