| 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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 UpdateAllExceptionsViewsFromModel(); | 714 UpdateAllExceptionsViewsFromModel(); |
| 715 UpdateAllChooserExceptionsViewsFromModel(); | 715 UpdateAllChooserExceptionsViewsFromModel(); |
| 716 UpdateProtectedContentExceptionsButton(); | 716 UpdateProtectedContentExceptionsButton(); |
| 717 | 717 |
| 718 // Fullscreen and mouselock settings are ignored, but still stored. Always | 718 // Fullscreen and mouselock settings are ignored, but still stored. Always |
| 719 // show the per-site settings (to give users the ability to view and delete | 719 // show the per-site settings (to give users the ability to view and delete |
| 720 // exceptions), but hide the global settings. | 720 // exceptions), but hide the global settings. |
| 721 // TODO(mgiuca): Remove this function and the global setting UI | 721 // TODO(mgiuca): Remove this function and the global setting UI |
| 722 // (https://crbug.com/610900). Then, delete all the per-site data and remove | 722 // (https://crbug.com/610900). Then, delete all the per-site data and remove |
| 723 // this content setting entirely (https://crbug.com/591896). | 723 // this content setting entirely (https://crbug.com/591896). |
| 724 web_ui()->CallJavascriptFunction("ContentSettings.setExclusiveAccessVisible", | 724 web_ui()->CallJavascriptFunctionUnsafe( |
| 725 base::FundamentalValue(true), | 725 "ContentSettings.setExclusiveAccessVisible", base::FundamentalValue(true), |
| 726 base::FundamentalValue(false)); | 726 base::FundamentalValue(false)); |
| 727 } | 727 } |
| 728 | 728 |
| 729 void ContentSettingsHandler::OnContentSettingChanged( | 729 void ContentSettingsHandler::OnContentSettingChanged( |
| 730 const ContentSettingsPattern& primary_pattern, | 730 const ContentSettingsPattern& primary_pattern, |
| 731 const ContentSettingsPattern& secondary_pattern, | 731 const ContentSettingsPattern& secondary_pattern, |
| 732 ContentSettingsType content_type, | 732 ContentSettingsType content_type, |
| 733 std::string resource_identifier) { | 733 std::string resource_identifier) { |
| 734 const ContentSettingsDetails details( | 734 const ContentSettingsDetails details( |
| 735 primary_pattern, secondary_pattern, content_type, resource_identifier); | 735 primary_pattern, secondary_pattern, content_type, resource_identifier); |
| 736 // TODO(estade): we pretend update_all() is always true. | 736 // TODO(estade): we pretend update_all() is always true. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 747 int type, | 747 int type, |
| 748 const content::NotificationSource& source, | 748 const content::NotificationSource& source, |
| 749 const content::NotificationDetails& details) { | 749 const content::NotificationDetails& details) { |
| 750 switch (type) { | 750 switch (type) { |
| 751 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 751 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| 752 Profile* profile = content::Source<Profile>(source).ptr(); | 752 Profile* profile = content::Source<Profile>(source).ptr(); |
| 753 HostContentSettingsMap* settings_map = | 753 HostContentSettingsMap* settings_map = |
| 754 HostContentSettingsMapFactory::GetForProfile(profile); | 754 HostContentSettingsMapFactory::GetForProfile(profile); |
| 755 if (profile->IsOffTheRecord() && | 755 if (profile->IsOffTheRecord() && |
| 756 observer_.IsObserving(settings_map)) { | 756 observer_.IsObserving(settings_map)) { |
| 757 web_ui()->CallJavascriptFunction( | 757 web_ui()->CallJavascriptFunctionUnsafe( |
| 758 "ContentSettingsExceptionsArea.OTRProfileDestroyed"); | 758 "ContentSettingsExceptionsArea.OTRProfileDestroyed"); |
| 759 observer_.Remove(settings_map); | 759 observer_.Remove(settings_map); |
| 760 } | 760 } |
| 761 break; | 761 break; |
| 762 } | 762 } |
| 763 | 763 |
| 764 case chrome::NOTIFICATION_PROFILE_CREATED: { | 764 case chrome::NOTIFICATION_PROFILE_CREATED: { |
| 765 Profile* profile = content::Source<Profile>(source).ptr(); | 765 Profile* profile = content::Source<Profile>(source).ptr(); |
| 766 if (profile->IsOffTheRecord()) { | 766 if (profile->IsOffTheRecord()) { |
| 767 UpdateAllOTRExceptionsViewsFromModel(); | 767 UpdateAllOTRExceptionsViewsFromModel(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 content_settings::ContentSettingToString(default_setting); | 831 content_settings::ContentSettingToString(default_setting); |
| 832 DCHECK(!setting_string.empty()); | 832 DCHECK(!setting_string.empty()); |
| 833 | 833 |
| 834 filter_settings.SetString( | 834 filter_settings.SetString( |
| 835 site_settings::ContentSettingsTypeToGroupName(type) + ".value", | 835 site_settings::ContentSettingsTypeToGroupName(type) + ".value", |
| 836 setting_string); | 836 setting_string); |
| 837 filter_settings.SetString( | 837 filter_settings.SetString( |
| 838 site_settings::ContentSettingsTypeToGroupName(type) + ".managedBy", | 838 site_settings::ContentSettingsTypeToGroupName(type) + ".managedBy", |
| 839 provider_id); | 839 provider_id); |
| 840 | 840 |
| 841 web_ui()->CallJavascriptFunction( | 841 web_ui()->CallJavascriptFunctionUnsafe( |
| 842 "ContentSettings.setContentFilterSettingsValue", filter_settings); | 842 "ContentSettings.setContentFilterSettingsValue", filter_settings); |
| 843 } | 843 } |
| 844 | 844 |
| 845 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs( | 845 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs( |
| 846 ContentSettingsType type) { | 846 ContentSettingsType type) { |
| 847 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 847 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 848 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); | 848 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); |
| 849 std::string policy_pref = (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) | 849 std::string policy_pref = (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) |
| 850 ? prefs::kAudioCaptureAllowed | 850 ? prefs::kAudioCaptureAllowed |
| 851 : prefs::kVideoCaptureAllowed; | 851 : prefs::kVideoCaptureAllowed; |
| 852 | 852 |
| 853 settings.policy_disable = !prefs->GetBoolean(policy_pref) && | 853 settings.policy_disable = !prefs->GetBoolean(policy_pref) && |
| 854 prefs->IsManagedPreference(policy_pref); | 854 prefs->IsManagedPreference(policy_pref); |
| 855 settings.default_setting = | 855 settings.default_setting = |
| 856 GetContentSettingsMap()->GetDefaultContentSetting(type, NULL); | 856 GetContentSettingsMap()->GetDefaultContentSetting(type, NULL); |
| 857 settings.default_setting_initialized = true; | 857 settings.default_setting_initialized = true; |
| 858 | 858 |
| 859 UpdateFlashMediaLinksVisibility(type); | 859 UpdateFlashMediaLinksVisibility(type); |
| 860 UpdateMediaDeviceDropdownVisibility(type); | 860 UpdateMediaDeviceDropdownVisibility(type); |
| 861 } | 861 } |
| 862 | 862 |
| 863 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { | 863 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { |
| 864 base::FundamentalValue handlers_enabled( | 864 base::FundamentalValue handlers_enabled( |
| 865 GetProtocolHandlerRegistry()->enabled()); | 865 GetProtocolHandlerRegistry()->enabled()); |
| 866 | 866 |
| 867 web_ui()->CallJavascriptFunction( | 867 web_ui()->CallJavascriptFunctionUnsafe( |
| 868 "ContentSettings.updateHandlersEnabledRadios", | 868 "ContentSettings.updateHandlersEnabledRadios", handlers_enabled); |
| 869 handlers_enabled); | |
| 870 } | 869 } |
| 871 | 870 |
| 872 void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() { | 871 void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() { |
| 873 const ExceptionsInfoMap& exceptions_info_map = GetExceptionsInfoMap(); | 872 const ExceptionsInfoMap& exceptions_info_map = GetExceptionsInfoMap(); |
| 874 for (const auto& exceptions_info_pair : exceptions_info_map) | 873 for (const auto& exceptions_info_pair : exceptions_info_map) |
| 875 UpdateExceptionsViewFromModel(exceptions_info_pair.first); | 874 UpdateExceptionsViewFromModel(exceptions_info_pair.first); |
| 876 | 875 |
| 877 // Zoom levels are not actually a content type so we need to handle them | 876 // Zoom levels are not actually a content type so we need to handle them |
| 878 // separately. | 877 // separately. |
| 879 UpdateZoomLevelsExceptionsView(); | 878 UpdateZoomLevelsExceptionsView(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 if (j == parent) | 962 if (j == parent) |
| 964 continue; | 963 continue; |
| 965 | 964 |
| 966 exceptions.Append(GetGeolocationExceptionForPage( | 965 exceptions.Append(GetGeolocationExceptionForPage( |
| 967 primary_pattern, j->first, j->second)); | 966 primary_pattern, j->first, j->second)); |
| 968 } | 967 } |
| 969 } | 968 } |
| 970 | 969 |
| 971 base::StringValue type_string(site_settings::ContentSettingsTypeToGroupName( | 970 base::StringValue type_string(site_settings::ContentSettingsTypeToGroupName( |
| 972 CONTENT_SETTINGS_TYPE_GEOLOCATION)); | 971 CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 973 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", | 972 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 974 type_string, exceptions); | 973 type_string, exceptions); |
| 975 | 974 |
| 976 // This is mainly here to keep this function ideologically parallel to | 975 // This is mainly here to keep this function ideologically parallel to |
| 977 // UpdateExceptionsViewFromHostContentSettingsMap(). | 976 // UpdateExceptionsViewFromHostContentSettingsMap(). |
| 978 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 977 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 979 } | 978 } |
| 980 | 979 |
| 981 void ContentSettingsHandler::UpdateNotificationExceptionsView() { | 980 void ContentSettingsHandler::UpdateNotificationExceptionsView() { |
| 982 Profile* profile = Profile::FromWebUI(web_ui()); | 981 Profile* profile = Profile::FromWebUI(web_ui()); |
| 983 ContentSettingsForOneType settings; | 982 ContentSettingsForOneType settings; |
| 984 DesktopNotificationProfileUtil::GetNotificationsSettings(profile, &settings); | 983 DesktopNotificationProfileUtil::GetNotificationsSettings(profile, &settings); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1003 | 1002 |
| 1004 exceptions.Append( | 1003 exceptions.Append( |
| 1005 GetNotificationExceptionForPage(i->primary_pattern, | 1004 GetNotificationExceptionForPage(i->primary_pattern, |
| 1006 i->secondary_pattern, | 1005 i->secondary_pattern, |
| 1007 i->setting, | 1006 i->setting, |
| 1008 i->source)); | 1007 i->source)); |
| 1009 } | 1008 } |
| 1010 | 1009 |
| 1011 base::StringValue type_string(site_settings::ContentSettingsTypeToGroupName( | 1010 base::StringValue type_string(site_settings::ContentSettingsTypeToGroupName( |
| 1012 CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); | 1011 CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); |
| 1013 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", | 1012 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1014 type_string, exceptions); | 1013 type_string, exceptions); |
| 1015 | 1014 |
| 1016 // This is mainly here to keep this function ideologically parallel to | 1015 // This is mainly here to keep this function ideologically parallel to |
| 1017 // UpdateExceptionsViewFromHostContentSettingsMap(). | 1016 // UpdateExceptionsViewFromHostContentSettingsMap(). |
| 1018 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 1017 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 1019 } | 1018 } |
| 1020 | 1019 |
| 1021 void ContentSettingsHandler::CompareMediaExceptionsWithFlash( | 1020 void ContentSettingsHandler::CompareMediaExceptionsWithFlash( |
| 1022 ContentSettingsType type) { | 1021 ContentSettingsType type) { |
| 1023 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); | 1022 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); |
| 1024 | 1023 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 void ContentSettingsHandler::UpdateAllOTRChooserExceptionsViewsFromModel() { | 1071 void ContentSettingsHandler::UpdateAllOTRChooserExceptionsViewsFromModel() { |
| 1073 for (const ChooserTypeNameEntry& chooser_type : kChooserTypeGroupNames) | 1072 for (const ChooserTypeNameEntry& chooser_type : kChooserTypeGroupNames) |
| 1074 UpdateOTRChooserExceptionsViewFromModel(chooser_type); | 1073 UpdateOTRChooserExceptionsViewFromModel(chooser_type); |
| 1075 } | 1074 } |
| 1076 | 1075 |
| 1077 void ContentSettingsHandler::UpdateChooserExceptionsViewFromModel( | 1076 void ContentSettingsHandler::UpdateChooserExceptionsViewFromModel( |
| 1078 const ChooserTypeNameEntry& chooser_type) { | 1077 const ChooserTypeNameEntry& chooser_type) { |
| 1079 base::ListValue exceptions; | 1078 base::ListValue exceptions; |
| 1080 GetChooserExceptionsFromProfile(false, chooser_type, &exceptions); | 1079 GetChooserExceptionsFromProfile(false, chooser_type, &exceptions); |
| 1081 base::StringValue type_string(chooser_type.name); | 1080 base::StringValue type_string(chooser_type.name); |
| 1082 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, | 1081 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1083 exceptions); | 1082 type_string, exceptions); |
| 1084 | 1083 |
| 1085 UpdateOTRChooserExceptionsViewFromModel(chooser_type); | 1084 UpdateOTRChooserExceptionsViewFromModel(chooser_type); |
| 1086 } | 1085 } |
| 1087 | 1086 |
| 1088 void ContentSettingsHandler::UpdateOTRChooserExceptionsViewFromModel( | 1087 void ContentSettingsHandler::UpdateOTRChooserExceptionsViewFromModel( |
| 1089 const ChooserTypeNameEntry& chooser_type) { | 1088 const ChooserTypeNameEntry& chooser_type) { |
| 1090 if (!Profile::FromWebUI(web_ui())->HasOffTheRecordProfile()) | 1089 if (!Profile::FromWebUI(web_ui())->HasOffTheRecordProfile()) |
| 1091 return; | 1090 return; |
| 1092 | 1091 |
| 1093 base::ListValue exceptions; | 1092 base::ListValue exceptions; |
| 1094 GetChooserExceptionsFromProfile(true, chooser_type, &exceptions); | 1093 GetChooserExceptionsFromProfile(true, chooser_type, &exceptions); |
| 1095 base::StringValue type_string(chooser_type.name); | 1094 base::StringValue type_string(chooser_type.name); |
| 1096 web_ui()->CallJavascriptFunction("ContentSettings.setOTRExceptions", | 1095 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", |
| 1097 type_string, exceptions); | 1096 type_string, exceptions); |
| 1098 } | 1097 } |
| 1099 | 1098 |
| 1100 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { | 1099 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { |
| 1101 base::ListValue zoom_levels_exceptions; | 1100 base::ListValue zoom_levels_exceptions; |
| 1102 | 1101 |
| 1103 content::HostZoomMap* host_zoom_map = | 1102 content::HostZoomMap* host_zoom_map = |
| 1104 content::HostZoomMap::GetDefaultForBrowserContext( | 1103 content::HostZoomMap::GetDefaultForBrowserContext( |
| 1105 GetBrowserContext(web_ui())); | 1104 GetBrowserContext(web_ui())); |
| 1106 content::HostZoomMap::ZoomLevelVector zoom_levels( | 1105 content::HostZoomMap::ZoomLevelVector zoom_levels( |
| 1107 host_zoom_map->GetAllZoomLevels()); | 1106 host_zoom_map->GetAllZoomLevels()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 int zoom_percent = static_cast<int>( | 1150 int zoom_percent = static_cast<int>( |
| 1152 content::ZoomLevelToZoomFactor(i->zoom_level) * 100 + 0.5); | 1151 content::ZoomLevelToZoomFactor(i->zoom_level) * 100 + 0.5); |
| 1153 exception->SetString(kZoom, base::FormatPercent(zoom_percent)); | 1152 exception->SetString(kZoom, base::FormatPercent(zoom_percent)); |
| 1154 exception->SetString( | 1153 exception->SetString( |
| 1155 site_settings::kSource, site_settings::kPreferencesSource); | 1154 site_settings::kSource, site_settings::kPreferencesSource); |
| 1156 // Append the new entry to the list and map. | 1155 // Append the new entry to the list and map. |
| 1157 zoom_levels_exceptions.Append(exception.release()); | 1156 zoom_levels_exceptions.Append(exception.release()); |
| 1158 } | 1157 } |
| 1159 | 1158 |
| 1160 base::StringValue type_string(kZoomContentType); | 1159 base::StringValue type_string(kZoomContentType); |
| 1161 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", | 1160 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1162 type_string, zoom_levels_exceptions); | 1161 type_string, zoom_levels_exceptions); |
| 1163 } | 1162 } |
| 1164 | 1163 |
| 1165 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( | 1164 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( |
| 1166 ContentSettingsType type) { | 1165 ContentSettingsType type) { |
| 1167 base::ListValue exceptions; | 1166 base::ListValue exceptions; |
| 1168 site_settings::GetExceptionsFromHostContentSettingsMap( | 1167 site_settings::GetExceptionsFromHostContentSettingsMap( |
| 1169 GetContentSettingsMap(), type, web_ui(), &exceptions); | 1168 GetContentSettingsMap(), type, web_ui(), &exceptions); |
| 1170 base::StringValue type_string( | 1169 base::StringValue type_string( |
| 1171 site_settings::ContentSettingsTypeToGroupName(type)); | 1170 site_settings::ContentSettingsTypeToGroupName(type)); |
| 1172 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, | 1171 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1173 exceptions); | 1172 |
| 1173 type_string, exceptions); |
| 1174 | 1174 |
| 1175 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); | 1175 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); |
| 1176 | 1176 |
| 1177 // TODO(koz): The default for fullscreen is always 'ask'. | 1177 // TODO(koz): The default for fullscreen is always 'ask'. |
| 1178 // http://crbug.com/104683 | 1178 // http://crbug.com/104683 |
| 1179 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN) | 1179 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN) |
| 1180 return; | 1180 return; |
| 1181 | 1181 |
| 1182 #if defined(OS_CHROMEOS) | 1182 #if defined(OS_CHROMEOS) |
| 1183 // Also the default for protected contents is managed in another place. | 1183 // Also the default for protected contents is managed in another place. |
| 1184 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) | 1184 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) |
| 1185 return; | 1185 return; |
| 1186 #endif | 1186 #endif |
| 1187 | 1187 |
| 1188 // The default may also have changed (we won't get a separate notification). | 1188 // The default may also have changed (we won't get a separate notification). |
| 1189 // If it hasn't changed, this call will be harmless. | 1189 // If it hasn't changed, this call will be harmless. |
| 1190 UpdateSettingDefaultFromModel(type); | 1190 UpdateSettingDefaultFromModel(type); |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap( | 1193 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap( |
| 1194 ContentSettingsType type) { | 1194 ContentSettingsType type) { |
| 1195 const HostContentSettingsMap* otr_settings_map = GetOTRContentSettingsMap(); | 1195 const HostContentSettingsMap* otr_settings_map = GetOTRContentSettingsMap(); |
| 1196 if (!otr_settings_map) | 1196 if (!otr_settings_map) |
| 1197 return; | 1197 return; |
| 1198 base::ListValue exceptions; | 1198 base::ListValue exceptions; |
| 1199 site_settings::GetExceptionsFromHostContentSettingsMap( | 1199 site_settings::GetExceptionsFromHostContentSettingsMap( |
| 1200 otr_settings_map, type, web_ui(), &exceptions); | 1200 otr_settings_map, type, web_ui(), &exceptions); |
| 1201 base::StringValue type_string( | 1201 base::StringValue type_string( |
| 1202 site_settings::ContentSettingsTypeToGroupName(type)); | 1202 site_settings::ContentSettingsTypeToGroupName(type)); |
| 1203 web_ui()->CallJavascriptFunction("ContentSettings.setOTRExceptions", | 1203 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", |
| 1204 type_string, exceptions); | 1204 type_string, exceptions); |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 void ContentSettingsHandler::GetChooserExceptionsFromProfile( | 1207 void ContentSettingsHandler::GetChooserExceptionsFromProfile( |
| 1208 bool incognito, | 1208 bool incognito, |
| 1209 const ChooserTypeNameEntry& chooser_type, | 1209 const ChooserTypeNameEntry& chooser_type, |
| 1210 base::ListValue* exceptions) { | 1210 base::ListValue* exceptions) { |
| 1211 Profile* profile = Profile::FromWebUI(web_ui()); | 1211 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1212 if (incognito) { | 1212 if (incognito) { |
| 1213 if (profile->HasOffTheRecordProfile()) | 1213 if (profile->HasOffTheRecordProfile()) |
| 1214 profile = profile->GetOffTheRecordProfile(); | 1214 profile = profile->GetOffTheRecordProfile(); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 std::string type_string; | 1504 std::string type_string; |
| 1505 CHECK(args->GetString(0, &type_string)); | 1505 CHECK(args->GetString(0, &type_string)); |
| 1506 std::string mode_string; | 1506 std::string mode_string; |
| 1507 CHECK(args->GetString(1, &mode_string)); | 1507 CHECK(args->GetString(1, &mode_string)); |
| 1508 std::string pattern_string; | 1508 std::string pattern_string; |
| 1509 CHECK(args->GetString(2, &pattern_string)); | 1509 CHECK(args->GetString(2, &pattern_string)); |
| 1510 | 1510 |
| 1511 ContentSettingsPattern pattern = | 1511 ContentSettingsPattern pattern = |
| 1512 ContentSettingsPattern::FromString(pattern_string); | 1512 ContentSettingsPattern::FromString(pattern_string); |
| 1513 | 1513 |
| 1514 web_ui()->CallJavascriptFunction( | 1514 web_ui()->CallJavascriptFunctionUnsafe( |
| 1515 "ContentSettings.patternValidityCheckComplete", | 1515 "ContentSettings.patternValidityCheckComplete", |
| 1516 base::StringValue(type_string), | 1516 base::StringValue(type_string), base::StringValue(mode_string), |
| 1517 base::StringValue(mode_string), | |
| 1518 base::StringValue(pattern_string), | 1517 base::StringValue(pattern_string), |
| 1519 base::FundamentalValue(pattern.IsValid())); | 1518 base::FundamentalValue(pattern.IsValid())); |
| 1520 } | 1519 } |
| 1521 | 1520 |
| 1522 HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() { | 1521 HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() { |
| 1523 return HostContentSettingsMapFactory::GetForProfile( | 1522 return HostContentSettingsMapFactory::GetForProfile( |
| 1524 Profile::FromWebUI(web_ui())); | 1523 Profile::FromWebUI(web_ui())); |
| 1525 } | 1524 } |
| 1526 | 1525 |
| 1527 ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() { | 1526 ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 void ContentSettingsHandler::ShowFlashMediaLink( | 1571 void ContentSettingsHandler::ShowFlashMediaLink( |
| 1573 LinkType link_type, ContentSettingsType content_type, bool show) { | 1572 LinkType link_type, ContentSettingsType content_type, bool show) { |
| 1574 MediaSettingsInfo::ForOneType& settings = | 1573 MediaSettingsInfo::ForOneType& settings = |
| 1575 media_settings_->forType(content_type); | 1574 media_settings_->forType(content_type); |
| 1576 | 1575 |
| 1577 bool& show_link = link_type == DEFAULT_SETTING ? | 1576 bool& show_link = link_type == DEFAULT_SETTING ? |
| 1578 settings.show_flash_default_link : | 1577 settings.show_flash_default_link : |
| 1579 settings.show_flash_exceptions_link; | 1578 settings.show_flash_exceptions_link; |
| 1580 | 1579 |
| 1581 if (show_link != show) { | 1580 if (show_link != show) { |
| 1582 web_ui()->CallJavascriptFunction( | 1581 web_ui()->CallJavascriptFunctionUnsafe( |
| 1583 "ContentSettings.showMediaPepperFlashLink", | 1582 "ContentSettings.showMediaPepperFlashLink", |
| 1584 base::StringValue( | 1583 base::StringValue(link_type == DEFAULT_SETTING ? "default" |
| 1585 link_type == DEFAULT_SETTING ? "default" : "exceptions"), | 1584 : "exceptions"), |
| 1586 base::StringValue( | 1585 base::StringValue(content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC |
| 1587 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC | 1586 ? "mic" |
| 1588 ? "mic" | 1587 : "camera"), |
| 1589 : "camera"), | |
| 1590 base::FundamentalValue(show)); | 1588 base::FundamentalValue(show)); |
| 1591 show_link = show; | 1589 show_link = show; |
| 1592 } | 1590 } |
| 1593 } | 1591 } |
| 1594 | 1592 |
| 1595 void ContentSettingsHandler::UpdateFlashMediaLinksVisibility( | 1593 void ContentSettingsHandler::UpdateFlashMediaLinksVisibility( |
| 1596 ContentSettingsType type) { | 1594 ContentSettingsType type) { |
| 1597 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); | 1595 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); |
| 1598 MediaSettingsInfo::ForFlash& flash_settings = media_settings_->forFlash(); | 1596 MediaSettingsInfo::ForFlash& flash_settings = media_settings_->forFlash(); |
| 1599 | 1597 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 flash_settings.default_setting, | 1633 flash_settings.default_setting, |
| 1636 flash_settings.exceptions)) { | 1634 flash_settings.exceptions)) { |
| 1637 ShowFlashMediaLink(EXCEPTIONS, type, true); | 1635 ShowFlashMediaLink(EXCEPTIONS, type, true); |
| 1638 } | 1636 } |
| 1639 } | 1637 } |
| 1640 | 1638 |
| 1641 void ContentSettingsHandler::UpdateMediaDeviceDropdownVisibility( | 1639 void ContentSettingsHandler::UpdateMediaDeviceDropdownVisibility( |
| 1642 ContentSettingsType type) { | 1640 ContentSettingsType type) { |
| 1643 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); | 1641 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); |
| 1644 | 1642 |
| 1645 web_ui()->CallJavascriptFunction( | 1643 web_ui()->CallJavascriptFunctionUnsafe( |
| 1646 "ContentSettings.setDevicesMenuVisibility", | 1644 "ContentSettings.setDevicesMenuVisibility", |
| 1647 base::StringValue(site_settings::ContentSettingsTypeToGroupName(type)), | 1645 base::StringValue(site_settings::ContentSettingsTypeToGroupName(type)), |
| 1648 base::FundamentalValue(!settings.policy_disable)); | 1646 base::FundamentalValue(!settings.policy_disable)); |
| 1649 } | 1647 } |
| 1650 | 1648 |
| 1651 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { | 1649 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { |
| 1652 #if defined(OS_CHROMEOS) | 1650 #if defined(OS_CHROMEOS) |
| 1653 // Guests cannot modify exceptions. UIAccountTweaks will disabled the button. | 1651 // Guests cannot modify exceptions. UIAccountTweaks will disabled the button. |
| 1654 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) | 1652 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) |
| 1655 return; | 1653 return; |
| 1656 #endif | 1654 #endif |
| 1657 | 1655 |
| 1658 // Exceptions apply only when the feature is enabled. | 1656 // Exceptions apply only when the feature is enabled. |
| 1659 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1657 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1660 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1658 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1661 web_ui()->CallJavascriptFunction( | 1659 web_ui()->CallJavascriptFunctionUnsafe( |
| 1662 "ContentSettings.enableProtectedContentExceptions", | 1660 "ContentSettings.enableProtectedContentExceptions", |
| 1663 base::FundamentalValue(enable_exceptions)); | 1661 base::FundamentalValue(enable_exceptions)); |
| 1664 } | 1662 } |
| 1665 | 1663 |
| 1666 } // namespace options | 1664 } // namespace options |
| OLD | NEW |