Chromium Code Reviews| 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 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1300 std::string secondary_pattern; | 1302 std::string secondary_pattern; |
| 1301 if (args->GetSize() >= 4U) { | 1303 if (args->GetSize() >= 4U) { |
| 1302 rv = args->GetString(3, &secondary_pattern); | 1304 rv = args->GetString(3, &secondary_pattern); |
| 1303 DCHECK(rv); | 1305 DCHECK(rv); |
| 1304 } | 1306 } |
| 1305 | 1307 |
| 1306 HostContentSettingsMap* settings_map = | 1308 HostContentSettingsMap* settings_map = |
| 1307 mode == "normal" ? GetContentSettingsMap() : | 1309 mode == "normal" ? GetContentSettingsMap() : |
| 1308 GetOTRContentSettingsMap(); | 1310 GetOTRContentSettingsMap(); |
| 1309 if (settings_map) { | 1311 if (settings_map) { |
| 1312 ContentSettingsPattern secondary_content_setting_pattern = | |
| 1313 secondary_pattern.empty() | |
| 1314 ? ContentSettingsPattern::Wildcard() | |
| 1315 : ContentSettingsPattern::FromString(secondary_pattern); | |
| 1316 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( | |
| 1317 Profile::FromWebUI(web_ui()), | |
| 1318 ContentSettingsPattern::FromString(pattern), | |
| 1319 secondary_content_setting_pattern, type, | |
| 1320 PermissionSourceUI::SITE_SETTINGS); | |
| 1321 scoped_revocation_reporter.SetCustomSettingsMap(settings_map); | |
|
raymes
2016/07/26 01:18:31
I think we should just pass the OTR profile into t
stefanocs
2016/07/26 02:16:20
Done.
| |
| 1322 | |
| 1310 settings_map->SetContentSettingCustomScope( | 1323 settings_map->SetContentSettingCustomScope( |
| 1311 ContentSettingsPattern::FromString(pattern), | 1324 ContentSettingsPattern::FromString(pattern), |
|
raymes
2016/07/26 01:18:31
Can we pull this out above and have
ContentSetti
stefanocs
2016/07/26 02:16:20
Done.
| |
| 1312 secondary_pattern.empty() | 1325 secondary_content_setting_pattern, type, std::string(), |
| 1313 ? ContentSettingsPattern::Wildcard() | 1326 CONTENT_SETTING_DEFAULT); |
| 1314 : ContentSettingsPattern::FromString(secondary_pattern), | |
| 1315 type, std::string(), CONTENT_SETTING_DEFAULT); | |
| 1316 } | 1327 } |
| 1317 } | 1328 } |
| 1318 | 1329 |
| 1319 void ContentSettingsHandler::RemoveZoomLevelException( | 1330 void ContentSettingsHandler::RemoveZoomLevelException( |
| 1320 const base::ListValue* args) { | 1331 const base::ListValue* args) { |
| 1321 std::string mode; | 1332 std::string mode; |
| 1322 bool rv = args->GetString(1, &mode); | 1333 bool rv = args->GetString(1, &mode); |
| 1323 DCHECK(rv); | 1334 DCHECK(rv); |
| 1324 | 1335 |
| 1325 std::string pattern; | 1336 std::string pattern; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1475 // The settings map could be null if the mode was OTR but the OTR profile | 1486 // The settings map could be null if the mode was OTR but the OTR profile |
| 1476 // got destroyed before we received this message. | 1487 // got destroyed before we received this message. |
| 1477 if (!settings_map) | 1488 if (!settings_map) |
| 1478 return; | 1489 return; |
| 1479 | 1490 |
| 1480 ContentSetting setting_type; | 1491 ContentSetting setting_type; |
| 1481 bool result = | 1492 bool result = |
| 1482 content_settings::ContentSettingFromString(setting, &setting_type); | 1493 content_settings::ContentSettingFromString(setting, &setting_type); |
| 1483 DCHECK(result); | 1494 DCHECK(result); |
| 1484 | 1495 |
| 1496 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( | |
| 1497 Profile::FromWebUI(web_ui()), | |
| 1498 ContentSettingsPattern::FromString(pattern), | |
| 1499 ContentSettingsPattern::Wildcard(), type, | |
| 1500 PermissionSourceUI::SITE_SETTINGS); | |
| 1501 scoped_revocation_reporter.SetCustomSettingsMap(settings_map); | |
| 1502 | |
| 1485 settings_map->SetContentSettingCustomScope( | 1503 settings_map->SetContentSettingCustomScope( |
| 1486 ContentSettingsPattern::FromString(pattern), | 1504 ContentSettingsPattern::FromString(pattern), |
| 1487 ContentSettingsPattern::Wildcard(), type, std::string(), setting_type); | 1505 ContentSettingsPattern::Wildcard(), type, std::string(), setting_type); |
| 1488 WebSiteSettingsUmaUtil::LogPermissionChange(type, setting_type); | 1506 WebSiteSettingsUmaUtil::LogPermissionChange(type, setting_type); |
| 1489 } | 1507 } |
| 1490 } | 1508 } |
| 1491 | 1509 |
| 1492 void ContentSettingsHandler::CheckExceptionPatternValidity( | 1510 void ContentSettingsHandler::CheckExceptionPatternValidity( |
| 1493 const base::ListValue* args) { | 1511 const base::ListValue* args) { |
| 1494 std::string type_string; | 1512 std::string type_string; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1645 | 1663 |
| 1646 // Exceptions apply only when the feature is enabled. | 1664 // Exceptions apply only when the feature is enabled. |
| 1647 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1665 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1648 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1666 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1649 web_ui()->CallJavascriptFunctionUnsafe( | 1667 web_ui()->CallJavascriptFunctionUnsafe( |
| 1650 "ContentSettings.enableProtectedContentExceptions", | 1668 "ContentSettings.enableProtectedContentExceptions", |
| 1651 base::FundamentalValue(enable_exceptions)); | 1669 base::FundamentalValue(enable_exceptions)); |
| 1652 } | 1670 } |
| 1653 | 1671 |
| 1654 } // namespace options | 1672 } // namespace options |
| OLD | NEW |