| 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 <map> | 10 #include <map> |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 {"locationAllow", IDS_GEOLOCATION_ALLOW_RADIO}, | 425 {"locationAllow", IDS_GEOLOCATION_ALLOW_RADIO}, |
| 426 {"locationAsk", IDS_GEOLOCATION_ASK_RADIO}, | 426 {"locationAsk", IDS_GEOLOCATION_ASK_RADIO}, |
| 427 {"locationBlock", IDS_GEOLOCATION_BLOCK_RADIO}, | 427 {"locationBlock", IDS_GEOLOCATION_BLOCK_RADIO}, |
| 428 {"setBy", IDS_GEOLOCATION_SET_BY_HOVER}, | 428 {"setBy", IDS_GEOLOCATION_SET_BY_HOVER}, |
| 429 // Notifications filter. | 429 // Notifications filter. |
| 430 {"notificationsTabLabel", IDS_NOTIFICATIONS_TAB_LABEL}, | 430 {"notificationsTabLabel", IDS_NOTIFICATIONS_TAB_LABEL}, |
| 431 {"notificationsHeader", IDS_NOTIFICATIONS_HEADER}, | 431 {"notificationsHeader", IDS_NOTIFICATIONS_HEADER}, |
| 432 {"notificationsAllow", IDS_NOTIFICATIONS_ALLOW_RADIO}, | 432 {"notificationsAllow", IDS_NOTIFICATIONS_ALLOW_RADIO}, |
| 433 {"notificationsAsk", IDS_NOTIFICATIONS_ASK_RADIO}, | 433 {"notificationsAsk", IDS_NOTIFICATIONS_ASK_RADIO}, |
| 434 {"notificationsBlock", IDS_NOTIFICATIONS_BLOCK_RADIO}, | 434 {"notificationsBlock", IDS_NOTIFICATIONS_BLOCK_RADIO}, |
| 435 // Fullscreen filter. | |
| 436 {"fullscreenTabLabel", IDS_FULLSCREEN_TAB_LABEL}, | |
| 437 {"fullscreenHeader", IDS_FULLSCREEN_HEADER}, | |
| 438 {"fullscreenDeprecated", IDS_EXCLUSIVE_ACCESS_DEPRECATED}, | |
| 439 // Mouse Lock filter. | |
| 440 {"mouselockTabLabel", IDS_MOUSE_LOCK_TAB_LABEL}, | |
| 441 {"mouselockHeader", IDS_MOUSE_LOCK_HEADER}, | |
| 442 {"mouselockDeprecated", IDS_EXCLUSIVE_ACCESS_DEPRECATED}, | |
| 443 #if defined(OS_CHROMEOS) || defined(OS_WIN) | 435 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 444 // Protected Content filter | 436 // Protected Content filter |
| 445 {"protectedContentTabLabel", IDS_PROTECTED_CONTENT_TAB_LABEL}, | 437 {"protectedContentTabLabel", IDS_PROTECTED_CONTENT_TAB_LABEL}, |
| 446 {"protectedContentInfo", IDS_PROTECTED_CONTENT_INFO}, | 438 {"protectedContentInfo", IDS_PROTECTED_CONTENT_INFO}, |
| 447 {"protectedContentEnable", IDS_PROTECTED_CONTENT_ENABLE}, | 439 {"protectedContentEnable", IDS_PROTECTED_CONTENT_ENABLE}, |
| 448 {"protectedContentHeader", IDS_PROTECTED_CONTENT_HEADER}, | 440 {"protectedContentHeader", IDS_PROTECTED_CONTENT_HEADER}, |
| 449 #endif // defined(OS_CHROMEOS) || defined(OS_WIN) | 441 #endif // defined(OS_CHROMEOS) || defined(OS_WIN) |
| 450 // Microphone filter. | 442 // Microphone filter. |
| 451 {"mediaStreamMicTabLabel", IDS_MEDIA_STREAM_MIC_TAB_LABEL}, | 443 {"mediaStreamMicTabLabel", IDS_MEDIA_STREAM_MIC_TAB_LABEL}, |
| 452 {"mediaStreamMicHeader", IDS_MEDIA_STREAM_MIC_HEADER}, | 444 {"mediaStreamMicHeader", IDS_MEDIA_STREAM_MIC_HEADER}, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 IDS_IMAGES_TAB_LABEL); | 543 IDS_IMAGES_TAB_LABEL); |
| 552 RegisterTitle(localized_strings, "javascript", | 544 RegisterTitle(localized_strings, "javascript", |
| 553 IDS_JAVASCRIPT_TAB_LABEL); | 545 IDS_JAVASCRIPT_TAB_LABEL); |
| 554 RegisterTitle(localized_strings, "plugins", IDS_FLASH_TAB_LABEL); | 546 RegisterTitle(localized_strings, "plugins", IDS_FLASH_TAB_LABEL); |
| 555 RegisterTitle(localized_strings, "popups", | 547 RegisterTitle(localized_strings, "popups", |
| 556 IDS_POPUP_TAB_LABEL); | 548 IDS_POPUP_TAB_LABEL); |
| 557 RegisterTitle(localized_strings, "location", | 549 RegisterTitle(localized_strings, "location", |
| 558 IDS_GEOLOCATION_TAB_LABEL); | 550 IDS_GEOLOCATION_TAB_LABEL); |
| 559 RegisterTitle(localized_strings, "notifications", | 551 RegisterTitle(localized_strings, "notifications", |
| 560 IDS_NOTIFICATIONS_TAB_LABEL); | 552 IDS_NOTIFICATIONS_TAB_LABEL); |
| 561 RegisterTitle(localized_strings, "fullscreen", | |
| 562 IDS_FULLSCREEN_TAB_LABEL); | |
| 563 RegisterTitle(localized_strings, "mouselock", | |
| 564 IDS_MOUSE_LOCK_TAB_LABEL); | |
| 565 #if defined(OS_CHROMEOS) | 553 #if defined(OS_CHROMEOS) |
| 566 RegisterTitle(localized_strings, "protectedContent", | 554 RegisterTitle(localized_strings, "protectedContent", |
| 567 IDS_PROTECTED_CONTENT_TAB_LABEL); | 555 IDS_PROTECTED_CONTENT_TAB_LABEL); |
| 568 #endif | 556 #endif |
| 569 RegisterTitle(localized_strings, "media-stream-mic", | 557 RegisterTitle(localized_strings, "media-stream-mic", |
| 570 IDS_MEDIA_STREAM_MIC_TAB_LABEL); | 558 IDS_MEDIA_STREAM_MIC_TAB_LABEL); |
| 571 RegisterTitle(localized_strings, "media-stream-camera", | 559 RegisterTitle(localized_strings, "media-stream-camera", |
| 572 IDS_MEDIA_STREAM_CAMERA_TAB_LABEL); | 560 IDS_MEDIA_STREAM_CAMERA_TAB_LABEL); |
| 573 RegisterTitle(localized_strings, "ppapi-broker", | 561 RegisterTitle(localized_strings, "ppapi-broker", |
| 574 IDS_PPAPI_BROKER_TAB_LABEL); | 562 IDS_PPAPI_BROKER_TAB_LABEL); |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 zoom_levels_exceptions.Append(std::move(exception)); | 1089 zoom_levels_exceptions.Append(std::move(exception)); |
| 1102 } | 1090 } |
| 1103 | 1091 |
| 1104 base::StringValue type_string(kZoomContentType); | 1092 base::StringValue type_string(kZoomContentType); |
| 1105 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", | 1093 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1106 type_string, zoom_levels_exceptions); | 1094 type_string, zoom_levels_exceptions); |
| 1107 } | 1095 } |
| 1108 | 1096 |
| 1109 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( | 1097 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( |
| 1110 ContentSettingsType type) { | 1098 ContentSettingsType type) { |
| 1099 // Fullscreen and mouse lock have no global settings to update. |
| 1100 // TODO(mgiuca): Delete this after removing these content settings entirely |
| 1101 // (https://crbug.com/591896). |
| 1102 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN || |
| 1103 type == CONTENT_SETTINGS_TYPE_MOUSELOCK) { |
| 1104 return; |
| 1105 } |
| 1106 |
| 1111 base::ListValue exceptions; | 1107 base::ListValue exceptions; |
| 1112 HostContentSettingsMap* settings_map = | 1108 HostContentSettingsMap* settings_map = |
| 1113 HostContentSettingsMapFactory::GetForProfile(GetProfile()); | 1109 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 1114 site_settings::GetExceptionsFromHostContentSettingsMap(settings_map, type, | 1110 site_settings::GetExceptionsFromHostContentSettingsMap(settings_map, type, |
| 1115 web_ui(), /*incognito=*/false, /*filter=*/nullptr, &exceptions); | 1111 web_ui(), /*incognito=*/false, /*filter=*/nullptr, &exceptions); |
| 1116 base::StringValue type_string( | 1112 base::StringValue type_string( |
| 1117 site_settings::ContentSettingsTypeToGroupName(type)); | 1113 site_settings::ContentSettingsTypeToGroupName(type)); |
| 1118 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", | 1114 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1119 type_string, exceptions); | 1115 type_string, exceptions); |
| 1120 | 1116 |
| 1121 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); | 1117 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); |
| 1122 | 1118 |
| 1123 // Fullscreen and mouse lock have no global settings to update. | |
| 1124 // TODO(mgiuca): Delete this after removing these content settings entirely | |
| 1125 // (https://crbug.com/591896). | |
| 1126 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN || | |
| 1127 type == CONTENT_SETTINGS_TYPE_MOUSELOCK) { | |
| 1128 return; | |
| 1129 } | |
| 1130 | |
| 1131 #if defined(OS_CHROMEOS) | 1119 #if defined(OS_CHROMEOS) |
| 1132 // Also the default for protected contents is managed in another place. | 1120 // Also the default for protected contents is managed in another place. |
| 1133 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) | 1121 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) |
| 1134 return; | 1122 return; |
| 1135 #endif | 1123 #endif |
| 1136 | 1124 |
| 1137 // The default may also have changed (we won't get a separate notification). | 1125 // The default may also have changed (we won't get a separate notification). |
| 1138 // If it hasn't changed, this call will be harmless. | 1126 // If it hasn't changed, this call will be harmless. |
| 1139 UpdateSettingDefaultFromModel(type); | 1127 UpdateSettingDefaultFromModel(type); |
| 1140 } | 1128 } |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 | 1510 |
| 1523 // Exceptions apply only when the feature is enabled. | 1511 // Exceptions apply only when the feature is enabled. |
| 1524 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1512 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1525 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1513 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1526 web_ui()->CallJavascriptFunctionUnsafe( | 1514 web_ui()->CallJavascriptFunctionUnsafe( |
| 1527 "ContentSettings.enableProtectedContentExceptions", | 1515 "ContentSettings.enableProtectedContentExceptions", |
| 1528 base::FundamentalValue(enable_exceptions)); | 1516 base::FundamentalValue(enable_exceptions)); |
| 1529 } | 1517 } |
| 1530 | 1518 |
| 1531 } // namespace options | 1519 } // namespace options |
| OLD | NEW |