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