| 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/options/content_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 UpdateAllExceptionsViewsFromModel(); | 755 UpdateAllExceptionsViewsFromModel(); |
| 756 UpdateAllChooserExceptionsViewsFromModel(); | 756 UpdateAllChooserExceptionsViewsFromModel(); |
| 757 UpdateProtectedContentExceptionsButton(); | 757 UpdateProtectedContentExceptionsButton(); |
| 758 | 758 |
| 759 // Fullscreen and mouselock settings are ignored, but still stored. Always | 759 // Fullscreen and mouselock settings are ignored, but still stored. Always |
| 760 // show the per-site settings (to give users the ability to view and delete | 760 // show the per-site settings (to give users the ability to view and delete |
| 761 // exceptions), but hide the global settings. | 761 // exceptions), but hide the global settings. |
| 762 // TODO(mgiuca): Remove this function and the global setting UI | 762 // TODO(mgiuca): Remove this function and the global setting UI |
| 763 // (https://crbug.com/610900). Then, delete all the per-site data and remove | 763 // (https://crbug.com/610900). Then, delete all the per-site data and remove |
| 764 // this content setting entirely (https://crbug.com/591896). | 764 // this content setting entirely (https://crbug.com/591896). |
| 765 web_ui()->CallJavascriptFunction("ContentSettings.setExclusiveAccessVisible", | 765 web_ui()->CallJavascriptFunctionUnsafe( |
| 766 base::FundamentalValue(true), | 766 "ContentSettings.setExclusiveAccessVisible", base::FundamentalValue(true), |
| 767 base::FundamentalValue(false)); | 767 base::FundamentalValue(false)); |
| 768 } | 768 } |
| 769 | 769 |
| 770 void ContentSettingsHandler::OnContentSettingChanged( | 770 void ContentSettingsHandler::OnContentSettingChanged( |
| 771 const ContentSettingsPattern& primary_pattern, | 771 const ContentSettingsPattern& primary_pattern, |
| 772 const ContentSettingsPattern& secondary_pattern, | 772 const ContentSettingsPattern& secondary_pattern, |
| 773 ContentSettingsType content_type, | 773 ContentSettingsType content_type, |
| 774 std::string resource_identifier) { | 774 std::string resource_identifier) { |
| 775 const ContentSettingsDetails details( | 775 const ContentSettingsDetails details( |
| 776 primary_pattern, secondary_pattern, content_type, resource_identifier); | 776 primary_pattern, secondary_pattern, content_type, resource_identifier); |
| 777 // TODO(estade): we pretend update_all() is always true. | 777 // TODO(estade): we pretend update_all() is always true. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 788 int type, | 788 int type, |
| 789 const content::NotificationSource& source, | 789 const content::NotificationSource& source, |
| 790 const content::NotificationDetails& details) { | 790 const content::NotificationDetails& details) { |
| 791 switch (type) { | 791 switch (type) { |
| 792 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 792 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| 793 Profile* profile = content::Source<Profile>(source).ptr(); | 793 Profile* profile = content::Source<Profile>(source).ptr(); |
| 794 HostContentSettingsMap* settings_map = | 794 HostContentSettingsMap* settings_map = |
| 795 HostContentSettingsMapFactory::GetForProfile(profile); | 795 HostContentSettingsMapFactory::GetForProfile(profile); |
| 796 if (profile->IsOffTheRecord() && | 796 if (profile->IsOffTheRecord() && |
| 797 observer_.IsObserving(settings_map)) { | 797 observer_.IsObserving(settings_map)) { |
| 798 web_ui()->CallJavascriptFunction( | 798 web_ui()->CallJavascriptFunctionUnsafe( |
| 799 "ContentSettingsExceptionsArea.OTRProfileDestroyed"); | 799 "ContentSettingsExceptionsArea.OTRProfileDestroyed"); |
| 800 observer_.Remove(settings_map); | 800 observer_.Remove(settings_map); |
| 801 } | 801 } |
| 802 break; | 802 break; |
| 803 } | 803 } |
| 804 | 804 |
| 805 case chrome::NOTIFICATION_PROFILE_CREATED: { | 805 case chrome::NOTIFICATION_PROFILE_CREATED: { |
| 806 Profile* profile = content::Source<Profile>(source).ptr(); | 806 Profile* profile = content::Source<Profile>(source).ptr(); |
| 807 if (profile->IsOffTheRecord()) { | 807 if (profile->IsOffTheRecord()) { |
| 808 UpdateAllOTRExceptionsViewsFromModel(); | 808 UpdateAllOTRExceptionsViewsFromModel(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 | 870 |
| 871 std::string setting_string = | 871 std::string setting_string = |
| 872 content_settings::ContentSettingToString(default_setting); | 872 content_settings::ContentSettingToString(default_setting); |
| 873 DCHECK(!setting_string.empty()); | 873 DCHECK(!setting_string.empty()); |
| 874 | 874 |
| 875 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", | 875 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", |
| 876 setting_string); | 876 setting_string); |
| 877 filter_settings.SetString( | 877 filter_settings.SetString( |
| 878 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id); | 878 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id); |
| 879 | 879 |
| 880 web_ui()->CallJavascriptFunction( | 880 web_ui()->CallJavascriptFunctionUnsafe( |
| 881 "ContentSettings.setContentFilterSettingsValue", filter_settings); | 881 "ContentSettings.setContentFilterSettingsValue", filter_settings); |
| 882 } | 882 } |
| 883 | 883 |
| 884 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs( | 884 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs( |
| 885 ContentSettingsType type) { | 885 ContentSettingsType type) { |
| 886 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 886 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 887 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); | 887 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); |
| 888 std::string policy_pref = (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) | 888 std::string policy_pref = (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) |
| 889 ? prefs::kAudioCaptureAllowed | 889 ? prefs::kAudioCaptureAllowed |
| 890 : prefs::kVideoCaptureAllowed; | 890 : prefs::kVideoCaptureAllowed; |
| 891 | 891 |
| 892 settings.policy_disable = !prefs->GetBoolean(policy_pref) && | 892 settings.policy_disable = !prefs->GetBoolean(policy_pref) && |
| 893 prefs->IsManagedPreference(policy_pref); | 893 prefs->IsManagedPreference(policy_pref); |
| 894 settings.default_setting = | 894 settings.default_setting = |
| 895 GetContentSettingsMap()->GetDefaultContentSetting(type, NULL); | 895 GetContentSettingsMap()->GetDefaultContentSetting(type, NULL); |
| 896 settings.default_setting_initialized = true; | 896 settings.default_setting_initialized = true; |
| 897 | 897 |
| 898 UpdateFlashMediaLinksVisibility(type); | 898 UpdateFlashMediaLinksVisibility(type); |
| 899 UpdateMediaDeviceDropdownVisibility(type); | 899 UpdateMediaDeviceDropdownVisibility(type); |
| 900 } | 900 } |
| 901 | 901 |
| 902 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { | 902 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { |
| 903 base::FundamentalValue handlers_enabled( | 903 base::FundamentalValue handlers_enabled( |
| 904 GetProtocolHandlerRegistry()->enabled()); | 904 GetProtocolHandlerRegistry()->enabled()); |
| 905 | 905 |
| 906 web_ui()->CallJavascriptFunction( | 906 web_ui()->CallJavascriptFunctionUnsafe( |
| 907 "ContentSettings.updateHandlersEnabledRadios", | 907 "ContentSettings.updateHandlersEnabledRadios", handlers_enabled); |
| 908 handlers_enabled); | |
| 909 } | 908 } |
| 910 | 909 |
| 911 void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() { | 910 void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() { |
| 912 const ExceptionsInfoMap& exceptions_info_map = GetExceptionsInfoMap(); | 911 const ExceptionsInfoMap& exceptions_info_map = GetExceptionsInfoMap(); |
| 913 for (const auto& exceptions_info_pair : exceptions_info_map) | 912 for (const auto& exceptions_info_pair : exceptions_info_map) |
| 914 UpdateExceptionsViewFromModel(exceptions_info_pair.first); | 913 UpdateExceptionsViewFromModel(exceptions_info_pair.first); |
| 915 | 914 |
| 916 // Zoom levels are not actually a content type so we need to handle them | 915 // Zoom levels are not actually a content type so we need to handle them |
| 917 // separately. | 916 // separately. |
| 918 UpdateZoomLevelsExceptionsView(); | 917 UpdateZoomLevelsExceptionsView(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 if (j == parent) | 1001 if (j == parent) |
| 1003 continue; | 1002 continue; |
| 1004 | 1003 |
| 1005 exceptions.Append(GetGeolocationExceptionForPage( | 1004 exceptions.Append(GetGeolocationExceptionForPage( |
| 1006 primary_pattern, j->first, j->second)); | 1005 primary_pattern, j->first, j->second)); |
| 1007 } | 1006 } |
| 1008 } | 1007 } |
| 1009 | 1008 |
| 1010 base::StringValue type_string( | 1009 base::StringValue type_string( |
| 1011 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_GEOLOCATION)); | 1010 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 1012 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", | 1011 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1013 type_string, exceptions); | 1012 type_string, exceptions); |
| 1014 | 1013 |
| 1015 // This is mainly here to keep this function ideologically parallel to | 1014 // This is mainly here to keep this function ideologically parallel to |
| 1016 // UpdateExceptionsViewFromHostContentSettingsMap(). | 1015 // UpdateExceptionsViewFromHostContentSettingsMap(). |
| 1017 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 1016 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 1018 } | 1017 } |
| 1019 | 1018 |
| 1020 void ContentSettingsHandler::UpdateNotificationExceptionsView() { | 1019 void ContentSettingsHandler::UpdateNotificationExceptionsView() { |
| 1021 Profile* profile = Profile::FromWebUI(web_ui()); | 1020 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1022 ContentSettingsForOneType settings; | 1021 ContentSettingsForOneType settings; |
| 1023 DesktopNotificationProfileUtil::GetNotificationsSettings(profile, &settings); | 1022 DesktopNotificationProfileUtil::GetNotificationsSettings(profile, &settings); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1042 | 1041 |
| 1043 exceptions.Append( | 1042 exceptions.Append( |
| 1044 GetNotificationExceptionForPage(i->primary_pattern, | 1043 GetNotificationExceptionForPage(i->primary_pattern, |
| 1045 i->secondary_pattern, | 1044 i->secondary_pattern, |
| 1046 i->setting, | 1045 i->setting, |
| 1047 i->source)); | 1046 i->source)); |
| 1048 } | 1047 } |
| 1049 | 1048 |
| 1050 base::StringValue type_string( | 1049 base::StringValue type_string( |
| 1051 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); | 1050 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); |
| 1052 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", | 1051 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1053 type_string, exceptions); | 1052 type_string, exceptions); |
| 1054 | 1053 |
| 1055 // This is mainly here to keep this function ideologically parallel to | 1054 // This is mainly here to keep this function ideologically parallel to |
| 1056 // UpdateExceptionsViewFromHostContentSettingsMap(). | 1055 // UpdateExceptionsViewFromHostContentSettingsMap(). |
| 1057 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 1056 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 1058 } | 1057 } |
| 1059 | 1058 |
| 1060 void ContentSettingsHandler::CompareMediaExceptionsWithFlash( | 1059 void ContentSettingsHandler::CompareMediaExceptionsWithFlash( |
| 1061 ContentSettingsType type) { | 1060 ContentSettingsType type) { |
| 1062 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); | 1061 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); |
| 1063 | 1062 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 void ContentSettingsHandler::UpdateAllOTRChooserExceptionsViewsFromModel() { | 1110 void ContentSettingsHandler::UpdateAllOTRChooserExceptionsViewsFromModel() { |
| 1112 for (const ChooserTypeNameEntry& chooser_type : kChooserTypeGroupNames) | 1111 for (const ChooserTypeNameEntry& chooser_type : kChooserTypeGroupNames) |
| 1113 UpdateOTRChooserExceptionsViewFromModel(chooser_type); | 1112 UpdateOTRChooserExceptionsViewFromModel(chooser_type); |
| 1114 } | 1113 } |
| 1115 | 1114 |
| 1116 void ContentSettingsHandler::UpdateChooserExceptionsViewFromModel( | 1115 void ContentSettingsHandler::UpdateChooserExceptionsViewFromModel( |
| 1117 const ChooserTypeNameEntry& chooser_type) { | 1116 const ChooserTypeNameEntry& chooser_type) { |
| 1118 base::ListValue exceptions; | 1117 base::ListValue exceptions; |
| 1119 GetChooserExceptionsFromProfile(false, chooser_type, &exceptions); | 1118 GetChooserExceptionsFromProfile(false, chooser_type, &exceptions); |
| 1120 base::StringValue type_string(chooser_type.name); | 1119 base::StringValue type_string(chooser_type.name); |
| 1121 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, | 1120 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1122 exceptions); | 1121 type_string, exceptions); |
| 1123 | 1122 |
| 1124 UpdateOTRChooserExceptionsViewFromModel(chooser_type); | 1123 UpdateOTRChooserExceptionsViewFromModel(chooser_type); |
| 1125 } | 1124 } |
| 1126 | 1125 |
| 1127 void ContentSettingsHandler::UpdateOTRChooserExceptionsViewFromModel( | 1126 void ContentSettingsHandler::UpdateOTRChooserExceptionsViewFromModel( |
| 1128 const ChooserTypeNameEntry& chooser_type) { | 1127 const ChooserTypeNameEntry& chooser_type) { |
| 1129 if (!Profile::FromWebUI(web_ui())->HasOffTheRecordProfile()) | 1128 if (!Profile::FromWebUI(web_ui())->HasOffTheRecordProfile()) |
| 1130 return; | 1129 return; |
| 1131 | 1130 |
| 1132 base::ListValue exceptions; | 1131 base::ListValue exceptions; |
| 1133 GetChooserExceptionsFromProfile(true, chooser_type, &exceptions); | 1132 GetChooserExceptionsFromProfile(true, chooser_type, &exceptions); |
| 1134 base::StringValue type_string(chooser_type.name); | 1133 base::StringValue type_string(chooser_type.name); |
| 1135 web_ui()->CallJavascriptFunction("ContentSettings.setOTRExceptions", | 1134 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", |
| 1136 type_string, exceptions); | 1135 type_string, exceptions); |
| 1137 } | 1136 } |
| 1138 | 1137 |
| 1139 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { | 1138 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { |
| 1140 base::ListValue zoom_levels_exceptions; | 1139 base::ListValue zoom_levels_exceptions; |
| 1141 | 1140 |
| 1142 content::HostZoomMap* host_zoom_map = | 1141 content::HostZoomMap* host_zoom_map = |
| 1143 content::HostZoomMap::GetDefaultForBrowserContext( | 1142 content::HostZoomMap::GetDefaultForBrowserContext( |
| 1144 GetBrowserContext(web_ui())); | 1143 GetBrowserContext(web_ui())); |
| 1145 content::HostZoomMap::ZoomLevelVector zoom_levels( | 1144 content::HostZoomMap::ZoomLevelVector zoom_levels( |
| 1146 host_zoom_map->GetAllZoomLevels()); | 1145 host_zoom_map->GetAllZoomLevels()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 kZoom, | 1192 kZoom, |
| 1194 l10n_util::GetStringFUTF16(IDS_ZOOM_PERCENT, | 1193 l10n_util::GetStringFUTF16(IDS_ZOOM_PERCENT, |
| 1195 base::IntToString16(zoom_percent))); | 1194 base::IntToString16(zoom_percent))); |
| 1196 exception->SetString( | 1195 exception->SetString( |
| 1197 site_settings::kSource, site_settings::kPreferencesSource); | 1196 site_settings::kSource, site_settings::kPreferencesSource); |
| 1198 // Append the new entry to the list and map. | 1197 // Append the new entry to the list and map. |
| 1199 zoom_levels_exceptions.Append(exception.release()); | 1198 zoom_levels_exceptions.Append(exception.release()); |
| 1200 } | 1199 } |
| 1201 | 1200 |
| 1202 base::StringValue type_string(kZoomContentType); | 1201 base::StringValue type_string(kZoomContentType); |
| 1203 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", | 1202 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1204 type_string, zoom_levels_exceptions); | 1203 type_string, zoom_levels_exceptions); |
| 1205 } | 1204 } |
| 1206 | 1205 |
| 1207 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( | 1206 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( |
| 1208 ContentSettingsType type) { | 1207 ContentSettingsType type) { |
| 1209 base::ListValue exceptions; | 1208 base::ListValue exceptions; |
| 1210 site_settings::GetExceptionsFromHostContentSettingsMap( | 1209 site_settings::GetExceptionsFromHostContentSettingsMap( |
| 1211 GetContentSettingsMap(), type, web_ui(), &exceptions); | 1210 GetContentSettingsMap(), type, web_ui(), &exceptions); |
| 1212 base::StringValue type_string(ContentSettingsTypeToGroupName(type)); | 1211 base::StringValue type_string(ContentSettingsTypeToGroupName(type)); |
| 1213 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, | 1212 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1214 exceptions); | 1213 type_string, exceptions); |
| 1215 | 1214 |
| 1216 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); | 1215 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); |
| 1217 | 1216 |
| 1218 // TODO(koz): The default for fullscreen is always 'ask'. | 1217 // TODO(koz): The default for fullscreen is always 'ask'. |
| 1219 // http://crbug.com/104683 | 1218 // http://crbug.com/104683 |
| 1220 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN) | 1219 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN) |
| 1221 return; | 1220 return; |
| 1222 | 1221 |
| 1223 #if defined(OS_CHROMEOS) | 1222 #if defined(OS_CHROMEOS) |
| 1224 // Also the default for protected contents is managed in another place. | 1223 // Also the default for protected contents is managed in another place. |
| 1225 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) | 1224 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) |
| 1226 return; | 1225 return; |
| 1227 #endif | 1226 #endif |
| 1228 | 1227 |
| 1229 // The default may also have changed (we won't get a separate notification). | 1228 // The default may also have changed (we won't get a separate notification). |
| 1230 // If it hasn't changed, this call will be harmless. | 1229 // If it hasn't changed, this call will be harmless. |
| 1231 UpdateSettingDefaultFromModel(type); | 1230 UpdateSettingDefaultFromModel(type); |
| 1232 } | 1231 } |
| 1233 | 1232 |
| 1234 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap( | 1233 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap( |
| 1235 ContentSettingsType type) { | 1234 ContentSettingsType type) { |
| 1236 const HostContentSettingsMap* otr_settings_map = GetOTRContentSettingsMap(); | 1235 const HostContentSettingsMap* otr_settings_map = GetOTRContentSettingsMap(); |
| 1237 if (!otr_settings_map) | 1236 if (!otr_settings_map) |
| 1238 return; | 1237 return; |
| 1239 base::ListValue exceptions; | 1238 base::ListValue exceptions; |
| 1240 site_settings::GetExceptionsFromHostContentSettingsMap( | 1239 site_settings::GetExceptionsFromHostContentSettingsMap( |
| 1241 otr_settings_map, type, web_ui(), &exceptions); | 1240 otr_settings_map, type, web_ui(), &exceptions); |
| 1242 base::StringValue type_string(ContentSettingsTypeToGroupName(type)); | 1241 base::StringValue type_string(ContentSettingsTypeToGroupName(type)); |
| 1243 web_ui()->CallJavascriptFunction("ContentSettings.setOTRExceptions", | 1242 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", |
| 1244 type_string, exceptions); | 1243 type_string, exceptions); |
| 1245 } | 1244 } |
| 1246 | 1245 |
| 1247 void ContentSettingsHandler::GetChooserExceptionsFromProfile( | 1246 void ContentSettingsHandler::GetChooserExceptionsFromProfile( |
| 1248 bool incognito, | 1247 bool incognito, |
| 1249 const ChooserTypeNameEntry& chooser_type, | 1248 const ChooserTypeNameEntry& chooser_type, |
| 1250 base::ListValue* exceptions) { | 1249 base::ListValue* exceptions) { |
| 1251 Profile* profile = Profile::FromWebUI(web_ui()); | 1250 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1252 if (incognito) { | 1251 if (incognito) { |
| 1253 if (profile->HasOffTheRecordProfile()) | 1252 if (profile->HasOffTheRecordProfile()) |
| 1254 profile = profile->GetOffTheRecordProfile(); | 1253 profile = profile->GetOffTheRecordProfile(); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 std::string type_string; | 1540 std::string type_string; |
| 1542 CHECK(args->GetString(0, &type_string)); | 1541 CHECK(args->GetString(0, &type_string)); |
| 1543 std::string mode_string; | 1542 std::string mode_string; |
| 1544 CHECK(args->GetString(1, &mode_string)); | 1543 CHECK(args->GetString(1, &mode_string)); |
| 1545 std::string pattern_string; | 1544 std::string pattern_string; |
| 1546 CHECK(args->GetString(2, &pattern_string)); | 1545 CHECK(args->GetString(2, &pattern_string)); |
| 1547 | 1546 |
| 1548 ContentSettingsPattern pattern = | 1547 ContentSettingsPattern pattern = |
| 1549 ContentSettingsPattern::FromString(pattern_string); | 1548 ContentSettingsPattern::FromString(pattern_string); |
| 1550 | 1549 |
| 1551 web_ui()->CallJavascriptFunction( | 1550 web_ui()->CallJavascriptFunctionUnsafe( |
| 1552 "ContentSettings.patternValidityCheckComplete", | 1551 "ContentSettings.patternValidityCheckComplete", |
| 1553 base::StringValue(type_string), | 1552 base::StringValue(type_string), base::StringValue(mode_string), |
| 1554 base::StringValue(mode_string), | |
| 1555 base::StringValue(pattern_string), | 1553 base::StringValue(pattern_string), |
| 1556 base::FundamentalValue(pattern.IsValid())); | 1554 base::FundamentalValue(pattern.IsValid())); |
| 1557 } | 1555 } |
| 1558 | 1556 |
| 1559 // static | 1557 // static |
| 1560 std::string ContentSettingsHandler::ContentSettingsTypeToGroupName( | 1558 std::string ContentSettingsHandler::ContentSettingsTypeToGroupName( |
| 1561 ContentSettingsType type) { | 1559 ContentSettingsType type) { |
| 1562 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { | 1560 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { |
| 1563 if (type == kContentSettingsTypeGroupNames[i].type) | 1561 if (type == kContentSettingsTypeGroupNames[i].type) |
| 1564 return kContentSettingsTypeGroupNames[i].name; | 1562 return kContentSettingsTypeGroupNames[i].name; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1621 void ContentSettingsHandler::ShowFlashMediaLink( | 1619 void ContentSettingsHandler::ShowFlashMediaLink( |
| 1622 LinkType link_type, ContentSettingsType content_type, bool show) { | 1620 LinkType link_type, ContentSettingsType content_type, bool show) { |
| 1623 MediaSettingsInfo::ForOneType& settings = | 1621 MediaSettingsInfo::ForOneType& settings = |
| 1624 media_settings_->forType(content_type); | 1622 media_settings_->forType(content_type); |
| 1625 | 1623 |
| 1626 bool& show_link = link_type == DEFAULT_SETTING ? | 1624 bool& show_link = link_type == DEFAULT_SETTING ? |
| 1627 settings.show_flash_default_link : | 1625 settings.show_flash_default_link : |
| 1628 settings.show_flash_exceptions_link; | 1626 settings.show_flash_exceptions_link; |
| 1629 | 1627 |
| 1630 if (show_link != show) { | 1628 if (show_link != show) { |
| 1631 web_ui()->CallJavascriptFunction( | 1629 web_ui()->CallJavascriptFunctionUnsafe( |
| 1632 "ContentSettings.showMediaPepperFlashLink", | 1630 "ContentSettings.showMediaPepperFlashLink", |
| 1633 base::StringValue( | 1631 base::StringValue(link_type == DEFAULT_SETTING ? "default" |
| 1634 link_type == DEFAULT_SETTING ? "default" : "exceptions"), | 1632 : "exceptions"), |
| 1635 base::StringValue( | 1633 base::StringValue(content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC |
| 1636 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC | 1634 ? "mic" |
| 1637 ? "mic" | 1635 : "camera"), |
| 1638 : "camera"), | |
| 1639 base::FundamentalValue(show)); | 1636 base::FundamentalValue(show)); |
| 1640 show_link = show; | 1637 show_link = show; |
| 1641 } | 1638 } |
| 1642 } | 1639 } |
| 1643 | 1640 |
| 1644 void ContentSettingsHandler::UpdateFlashMediaLinksVisibility( | 1641 void ContentSettingsHandler::UpdateFlashMediaLinksVisibility( |
| 1645 ContentSettingsType type) { | 1642 ContentSettingsType type) { |
| 1646 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); | 1643 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); |
| 1647 MediaSettingsInfo::ForFlash& flash_settings = media_settings_->forFlash(); | 1644 MediaSettingsInfo::ForFlash& flash_settings = media_settings_->forFlash(); |
| 1648 | 1645 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1684 flash_settings.default_setting, | 1681 flash_settings.default_setting, |
| 1685 flash_settings.exceptions)) { | 1682 flash_settings.exceptions)) { |
| 1686 ShowFlashMediaLink(EXCEPTIONS, type, true); | 1683 ShowFlashMediaLink(EXCEPTIONS, type, true); |
| 1687 } | 1684 } |
| 1688 } | 1685 } |
| 1689 | 1686 |
| 1690 void ContentSettingsHandler::UpdateMediaDeviceDropdownVisibility( | 1687 void ContentSettingsHandler::UpdateMediaDeviceDropdownVisibility( |
| 1691 ContentSettingsType type) { | 1688 ContentSettingsType type) { |
| 1692 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); | 1689 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); |
| 1693 | 1690 |
| 1694 web_ui()->CallJavascriptFunction( | 1691 web_ui()->CallJavascriptFunctionUnsafe( |
| 1695 "ContentSettings.setDevicesMenuVisibility", | 1692 "ContentSettings.setDevicesMenuVisibility", |
| 1696 base::StringValue(ContentSettingsTypeToGroupName(type)), | 1693 base::StringValue(ContentSettingsTypeToGroupName(type)), |
| 1697 base::FundamentalValue(!settings.policy_disable)); | 1694 base::FundamentalValue(!settings.policy_disable)); |
| 1698 } | 1695 } |
| 1699 | 1696 |
| 1700 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { | 1697 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { |
| 1701 #if defined(OS_CHROMEOS) | 1698 #if defined(OS_CHROMEOS) |
| 1702 // Guests cannot modify exceptions. UIAccountTweaks will disabled the button. | 1699 // Guests cannot modify exceptions. UIAccountTweaks will disabled the button. |
| 1703 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) | 1700 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) |
| 1704 return; | 1701 return; |
| 1705 #endif | 1702 #endif |
| 1706 | 1703 |
| 1707 // Exceptions apply only when the feature is enabled. | 1704 // Exceptions apply only when the feature is enabled. |
| 1708 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1705 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1709 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1706 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1710 web_ui()->CallJavascriptFunction( | 1707 web_ui()->CallJavascriptFunctionUnsafe( |
| 1711 "ContentSettings.enableProtectedContentExceptions", | 1708 "ContentSettings.enableProtectedContentExceptions", |
| 1712 base::FundamentalValue(enable_exceptions)); | 1709 base::FundamentalValue(enable_exceptions)); |
| 1713 } | 1710 } |
| 1714 | 1711 |
| 1715 } // namespace options | 1712 } // namespace options |
| OLD | NEW |