| 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 37361437f44d78816f86d39db90591f632e15a86..1d5e70fbde6e201735d1a41b536653af7af154aa 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 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,
|
| @@ -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, "mediastream"},
|
| };
|
|
|
| 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.
|
| + { "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));
|
| @@ -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, "mediastream",
|
| + 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.
|
| + 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));
|
|
|