OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/options2/content_settings_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/content_settings_handler2.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"}, | 332 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"}, |
333 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"}, | 333 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"}, |
334 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"}, | 334 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"}, |
335 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"}, | 335 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"}, |
336 {CONTENT_SETTINGS_TYPE_INTENTS, "intents"}, | 336 {CONTENT_SETTINGS_TYPE_INTENTS, "intents"}, |
337 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"}, | 337 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"}, |
338 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"}, | 338 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"}, |
339 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"}, | 339 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"}, |
340 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, "mixed-script"}, | 340 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, "mixed-script"}, |
341 {EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC, "pepper-flash-cameramic"}, | 341 {EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC, "pepper-flash-cameramic"}, |
| 342 {CONTENT_SETTINGS_TYPE_MEDIASTREAM, "media-stream"}, |
342 }; | 343 }; |
343 | 344 |
344 ContentSettingsHandler::ContentSettingsHandler() { | 345 ContentSettingsHandler::ContentSettingsHandler() { |
345 } | 346 } |
346 | 347 |
347 ContentSettingsHandler::~ContentSettingsHandler() { | 348 ContentSettingsHandler::~ContentSettingsHandler() { |
348 } | 349 } |
349 | 350 |
350 void ContentSettingsHandler::GetLocalizedValues( | 351 void ContentSettingsHandler::GetLocalizedValues( |
351 DictionaryValue* localized_strings) { | 352 DictionaryValue* localized_strings) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 // The header has to be named as <content_type_name>_header. | 427 // The header has to be named as <content_type_name>_header. |
427 { "pepper-flash-cameramic_header", IDS_PEPPER_FLASH_CAMERAMIC_HEADER }, | 428 { "pepper-flash-cameramic_header", IDS_PEPPER_FLASH_CAMERAMIC_HEADER }, |
428 { "pepperFlashCameramicAsk", IDS_PEPPER_FLASH_CAMERAMIC_ASK_RADIO }, | 429 { "pepperFlashCameramicAsk", IDS_PEPPER_FLASH_CAMERAMIC_ASK_RADIO }, |
429 { "pepperFlashCameramicBlock", IDS_PEPPER_FLASH_CAMERAMIC_BLOCK_RADIO }, | 430 { "pepperFlashCameramicBlock", IDS_PEPPER_FLASH_CAMERAMIC_BLOCK_RADIO }, |
430 #if defined(OS_CHROMEOS) | 431 #if defined(OS_CHROMEOS) |
431 // Protected Content filter | 432 // Protected Content filter |
432 { "protectedContentTabLabel", IDS_PROTECTED_CONTENT_TAB_LABEL }, | 433 { "protectedContentTabLabel", IDS_PROTECTED_CONTENT_TAB_LABEL }, |
433 { "protectedContentInfo", IDS_PROTECTED_CONTENT_INFO }, | 434 { "protectedContentInfo", IDS_PROTECTED_CONTENT_INFO }, |
434 { "protectedContentEnable", IDS_PROTECTED_CONTENT_ENABLE}, | 435 { "protectedContentEnable", IDS_PROTECTED_CONTENT_ENABLE}, |
435 #endif // defined(OS_CHROMEOS) | 436 #endif // defined(OS_CHROMEOS) |
| 437 // Media stream capture device filter. |
| 438 { "mediaStreamTabLabel", IDS_MEDIA_STREAM_TAB_LABEL }, |
| 439 { "media-stream_header", IDS_MEDIA_STREAM_HEADER }, |
| 440 { "mediaStreamAsk", IDS_MEDIA_STREAM_ASK_RADIO }, |
| 441 { "mediaStreamBlock", IDS_MEDIA_STREAM_BLOCK_RADIO }, |
436 }; | 442 }; |
437 | 443 |
438 RegisterStrings(localized_strings, resources, arraysize(resources)); | 444 RegisterStrings(localized_strings, resources, arraysize(resources)); |
439 RegisterTitle(localized_strings, "contentSettingsPage", | 445 RegisterTitle(localized_strings, "contentSettingsPage", |
440 IDS_CONTENT_SETTINGS_TITLE); | 446 IDS_CONTENT_SETTINGS_TITLE); |
441 | 447 |
442 // Register titles for each of the individual settings whose exception | 448 // Register titles for each of the individual settings whose exception |
443 // dialogs will be processed by |ContentSettingsHandler|. | 449 // dialogs will be processed by |ContentSettingsHandler|. |
444 RegisterTitle(localized_strings, "cookies", | 450 RegisterTitle(localized_strings, "cookies", |
445 IDS_COOKIES_TAB_LABEL); | 451 IDS_COOKIES_TAB_LABEL); |
446 RegisterTitle(localized_strings, "images", | 452 RegisterTitle(localized_strings, "images", |
447 IDS_IMAGES_TAB_LABEL); | 453 IDS_IMAGES_TAB_LABEL); |
448 RegisterTitle(localized_strings, "javascript", | 454 RegisterTitle(localized_strings, "javascript", |
449 IDS_JAVASCRIPT_TAB_LABEL); | 455 IDS_JAVASCRIPT_TAB_LABEL); |
450 RegisterTitle(localized_strings, "plugins", | 456 RegisterTitle(localized_strings, "plugins", |
451 IDS_PLUGIN_TAB_LABEL); | 457 IDS_PLUGIN_TAB_LABEL); |
452 RegisterTitle(localized_strings, "popups", | 458 RegisterTitle(localized_strings, "popups", |
453 IDS_POPUP_TAB_LABEL); | 459 IDS_POPUP_TAB_LABEL); |
454 RegisterTitle(localized_strings, "location", | 460 RegisterTitle(localized_strings, "location", |
455 IDS_GEOLOCATION_TAB_LABEL); | 461 IDS_GEOLOCATION_TAB_LABEL); |
456 RegisterTitle(localized_strings, "notifications", | 462 RegisterTitle(localized_strings, "notifications", |
457 IDS_NOTIFICATIONS_TAB_LABEL); | 463 IDS_NOTIFICATIONS_TAB_LABEL); |
458 RegisterTitle(localized_strings, "fullscreen", | 464 RegisterTitle(localized_strings, "fullscreen", |
459 IDS_FULLSCREEN_TAB_LABEL); | 465 IDS_FULLSCREEN_TAB_LABEL); |
460 RegisterTitle(localized_strings, "mouselock", | 466 RegisterTitle(localized_strings, "mouselock", |
461 IDS_MOUSE_LOCK_TAB_LABEL); | 467 IDS_MOUSE_LOCK_TAB_LABEL); |
462 RegisterTitle(localized_strings, "pepper-flash-cameramic", | 468 RegisterTitle(localized_strings, "pepper-flash-cameramic", |
463 IDS_PEPPER_FLASH_CAMERAMIC_TAB_LABEL); | 469 IDS_PEPPER_FLASH_CAMERAMIC_TAB_LABEL); |
| 470 RegisterTitle(localized_strings, "media-stream", |
| 471 IDS_MEDIA_STREAM_TAB_LABEL); |
464 | 472 |
465 Profile* profile = Profile::FromWebUI(web_ui()); | 473 Profile* profile = Profile::FromWebUI(web_ui()); |
466 localized_strings->SetBoolean( | 474 localized_strings->SetBoolean( |
467 "enable_web_intents", | 475 "enable_web_intents", |
468 web_intents::IsWebIntentsEnabledForProfile(profile)); | 476 web_intents::IsWebIntentsEnabledForProfile(profile)); |
469 // TODO(marja): clean up the options UI after the decision on the session | 477 // TODO(marja): clean up the options UI after the decision on the session |
470 // restore changes has stabilized. | 478 // restore changes has stabilized. |
471 localized_strings->SetBoolean( | 479 localized_strings->SetBoolean( |
472 "enable_restore_session_state", false); | 480 "enable_restore_session_state", false); |
473 } | 481 } |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 entries[i].source != "preference") { | 867 entries[i].source != "preference") { |
860 continue; | 868 continue; |
861 } | 869 } |
862 // The content settings UI does not support secondary content settings | 870 // The content settings UI does not support secondary content settings |
863 // pattern yet. For content settings set through the content settings UI the | 871 // pattern yet. For content settings set through the content settings UI the |
864 // secondary pattern is by default a wildcard pattern. Hence users are not | 872 // secondary pattern is by default a wildcard pattern. Hence users are not |
865 // able to modify content settings with a secondary pattern other than the | 873 // able to modify content settings with a secondary pattern other than the |
866 // wildcard pattern. So only show settings that the user is able to modify. | 874 // wildcard pattern. So only show settings that the user is able to modify. |
867 // TODO(bauerb): Support a read-only view for those patterns. | 875 // TODO(bauerb): Support a read-only view for those patterns. |
868 if (entries[i].secondary_pattern == ContentSettingsPattern::Wildcard()) { | 876 if (entries[i].secondary_pattern == ContentSettingsPattern::Wildcard()) { |
869 exceptions.Append( | 877 // Media Stream is using compound values for exceptions, which are |
870 GetExceptionForPage(entries[i].primary_pattern, entries[i].setting, | 878 // granted as |CONTENT_SETTING_ALLOW|. |
871 entries[i].source)); | 879 ContentSetting content_setting = CONTENT_SETTING_DEFAULT; |
| 880 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) |
| 881 content_setting = CONTENT_SETTING_ALLOW; |
| 882 else |
| 883 content_setting = entries[i].setting; |
| 884 |
| 885 exceptions.Append(GetExceptionForPage(entries[i].primary_pattern, |
| 886 content_setting, |
| 887 entries[i].source)); |
872 } else { | 888 } else { |
873 LOG(ERROR) << "Secondary content settings patterns are not " | 889 LOG(ERROR) << "Secondary content settings patterns are not " |
874 << "supported by the content settings UI"; | 890 << "supported by the content settings UI"; |
875 } | 891 } |
876 } | 892 } |
877 | 893 |
878 StringValue type_string(ContentSettingsTypeToGroupName(type)); | 894 StringValue type_string(ContentSettingsTypeToGroupName(type)); |
879 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, | 895 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, |
880 exceptions); | 896 exceptions); |
881 | 897 |
(...skipping 26 matching lines...) Expand all Loading... |
908 if (!otr_entries[i].incognito) | 924 if (!otr_entries[i].incognito) |
909 continue; | 925 continue; |
910 // The content settings UI does not support secondary content settings | 926 // The content settings UI does not support secondary content settings |
911 // pattern yet. For content settings set through the content settings UI the | 927 // pattern yet. For content settings set through the content settings UI the |
912 // secondary pattern is by default a wildcard pattern. Hence users are not | 928 // secondary pattern is by default a wildcard pattern. Hence users are not |
913 // able to modify content settings with a secondary pattern other than the | 929 // able to modify content settings with a secondary pattern other than the |
914 // wildcard pattern. So only show settings that the user is able to modify. | 930 // wildcard pattern. So only show settings that the user is able to modify. |
915 // TODO(bauerb): Support a read-only view for those patterns. | 931 // TODO(bauerb): Support a read-only view for those patterns. |
916 if (otr_entries[i].secondary_pattern == | 932 if (otr_entries[i].secondary_pattern == |
917 ContentSettingsPattern::Wildcard()) { | 933 ContentSettingsPattern::Wildcard()) { |
918 otr_exceptions.Append( | 934 ContentSetting content_setting = CONTENT_SETTING_DEFAULT; |
919 GetExceptionForPage(otr_entries[i].primary_pattern, | 935 // Media Stream is using compound values for its exceptions and arbitrary |
920 otr_entries[i].setting, | 936 // values for its default setting. And all the exceptions are granted as |
921 otr_entries[i].source)); | 937 // |CONTENT_SETTING_ALLOW|. |
| 938 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM && |
| 939 otr_entries[i].primary_pattern != ContentSettingsPattern::Wildcard()) |
| 940 content_setting = CONTENT_SETTING_ALLOW; |
| 941 else |
| 942 content_setting = otr_entries[i].setting; |
| 943 |
| 944 otr_exceptions.Append(GetExceptionForPage(otr_entries[i].primary_pattern, |
| 945 content_setting, |
| 946 otr_entries[i].source)); |
922 } else { | 947 } else { |
923 LOG(ERROR) << "Secondary content settings patterns are not " | 948 LOG(ERROR) << "Secondary content settings patterns are not " |
924 << "supported by the content settings UI"; | 949 << "supported by the content settings UI"; |
925 } | 950 } |
926 } | 951 } |
927 | 952 |
928 StringValue type_string(ContentSettingsTypeToGroupName(type)); | 953 StringValue type_string(ContentSettingsTypeToGroupName(type)); |
929 web_ui()->CallJavascriptFunction("ContentSettings.setOTRExceptions", | 954 web_ui()->CallJavascriptFunction("ContentSettings.setOTRExceptions", |
930 type_string, otr_exceptions); | 955 type_string, otr_exceptions); |
931 } | 956 } |
932 | 957 |
| 958 void ContentSettingsHandler::RemoveGeolocationException( |
| 959 const ListValue* args, size_t arg_index) { |
| 960 Profile* profile = Profile::FromWebUI(web_ui()); |
| 961 std::string origin; |
| 962 std::string embedding_origin; |
| 963 bool rv = args->GetString(arg_index++, &origin); |
| 964 DCHECK(rv); |
| 965 rv = args->GetString(arg_index++, &embedding_origin); |
| 966 DCHECK(rv); |
| 967 |
| 968 profile->GetHostContentSettingsMap()-> |
| 969 SetContentSetting(ContentSettingsPattern::FromString(origin), |
| 970 ContentSettingsPattern::FromString(embedding_origin), |
| 971 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 972 std::string(), |
| 973 CONTENT_SETTING_DEFAULT); |
| 974 } |
| 975 |
| 976 void ContentSettingsHandler::RemoveNotificationException( |
| 977 const ListValue* args, size_t arg_index) { |
| 978 Profile* profile = Profile::FromWebUI(web_ui()); |
| 979 std::string origin; |
| 980 std::string setting; |
| 981 bool rv = args->GetString(arg_index++, &origin); |
| 982 DCHECK(rv); |
| 983 rv = args->GetString(arg_index++, &setting); |
| 984 DCHECK(rv); |
| 985 ContentSetting content_setting = ContentSettingFromString(setting); |
| 986 |
| 987 DCHECK(content_setting == CONTENT_SETTING_ALLOW || |
| 988 content_setting == CONTENT_SETTING_BLOCK); |
| 989 DesktopNotificationServiceFactory::GetForProfile(profile)-> |
| 990 ClearSetting(ContentSettingsPattern::FromString(origin)); |
| 991 } |
| 992 |
| 993 void ContentSettingsHandler::RemoveFlashCameraMicException( |
| 994 const ListValue* args, size_t arg_index) { |
| 995 std::string mode; |
| 996 bool rv = args->GetString(arg_index++, &mode); |
| 997 DCHECK(rv); |
| 998 DCHECK_EQ(mode, "normal"); |
| 999 |
| 1000 std::string pattern; |
| 1001 rv = args->GetString(arg_index++, &pattern); |
| 1002 DCHECK(rv); |
| 1003 |
| 1004 CachedPepperFlashSettings::SiteMap::iterator iter = |
| 1005 flash_cameramic_settings_.sites.find(pattern); |
| 1006 if (iter != flash_cameramic_settings_.sites.end()) { |
| 1007 flash_cameramic_settings_.sites.erase(iter); |
| 1008 ppapi::FlashSiteSettings site_settings( |
| 1009 1, |
| 1010 ppapi::FlashSiteSetting(pattern, |
| 1011 PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT)); |
| 1012 flash_settings_manager_->SetSitePermission( |
| 1013 PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC, |
| 1014 site_settings); |
| 1015 } else { |
| 1016 NOTREACHED(); |
| 1017 } |
| 1018 |
| 1019 UpdateFlashCameraMicExceptionsView(); |
| 1020 } |
| 1021 |
| 1022 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap( |
| 1023 const ListValue* args, size_t arg_index, |
| 1024 const ExContentSettingsType& type) { |
| 1025 std::string mode; |
| 1026 bool rv = args->GetString(arg_index++, &mode); |
| 1027 DCHECK(rv); |
| 1028 |
| 1029 std::string pattern; |
| 1030 rv = args->GetString(arg_index++, &pattern); |
| 1031 DCHECK(rv); |
| 1032 |
| 1033 HostContentSettingsMap* settings_map = |
| 1034 mode == "normal" ? GetContentSettingsMap() : |
| 1035 GetOTRContentSettingsMap(); |
| 1036 if (settings_map) { |
| 1037 settings_map->SetWebsiteSetting( |
| 1038 ContentSettingsPattern::FromString(pattern), |
| 1039 ContentSettingsPattern::Wildcard(), |
| 1040 type.ToContentSettingsType(), |
| 1041 "", |
| 1042 NULL); |
| 1043 } |
| 1044 } |
| 1045 |
933 void ContentSettingsHandler::RegisterMessages() { | 1046 void ContentSettingsHandler::RegisterMessages() { |
934 web_ui()->RegisterMessageCallback("setContentFilter", | 1047 web_ui()->RegisterMessageCallback("setContentFilter", |
935 base::Bind(&ContentSettingsHandler::SetContentFilter, | 1048 base::Bind(&ContentSettingsHandler::SetContentFilter, |
936 base::Unretained(this))); | 1049 base::Unretained(this))); |
937 web_ui()->RegisterMessageCallback("removeException", | 1050 web_ui()->RegisterMessageCallback("removeException", |
938 base::Bind(&ContentSettingsHandler::RemoveException, | 1051 base::Bind(&ContentSettingsHandler::RemoveException, |
939 base::Unretained(this))); | 1052 base::Unretained(this))); |
940 web_ui()->RegisterMessageCallback("setException", | 1053 web_ui()->RegisterMessageCallback("setException", |
941 base::Bind(&ContentSettingsHandler::SetException, | 1054 base::Bind(&ContentSettingsHandler::SetException, |
942 base::Unretained(this))); | 1055 base::Unretained(this))); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 UserMetricsAction("Options_DefaultHandlersSettingChanged")); | 1158 UserMetricsAction("Options_DefaultHandlersSettingChanged")); |
1046 break; | 1159 break; |
1047 case CONTENT_SETTINGS_TYPE_MOUSELOCK: | 1160 case CONTENT_SETTINGS_TYPE_MOUSELOCK: |
1048 content::RecordAction( | 1161 content::RecordAction( |
1049 UserMetricsAction("Options_DefaultMouseLockSettingChanged")); | 1162 UserMetricsAction("Options_DefaultMouseLockSettingChanged")); |
1050 break; | 1163 break; |
1051 case EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC: | 1164 case EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC: |
1052 content::RecordAction( | 1165 content::RecordAction( |
1053 UserMetricsAction("Options_DefaultFlashCameraMicSettingChanged")); | 1166 UserMetricsAction("Options_DefaultFlashCameraMicSettingChanged")); |
1054 break; | 1167 break; |
| 1168 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
| 1169 content::RecordAction( |
| 1170 UserMetricsAction("Options_DefaultMediaStreamSettingChanged")); |
| 1171 break; |
1055 default: | 1172 default: |
1056 break; | 1173 break; |
1057 } | 1174 } |
1058 } | 1175 } |
1059 | 1176 |
1060 void ContentSettingsHandler::RemoveException(const ListValue* args) { | 1177 void ContentSettingsHandler::RemoveException(const ListValue* args) { |
1061 size_t arg_i = 0; | 1178 size_t arg_i = 0; |
1062 std::string type_string; | 1179 std::string type_string; |
1063 CHECK(args->GetString(arg_i++, &type_string)); | 1180 CHECK(args->GetString(arg_i++, &type_string)); |
1064 | 1181 |
1065 Profile* profile = Profile::FromWebUI(web_ui()); | 1182 ExContentSettingsType type = ExContentSettingsTypeFromGroupName(type_string); |
1066 ExContentSettingsType type = ExContentSettingsTypeFromGroupName( | 1183 switch (type) { |
1067 type_string); | 1184 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
1068 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 1185 RemoveGeolocationException(args, arg_i); |
1069 std::string origin; | 1186 break; |
1070 std::string embedding_origin; | 1187 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
1071 bool rv = args->GetString(arg_i++, &origin); | 1188 RemoveNotificationException(args, arg_i); |
1072 DCHECK(rv); | 1189 break; |
1073 rv = args->GetString(arg_i++, &embedding_origin); | 1190 case EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC: |
1074 DCHECK(rv); | 1191 RemoveFlashCameraMicException(args, arg_i); |
1075 | 1192 break; |
1076 profile->GetHostContentSettingsMap()-> | 1193 default: |
1077 SetContentSetting(ContentSettingsPattern::FromString(origin), | 1194 RemoveExceptionFromHostContentSettingsMap(args, arg_i, type); |
1078 ContentSettingsPattern::FromString(embedding_origin), | 1195 break; |
1079 CONTENT_SETTINGS_TYPE_GEOLOCATION, | |
1080 std::string(), | |
1081 CONTENT_SETTING_DEFAULT); | |
1082 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | |
1083 std::string origin; | |
1084 std::string setting; | |
1085 bool rv = args->GetString(arg_i++, &origin); | |
1086 DCHECK(rv); | |
1087 rv = args->GetString(arg_i++, &setting); | |
1088 DCHECK(rv); | |
1089 ContentSetting content_setting = ContentSettingFromString(setting); | |
1090 | |
1091 DCHECK(content_setting == CONTENT_SETTING_ALLOW || | |
1092 content_setting == CONTENT_SETTING_BLOCK); | |
1093 DesktopNotificationServiceFactory::GetForProfile(profile)-> | |
1094 ClearSetting(ContentSettingsPattern::FromString(origin)); | |
1095 } else { | |
1096 std::string mode; | |
1097 bool rv = args->GetString(arg_i++, &mode); | |
1098 DCHECK(rv); | |
1099 | |
1100 std::string pattern; | |
1101 rv = args->GetString(arg_i++, &pattern); | |
1102 DCHECK(rv); | |
1103 | |
1104 if (type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) { | |
1105 DCHECK_EQ(mode, "normal"); | |
1106 | |
1107 CachedPepperFlashSettings::SiteMap::iterator iter = | |
1108 flash_cameramic_settings_.sites.find(pattern); | |
1109 if (iter != flash_cameramic_settings_.sites.end()) { | |
1110 flash_cameramic_settings_.sites.erase(iter); | |
1111 ppapi::FlashSiteSettings site_settings(1, | |
1112 ppapi::FlashSiteSetting( | |
1113 pattern, PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT)); | |
1114 flash_settings_manager_->SetSitePermission( | |
1115 PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC, | |
1116 site_settings); | |
1117 } else { | |
1118 NOTREACHED(); | |
1119 } | |
1120 UpdateFlashCameraMicExceptionsView(); | |
1121 } else { | |
1122 HostContentSettingsMap* settings_map = | |
1123 mode == "normal" ? GetContentSettingsMap() : | |
1124 GetOTRContentSettingsMap(); | |
1125 // The settings map could be null if the mode was OTR but the OTR profile | |
1126 // got destroyed before we received this message. | |
1127 if (settings_map) { | |
1128 settings_map->SetContentSetting( | |
1129 ContentSettingsPattern::FromString(pattern), | |
1130 ContentSettingsPattern::Wildcard(), | |
1131 type.ToContentSettingsType(), | |
1132 "", | |
1133 CONTENT_SETTING_DEFAULT); | |
1134 } | |
1135 } | |
1136 } | 1196 } |
1137 } | 1197 } |
1138 | 1198 |
1139 void ContentSettingsHandler::SetException(const ListValue* args) { | 1199 void ContentSettingsHandler::SetException(const ListValue* args) { |
1140 size_t arg_i = 0; | 1200 size_t arg_i = 0; |
1141 std::string type_string; | 1201 std::string type_string; |
1142 CHECK(args->GetString(arg_i++, &type_string)); | 1202 CHECK(args->GetString(arg_i++, &type_string)); |
1143 std::string mode; | 1203 std::string mode; |
1144 CHECK(args->GetString(arg_i++, &mode)); | 1204 CHECK(args->GetString(arg_i++, &mode)); |
1145 std::string pattern; | 1205 std::string pattern; |
1146 CHECK(args->GetString(arg_i++, &pattern)); | 1206 CHECK(args->GetString(arg_i++, &pattern)); |
1147 std::string setting; | 1207 std::string setting; |
1148 CHECK(args->GetString(arg_i++, &setting)); | 1208 CHECK(args->GetString(arg_i++, &setting)); |
1149 | 1209 |
1150 ExContentSettingsType type = ExContentSettingsTypeFromGroupName(type_string); | 1210 ExContentSettingsType type = ExContentSettingsTypeFromGroupName(type_string); |
1151 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || | 1211 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || |
1152 type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 1212 type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS || |
| 1213 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { |
1153 NOTREACHED(); | 1214 NOTREACHED(); |
1154 } else if (type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) { | 1215 } else if (type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) { |
1155 DCHECK(IsValidHost(pattern)); | 1216 DCHECK(IsValidHost(pattern)); |
1156 | 1217 |
1157 if (flash_cameramic_settings_.sites.find(pattern) == | 1218 if (flash_cameramic_settings_.sites.find(pattern) == |
1158 flash_cameramic_settings_.sites.end()) { | 1219 flash_cameramic_settings_.sites.end()) { |
1159 pattern = CanonicalizeHost(pattern); | 1220 pattern = CanonicalizeHost(pattern); |
1160 } | 1221 } |
1161 PP_Flash_BrowserOperations_Permission permission = | 1222 PP_Flash_BrowserOperations_Permission permission = |
1162 FlashPermissionFromContentSetting(ContentSettingFromString(setting)); | 1223 FlashPermissionFromContentSetting(ContentSettingFromString(setting)); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 for (size_t i = 0; i < arraysize(kExContentSettingsTypeGroupNames); ++i) { | 1331 for (size_t i = 0; i < arraysize(kExContentSettingsTypeGroupNames); ++i) { |
1271 if (type == kExContentSettingsTypeGroupNames[i].type) | 1332 if (type == kExContentSettingsTypeGroupNames[i].type) |
1272 return kExContentSettingsTypeGroupNames[i].name; | 1333 return kExContentSettingsTypeGroupNames[i].name; |
1273 } | 1334 } |
1274 | 1335 |
1275 NOTREACHED(); | 1336 NOTREACHED(); |
1276 return std::string(); | 1337 return std::string(); |
1277 } | 1338 } |
1278 | 1339 |
1279 } // namespace options2 | 1340 } // namespace options2 |
OLD | NEW |