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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 prefs->IsManagedPreference(policy_pref); | 774 prefs->IsManagedPreference(policy_pref); |
775 settings.default_setting = | 775 settings.default_setting = |
776 settings_map->GetDefaultContentSetting(type, nullptr); | 776 settings_map->GetDefaultContentSetting(type, nullptr); |
777 settings.default_setting_initialized = true; | 777 settings.default_setting_initialized = true; |
778 | 778 |
779 UpdateFlashMediaLinksVisibility(type); | 779 UpdateFlashMediaLinksVisibility(type); |
780 UpdateMediaDeviceDropdownVisibility(type); | 780 UpdateMediaDeviceDropdownVisibility(type); |
781 } | 781 } |
782 | 782 |
783 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { | 783 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { |
784 base::FundamentalValue handlers_enabled( | 784 base::Value handlers_enabled( |
785 GetProtocolHandlerRegistry()->enabled()); | 785 GetProtocolHandlerRegistry()->enabled()); |
786 | 786 |
787 web_ui()->CallJavascriptFunctionUnsafe( | 787 web_ui()->CallJavascriptFunctionUnsafe( |
788 "ContentSettings.updateHandlersEnabledRadios", handlers_enabled); | 788 "ContentSettings.updateHandlersEnabledRadios", handlers_enabled); |
789 } | 789 } |
790 | 790 |
791 void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() { | 791 void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() { |
792 const ExceptionsInfoMap& exceptions_info_map = GetExceptionsInfoMap(); | 792 const ExceptionsInfoMap& exceptions_info_map = GetExceptionsInfoMap(); |
793 for (const auto& exceptions_info_pair : exceptions_info_map) | 793 for (const auto& exceptions_info_pair : exceptions_info_map) |
794 UpdateExceptionsViewFromModel(exceptions_info_pair.first); | 794 UpdateExceptionsViewFromModel(exceptions_info_pair.first); |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 std::string pattern_string; | 1349 std::string pattern_string; |
1350 CHECK(args->GetString(2, &pattern_string)); | 1350 CHECK(args->GetString(2, &pattern_string)); |
1351 | 1351 |
1352 ContentSettingsPattern pattern = | 1352 ContentSettingsPattern pattern = |
1353 ContentSettingsPattern::FromString(pattern_string); | 1353 ContentSettingsPattern::FromString(pattern_string); |
1354 | 1354 |
1355 web_ui()->CallJavascriptFunctionUnsafe( | 1355 web_ui()->CallJavascriptFunctionUnsafe( |
1356 "ContentSettings.patternValidityCheckComplete", | 1356 "ContentSettings.patternValidityCheckComplete", |
1357 base::StringValue(type_string), base::StringValue(mode_string), | 1357 base::StringValue(type_string), base::StringValue(mode_string), |
1358 base::StringValue(pattern_string), | 1358 base::StringValue(pattern_string), |
1359 base::FundamentalValue(pattern.IsValid())); | 1359 base::Value(pattern.IsValid())); |
1360 } | 1360 } |
1361 | 1361 |
1362 Profile* ContentSettingsHandler::GetProfile() { | 1362 Profile* ContentSettingsHandler::GetProfile() { |
1363 return Profile::FromWebUI(web_ui()); | 1363 return Profile::FromWebUI(web_ui()); |
1364 } | 1364 } |
1365 | 1365 |
1366 ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() { | 1366 ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() { |
1367 return ProtocolHandlerRegistryFactory::GetForBrowserContext( | 1367 return ProtocolHandlerRegistryFactory::GetForBrowserContext( |
1368 GetBrowserContext(web_ui())); | 1368 GetBrowserContext(web_ui())); |
1369 } | 1369 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 settings.show_flash_exceptions_link; | 1415 settings.show_flash_exceptions_link; |
1416 | 1416 |
1417 if (show_link != show) { | 1417 if (show_link != show) { |
1418 web_ui()->CallJavascriptFunctionUnsafe( | 1418 web_ui()->CallJavascriptFunctionUnsafe( |
1419 "ContentSettings.showMediaPepperFlashLink", | 1419 "ContentSettings.showMediaPepperFlashLink", |
1420 base::StringValue(link_type == DEFAULT_SETTING ? "default" | 1420 base::StringValue(link_type == DEFAULT_SETTING ? "default" |
1421 : "exceptions"), | 1421 : "exceptions"), |
1422 base::StringValue(content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC | 1422 base::StringValue(content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC |
1423 ? "mic" | 1423 ? "mic" |
1424 : "camera"), | 1424 : "camera"), |
1425 base::FundamentalValue(show)); | 1425 base::Value(show)); |
1426 show_link = show; | 1426 show_link = show; |
1427 } | 1427 } |
1428 } | 1428 } |
1429 | 1429 |
1430 void ContentSettingsHandler::UpdateFlashMediaLinksVisibility( | 1430 void ContentSettingsHandler::UpdateFlashMediaLinksVisibility( |
1431 ContentSettingsType type) { | 1431 ContentSettingsType type) { |
1432 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); | 1432 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); |
1433 MediaSettingsInfo::ForFlash& flash_settings = media_settings_->forFlash(); | 1433 MediaSettingsInfo::ForFlash& flash_settings = media_settings_->forFlash(); |
1434 | 1434 |
1435 if (!flash_settings.initialized) | 1435 if (!flash_settings.initialized) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 } | 1473 } |
1474 } | 1474 } |
1475 | 1475 |
1476 void ContentSettingsHandler::UpdateMediaDeviceDropdownVisibility( | 1476 void ContentSettingsHandler::UpdateMediaDeviceDropdownVisibility( |
1477 ContentSettingsType type) { | 1477 ContentSettingsType type) { |
1478 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); | 1478 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); |
1479 | 1479 |
1480 web_ui()->CallJavascriptFunctionUnsafe( | 1480 web_ui()->CallJavascriptFunctionUnsafe( |
1481 "ContentSettings.setDevicesMenuVisibility", | 1481 "ContentSettings.setDevicesMenuVisibility", |
1482 base::StringValue(site_settings::ContentSettingsTypeToGroupName(type)), | 1482 base::StringValue(site_settings::ContentSettingsTypeToGroupName(type)), |
1483 base::FundamentalValue(!settings.policy_disable)); | 1483 base::Value(!settings.policy_disable)); |
1484 } | 1484 } |
1485 | 1485 |
1486 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { | 1486 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { |
1487 #if defined(OS_CHROMEOS) | 1487 #if defined(OS_CHROMEOS) |
1488 // Guests cannot modify exceptions. UIAccountTweaks will disabled the button. | 1488 // Guests cannot modify exceptions. UIAccountTweaks will disabled the button. |
1489 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) | 1489 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) |
1490 return; | 1490 return; |
1491 #endif | 1491 #endif |
1492 | 1492 |
1493 // Exceptions apply only when the feature is enabled. | 1493 // Exceptions apply only when the feature is enabled. |
1494 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1494 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
1495 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1495 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
1496 web_ui()->CallJavascriptFunctionUnsafe( | 1496 web_ui()->CallJavascriptFunctionUnsafe( |
1497 "ContentSettings.enableProtectedContentExceptions", | 1497 "ContentSettings.enableProtectedContentExceptions", |
1498 base::FundamentalValue(enable_exceptions)); | 1498 base::Value(enable_exceptions)); |
1499 } | 1499 } |
1500 | 1500 |
1501 } // namespace options | 1501 } // namespace options |
OLD | NEW |