| 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 12 matching lines...) Expand all Loading... |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 25 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
| 26 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 26 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 27 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" | 27 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" |
| 28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 29 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 29 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
| 30 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 30 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 31 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 31 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| 32 #include "chrome/browser/permissions/chooser_context_base.h" | 32 #include "chrome/browser/permissions/chooser_context_base.h" |
| 33 #include "chrome/browser/permissions/permission_uma_util.h" |
| 34 #include "chrome/browser/permissions/permission_util.h" |
| 33 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
| 34 #include "chrome/browser/ui/browser_list.h" | 36 #include "chrome/browser/ui/browser_list.h" |
| 35 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 37 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
| 36 #include "chrome/browser/ui/webui/site_settings_helper.h" | 38 #include "chrome/browser/ui/webui/site_settings_helper.h" |
| 37 #include "chrome/browser/usb/usb_chooser_context.h" | 39 #include "chrome/browser/usb/usb_chooser_context.h" |
| 38 #include "chrome/browser/usb/usb_chooser_context_factory.h" | 40 #include "chrome/browser/usb/usb_chooser_context_factory.h" |
| 39 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
| 40 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 42 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 41 #include "chrome/common/features.h" | 43 #include "chrome/common/features.h" |
| 42 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 | 785 |
| 784 UpdateFlashMediaLinksVisibility(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 786 UpdateFlashMediaLinksVisibility(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 785 UpdateFlashMediaLinksVisibility(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 787 UpdateFlashMediaLinksVisibility(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 786 } | 788 } |
| 787 } | 789 } |
| 788 | 790 |
| 789 void ContentSettingsHandler::UpdateSettingDefaultFromModel( | 791 void ContentSettingsHandler::UpdateSettingDefaultFromModel( |
| 790 ContentSettingsType type) { | 792 ContentSettingsType type) { |
| 791 std::string provider_id; | 793 std::string provider_id; |
| 792 ContentSetting default_setting = | 794 ContentSetting default_setting = |
| 793 GetContentSettingsMap()->GetDefaultContentSetting(type, &provider_id); | 795 HostContentSettingsMapFactory::GetForProfile(GetProfile()) |
| 796 ->GetDefaultContentSetting(type, &provider_id); |
| 794 | 797 |
| 795 #if defined(ENABLE_PLUGINS) | 798 #if defined(ENABLE_PLUGINS) |
| 796 default_setting = | 799 default_setting = |
| 797 content_settings::PluginsFieldTrial::EffectiveContentSetting( | 800 content_settings::PluginsFieldTrial::EffectiveContentSetting( |
| 798 type, default_setting); | 801 type, default_setting); |
| 799 #endif | 802 #endif |
| 800 | 803 |
| 801 // Camera and microphone default content settings cannot be set by the policy. | 804 // Camera and microphone default content settings cannot be set by the policy. |
| 802 // However, the policy can disable them. Treat this case visually in the same | 805 // However, the policy can disable them. Treat this case visually in the same |
| 803 // way as if the policy set the default setting to BLOCK. Furthermore, compare | 806 // way as if the policy set the default setting to BLOCK. Furthermore, compare |
| (...skipping 21 matching lines...) Expand all Loading... |
| 825 site_settings::ContentSettingsTypeToGroupName(type) + ".managedBy", | 828 site_settings::ContentSettingsTypeToGroupName(type) + ".managedBy", |
| 826 provider_id); | 829 provider_id); |
| 827 | 830 |
| 828 web_ui()->CallJavascriptFunctionUnsafe( | 831 web_ui()->CallJavascriptFunctionUnsafe( |
| 829 "ContentSettings.setContentFilterSettingsValue", filter_settings); | 832 "ContentSettings.setContentFilterSettingsValue", filter_settings); |
| 830 } | 833 } |
| 831 | 834 |
| 832 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs( | 835 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs( |
| 833 ContentSettingsType type) { | 836 ContentSettingsType type) { |
| 834 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 837 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 838 HostContentSettingsMap* settings_map = |
| 839 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 835 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); | 840 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); |
| 836 std::string policy_pref = (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) | 841 std::string policy_pref = (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) |
| 837 ? prefs::kAudioCaptureAllowed | 842 ? prefs::kAudioCaptureAllowed |
| 838 : prefs::kVideoCaptureAllowed; | 843 : prefs::kVideoCaptureAllowed; |
| 839 | 844 |
| 840 settings.policy_disable = !prefs->GetBoolean(policy_pref) && | 845 settings.policy_disable = !prefs->GetBoolean(policy_pref) && |
| 841 prefs->IsManagedPreference(policy_pref); | 846 prefs->IsManagedPreference(policy_pref); |
| 842 settings.default_setting = | 847 settings.default_setting = |
| 843 GetContentSettingsMap()->GetDefaultContentSetting(type, NULL); | 848 settings_map->GetDefaultContentSetting(type, nullptr); |
| 844 settings.default_setting_initialized = true; | 849 settings.default_setting_initialized = true; |
| 845 | 850 |
| 846 UpdateFlashMediaLinksVisibility(type); | 851 UpdateFlashMediaLinksVisibility(type); |
| 847 UpdateMediaDeviceDropdownVisibility(type); | 852 UpdateMediaDeviceDropdownVisibility(type); |
| 848 } | 853 } |
| 849 | 854 |
| 850 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { | 855 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { |
| 851 base::FundamentalValue handlers_enabled( | 856 base::FundamentalValue handlers_enabled( |
| 852 GetProtocolHandlerRegistry()->enabled()); | 857 GetProtocolHandlerRegistry()->enabled()); |
| 853 | 858 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 type_string, exceptions); | 1005 type_string, exceptions); |
| 1001 | 1006 |
| 1002 // This is mainly here to keep this function ideologically parallel to | 1007 // This is mainly here to keep this function ideologically parallel to |
| 1003 // UpdateExceptionsViewFromHostContentSettingsMap(). | 1008 // UpdateExceptionsViewFromHostContentSettingsMap(). |
| 1004 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 1009 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 1005 } | 1010 } |
| 1006 | 1011 |
| 1007 void ContentSettingsHandler::CompareMediaExceptionsWithFlash( | 1012 void ContentSettingsHandler::CompareMediaExceptionsWithFlash( |
| 1008 ContentSettingsType type) { | 1013 ContentSettingsType type) { |
| 1009 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); | 1014 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); |
| 1015 HostContentSettingsMap* settings_map = |
| 1016 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 1010 | 1017 |
| 1011 base::ListValue exceptions; | 1018 base::ListValue exceptions; |
| 1012 site_settings::GetExceptionsFromHostContentSettingsMap( | 1019 site_settings::GetExceptionsFromHostContentSettingsMap(settings_map, type, |
| 1013 GetContentSettingsMap(), | 1020 web_ui(), &exceptions); |
| 1014 type, | |
| 1015 web_ui(), | |
| 1016 &exceptions); | |
| 1017 | 1021 |
| 1018 settings.exceptions.clear(); | 1022 settings.exceptions.clear(); |
| 1019 for (base::ListValue::const_iterator entry = exceptions.begin(); | 1023 for (base::ListValue::const_iterator entry = exceptions.begin(); |
| 1020 entry != exceptions.end(); ++entry) { | 1024 entry != exceptions.end(); ++entry) { |
| 1021 base::DictionaryValue* dict = nullptr; | 1025 base::DictionaryValue* dict = nullptr; |
| 1022 bool valid_dict = (*entry)->GetAsDictionary(&dict); | 1026 bool valid_dict = (*entry)->GetAsDictionary(&dict); |
| 1023 DCHECK(valid_dict); | 1027 DCHECK(valid_dict); |
| 1024 | 1028 |
| 1025 std::string origin; | 1029 std::string origin; |
| 1026 std::string setting; | 1030 std::string setting; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 } | 1148 } |
| 1145 | 1149 |
| 1146 base::StringValue type_string(kZoomContentType); | 1150 base::StringValue type_string(kZoomContentType); |
| 1147 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", | 1151 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1148 type_string, zoom_levels_exceptions); | 1152 type_string, zoom_levels_exceptions); |
| 1149 } | 1153 } |
| 1150 | 1154 |
| 1151 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( | 1155 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( |
| 1152 ContentSettingsType type) { | 1156 ContentSettingsType type) { |
| 1153 base::ListValue exceptions; | 1157 base::ListValue exceptions; |
| 1154 site_settings::GetExceptionsFromHostContentSettingsMap( | 1158 HostContentSettingsMap* settings_map = |
| 1155 GetContentSettingsMap(), type, web_ui(), &exceptions); | 1159 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 1160 site_settings::GetExceptionsFromHostContentSettingsMap(settings_map, type, |
| 1161 web_ui(), &exceptions); |
| 1156 base::StringValue type_string( | 1162 base::StringValue type_string( |
| 1157 site_settings::ContentSettingsTypeToGroupName(type)); | 1163 site_settings::ContentSettingsTypeToGroupName(type)); |
| 1158 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", | 1164 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1159 | 1165 |
| 1160 type_string, exceptions); | 1166 type_string, exceptions); |
| 1161 | 1167 |
| 1162 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); | 1168 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); |
| 1163 | 1169 |
| 1164 // Fullscreen and mouse lock have no global settings to update. | 1170 // Fullscreen and mouse lock have no global settings to update. |
| 1165 // TODO(mgiuca): Delete this after removing these content settings entirely | 1171 // TODO(mgiuca): Delete this after removing these content settings entirely |
| 1166 // (https://crbug.com/591896). | 1172 // (https://crbug.com/591896). |
| 1167 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN || | 1173 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN || |
| 1168 type == CONTENT_SETTINGS_TYPE_MOUSELOCK) { | 1174 type == CONTENT_SETTINGS_TYPE_MOUSELOCK) { |
| 1169 return; | 1175 return; |
| 1170 } | 1176 } |
| 1171 | 1177 |
| 1172 #if defined(OS_CHROMEOS) | 1178 #if defined(OS_CHROMEOS) |
| 1173 // Also the default for protected contents is managed in another place. | 1179 // Also the default for protected contents is managed in another place. |
| 1174 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) | 1180 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) |
| 1175 return; | 1181 return; |
| 1176 #endif | 1182 #endif |
| 1177 | 1183 |
| 1178 // The default may also have changed (we won't get a separate notification). | 1184 // The default may also have changed (we won't get a separate notification). |
| 1179 // If it hasn't changed, this call will be harmless. | 1185 // If it hasn't changed, this call will be harmless. |
| 1180 UpdateSettingDefaultFromModel(type); | 1186 UpdateSettingDefaultFromModel(type); |
| 1181 } | 1187 } |
| 1182 | 1188 |
| 1183 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap( | 1189 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap( |
| 1184 ContentSettingsType type) { | 1190 ContentSettingsType type) { |
| 1185 const HostContentSettingsMap* otr_settings_map = GetOTRContentSettingsMap(); | 1191 const HostContentSettingsMap* otr_settings_map = |
| 1192 HostContentSettingsMapFactory::GetForProfile(GetOTRProfile()); |
| 1186 if (!otr_settings_map) | 1193 if (!otr_settings_map) |
| 1187 return; | 1194 return; |
| 1188 base::ListValue exceptions; | 1195 base::ListValue exceptions; |
| 1189 site_settings::GetExceptionsFromHostContentSettingsMap( | 1196 site_settings::GetExceptionsFromHostContentSettingsMap( |
| 1190 otr_settings_map, type, web_ui(), &exceptions); | 1197 otr_settings_map, type, web_ui(), &exceptions); |
| 1191 base::StringValue type_string( | 1198 base::StringValue type_string( |
| 1192 site_settings::ContentSettingsTypeToGroupName(type)); | 1199 site_settings::ContentSettingsTypeToGroupName(type)); |
| 1193 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", | 1200 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", |
| 1194 type_string, exceptions); | 1201 type_string, exceptions); |
| 1195 } | 1202 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 ContentSettingsType type) { | 1297 ContentSettingsType type) { |
| 1291 std::string mode; | 1298 std::string mode; |
| 1292 bool rv = args->GetString(1, &mode); | 1299 bool rv = args->GetString(1, &mode); |
| 1293 DCHECK(rv); | 1300 DCHECK(rv); |
| 1294 | 1301 |
| 1295 std::string pattern; | 1302 std::string pattern; |
| 1296 rv = args->GetString(2, &pattern); | 1303 rv = args->GetString(2, &pattern); |
| 1297 DCHECK(rv); | 1304 DCHECK(rv); |
| 1298 | 1305 |
| 1299 // The fourth argument to this handler is optional. | 1306 // The fourth argument to this handler is optional. |
| 1300 std::string secondary_pattern; | 1307 std::string secondary_pattern_string; |
| 1301 if (args->GetSize() >= 4U) { | 1308 if (args->GetSize() >= 4U) { |
| 1302 rv = args->GetString(3, &secondary_pattern); | 1309 rv = args->GetString(3, &secondary_pattern_string); |
| 1303 DCHECK(rv); | 1310 DCHECK(rv); |
| 1304 } | 1311 } |
| 1305 | 1312 |
| 1313 Profile* profile = mode == "normal" ? GetProfile() : GetOTRProfile(); |
| 1314 if (!profile) |
| 1315 return; |
| 1316 |
| 1306 HostContentSettingsMap* settings_map = | 1317 HostContentSettingsMap* settings_map = |
| 1307 mode == "normal" ? GetContentSettingsMap() : | 1318 HostContentSettingsMapFactory::GetForProfile(profile); |
| 1308 GetOTRContentSettingsMap(); | 1319 ContentSettingsPattern primary_pattern = |
| 1309 if (settings_map) { | 1320 ContentSettingsPattern::FromString(pattern); |
| 1310 settings_map->SetContentSettingCustomScope( | 1321 ContentSettingsPattern secondary_pattern = |
| 1311 ContentSettingsPattern::FromString(pattern), | 1322 secondary_pattern_string.empty() |
| 1312 secondary_pattern.empty() | 1323 ? ContentSettingsPattern::Wildcard() |
| 1313 ? ContentSettingsPattern::Wildcard() | 1324 : ContentSettingsPattern::FromString(secondary_pattern_string); |
| 1314 : ContentSettingsPattern::FromString(secondary_pattern), | 1325 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( |
| 1315 type, std::string(), CONTENT_SETTING_DEFAULT); | 1326 profile, primary_pattern, secondary_pattern, type, |
| 1316 } | 1327 PermissionSourceUI::SITE_SETTINGS); |
| 1328 |
| 1329 settings_map->SetContentSettingCustomScope( |
| 1330 primary_pattern, secondary_pattern, type, std::string(), |
| 1331 CONTENT_SETTING_DEFAULT); |
| 1317 } | 1332 } |
| 1318 | 1333 |
| 1319 void ContentSettingsHandler::RemoveZoomLevelException( | 1334 void ContentSettingsHandler::RemoveZoomLevelException( |
| 1320 const base::ListValue* args) { | 1335 const base::ListValue* args) { |
| 1321 std::string mode; | 1336 std::string mode; |
| 1322 bool rv = args->GetString(1, &mode); | 1337 bool rv = args->GetString(1, &mode); |
| 1323 DCHECK(rv); | 1338 DCHECK(rv); |
| 1324 | 1339 |
| 1325 std::string pattern; | 1340 std::string pattern; |
| 1326 rv = args->GetString(2, &pattern); | 1341 rv = args->GetString(2, &pattern); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 std::string mode; | 1471 std::string mode; |
| 1457 CHECK(args->GetString(1, &mode)); | 1472 CHECK(args->GetString(1, &mode)); |
| 1458 std::string pattern; | 1473 std::string pattern; |
| 1459 CHECK(args->GetString(2, &pattern)); | 1474 CHECK(args->GetString(2, &pattern)); |
| 1460 std::string setting; | 1475 std::string setting; |
| 1461 CHECK(args->GetString(3, &setting)); | 1476 CHECK(args->GetString(3, &setting)); |
| 1462 | 1477 |
| 1463 ContentSettingsType type = | 1478 ContentSettingsType type = |
| 1464 site_settings::ContentSettingsTypeFromGroupName(type_string); | 1479 site_settings::ContentSettingsTypeFromGroupName(type_string); |
| 1465 | 1480 |
| 1466 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || | 1481 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION && |
| 1467 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | 1482 type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && |
| 1468 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { | 1483 type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 1469 NOTREACHED(); | |
| 1470 } else { | |
| 1471 HostContentSettingsMap* settings_map = | |
| 1472 mode == "normal" ? GetContentSettingsMap() : | |
| 1473 GetOTRContentSettingsMap(); | |
| 1474 | 1484 |
| 1475 // The settings map could be null if the mode was OTR but the OTR profile | 1485 Profile* profile = mode == "normal" ? GetProfile() : GetOTRProfile(); |
| 1476 // got destroyed before we received this message. | |
| 1477 if (!settings_map) | |
| 1478 return; | |
| 1479 | 1486 |
| 1480 ContentSetting setting_type; | 1487 // The profile could be nullptr if the mode was OTR but the OTR profile |
| 1481 bool result = | 1488 // got destroyed before we received this message. |
| 1482 content_settings::ContentSettingFromString(setting, &setting_type); | 1489 if (!profile) |
| 1483 DCHECK(result); | 1490 return; |
| 1484 | 1491 |
| 1485 settings_map->SetContentSettingCustomScope( | 1492 ContentSetting setting_type; |
| 1486 ContentSettingsPattern::FromString(pattern), | 1493 bool result = |
| 1487 ContentSettingsPattern::Wildcard(), type, std::string(), setting_type); | 1494 content_settings::ContentSettingFromString(setting, &setting_type); |
| 1488 WebSiteSettingsUmaUtil::LogPermissionChange(type, setting_type); | 1495 DCHECK(result); |
| 1489 } | 1496 |
| 1497 HostContentSettingsMap* settings_map = |
| 1498 HostContentSettingsMapFactory::GetForProfile(profile); |
| 1499 |
| 1500 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( |
| 1501 profile, ContentSettingsPattern::FromString(pattern), |
| 1502 ContentSettingsPattern::Wildcard(), type, |
| 1503 PermissionSourceUI::SITE_SETTINGS); |
| 1504 |
| 1505 settings_map->SetContentSettingCustomScope( |
| 1506 ContentSettingsPattern::FromString(pattern), |
| 1507 ContentSettingsPattern::Wildcard(), type, std::string(), setting_type); |
| 1508 WebSiteSettingsUmaUtil::LogPermissionChange(type, setting_type); |
| 1490 } | 1509 } |
| 1491 | 1510 |
| 1492 void ContentSettingsHandler::CheckExceptionPatternValidity( | 1511 void ContentSettingsHandler::CheckExceptionPatternValidity( |
| 1493 const base::ListValue* args) { | 1512 const base::ListValue* args) { |
| 1494 std::string type_string; | 1513 std::string type_string; |
| 1495 CHECK(args->GetString(0, &type_string)); | 1514 CHECK(args->GetString(0, &type_string)); |
| 1496 std::string mode_string; | 1515 std::string mode_string; |
| 1497 CHECK(args->GetString(1, &mode_string)); | 1516 CHECK(args->GetString(1, &mode_string)); |
| 1498 std::string pattern_string; | 1517 std::string pattern_string; |
| 1499 CHECK(args->GetString(2, &pattern_string)); | 1518 CHECK(args->GetString(2, &pattern_string)); |
| 1500 | 1519 |
| 1501 ContentSettingsPattern pattern = | 1520 ContentSettingsPattern pattern = |
| 1502 ContentSettingsPattern::FromString(pattern_string); | 1521 ContentSettingsPattern::FromString(pattern_string); |
| 1503 | 1522 |
| 1504 web_ui()->CallJavascriptFunctionUnsafe( | 1523 web_ui()->CallJavascriptFunctionUnsafe( |
| 1505 "ContentSettings.patternValidityCheckComplete", | 1524 "ContentSettings.patternValidityCheckComplete", |
| 1506 base::StringValue(type_string), base::StringValue(mode_string), | 1525 base::StringValue(type_string), base::StringValue(mode_string), |
| 1507 base::StringValue(pattern_string), | 1526 base::StringValue(pattern_string), |
| 1508 base::FundamentalValue(pattern.IsValid())); | 1527 base::FundamentalValue(pattern.IsValid())); |
| 1509 } | 1528 } |
| 1510 | 1529 |
| 1511 HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() { | 1530 Profile* ContentSettingsHandler::GetProfile() { |
| 1512 return HostContentSettingsMapFactory::GetForProfile( | 1531 return Profile::FromWebUI(web_ui()); |
| 1513 Profile::FromWebUI(web_ui())); | |
| 1514 } | 1532 } |
| 1515 | 1533 |
| 1516 ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() { | 1534 ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() { |
| 1517 return ProtocolHandlerRegistryFactory::GetForBrowserContext( | 1535 return ProtocolHandlerRegistryFactory::GetForBrowserContext( |
| 1518 GetBrowserContext(web_ui())); | 1536 GetBrowserContext(web_ui())); |
| 1519 } | 1537 } |
| 1520 | 1538 |
| 1521 HostContentSettingsMap* | 1539 Profile* ContentSettingsHandler::GetOTRProfile() { |
| 1522 ContentSettingsHandler::GetOTRContentSettingsMap() { | 1540 return GetProfile()->HasOffTheRecordProfile() |
| 1523 Profile* profile = Profile::FromWebUI(web_ui()); | 1541 ? GetProfile()->GetOffTheRecordProfile() |
| 1524 if (profile->HasOffTheRecordProfile()) | 1542 : nullptr; |
| 1525 return HostContentSettingsMapFactory::GetForProfile( | |
| 1526 profile->GetOffTheRecordProfile()); | |
| 1527 return NULL; | |
| 1528 } | 1543 } |
| 1529 | 1544 |
| 1530 void ContentSettingsHandler::RefreshFlashMediaSettings() { | 1545 void ContentSettingsHandler::RefreshFlashMediaSettings() { |
| 1531 MediaSettingsInfo::ForFlash& settings = media_settings_->forFlash(); | 1546 MediaSettingsInfo::ForFlash& settings = media_settings_->forFlash(); |
| 1532 settings.initialized = false; | 1547 settings.initialized = false; |
| 1533 | 1548 |
| 1534 settings.last_refresh_request_id = | 1549 settings.last_refresh_request_id = |
| 1535 flash_settings_manager_->GetPermissionSettings( | 1550 flash_settings_manager_->GetPermissionSettings( |
| 1536 PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC); | 1551 PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC); |
| 1537 } | 1552 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 | 1660 |
| 1646 // Exceptions apply only when the feature is enabled. | 1661 // Exceptions apply only when the feature is enabled. |
| 1647 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1662 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1648 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1663 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1649 web_ui()->CallJavascriptFunctionUnsafe( | 1664 web_ui()->CallJavascriptFunctionUnsafe( |
| 1650 "ContentSettings.enableProtectedContentExceptions", | 1665 "ContentSettings.enableProtectedContentExceptions", |
| 1651 base::FundamentalValue(enable_exceptions)); | 1666 base::FundamentalValue(enable_exceptions)); |
| 1652 } | 1667 } |
| 1653 | 1668 |
| 1654 } // namespace options | 1669 } // namespace options |
| OLD | NEW |