| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" | |
| 14 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 15 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/values.h" | 16 #include "base/values.h" |
| 18 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" | 19 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" |
| 21 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 20 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 22 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 21 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
| 23 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 22 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 24 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 23 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/ui/browser_list.h" | 25 #include "chrome/browser/ui/browser_list.h" |
| 27 #include "chrome/common/chrome_switches.h" | |
| 28 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 26 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 29 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 31 #include "chrome/grit/generated_resources.h" | 29 #include "chrome/grit/generated_resources.h" |
| 32 #include "chrome/grit/locale_settings.h" | 30 #include "chrome/grit/locale_settings.h" |
| 33 #include "components/content_settings/core/browser/content_settings_details.h" | 31 #include "components/content_settings/core/browser/content_settings_details.h" |
| 34 #include "components/content_settings/core/browser/content_settings_utils.h" | 32 #include "components/content_settings/core/browser/content_settings_utils.h" |
| 35 #include "components/content_settings/core/browser/host_content_settings_map.h" | 33 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 36 #include "components/content_settings/core/common/content_settings.h" | 34 #include "components/content_settings/core/common/content_settings.h" |
| 37 #include "components/content_settings/core/common/content_settings_pattern.h" | 35 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 38 #include "components/google/core/browser/google_util.h" | 36 #include "components/google/core/browser/google_util.h" |
| 37 #include "components/plugins/common/plugins_field_trial.h" |
| 39 #include "components/signin/core/common/profile_management_switches.h" | 38 #include "components/signin/core/common/profile_management_switches.h" |
| 40 #include "components/user_prefs/user_prefs.h" | 39 #include "components/user_prefs/user_prefs.h" |
| 41 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
| 42 #include "content/public/browser/notification_source.h" | 41 #include "content/public/browser/notification_source.h" |
| 43 #include "content/public/browser/notification_types.h" | 42 #include "content/public/browser/notification_types.h" |
| 44 #include "content/public/browser/storage_partition.h" | 43 #include "content/public/browser/storage_partition.h" |
| 45 #include "content/public/browser/user_metrics.h" | 44 #include "content/public/browser/user_metrics.h" |
| 46 #include "content/public/browser/web_contents.h" | 45 #include "content/public/browser/web_contents.h" |
| 47 #include "content/public/browser/web_ui.h" | 46 #include "content/public/browser/web_ui.h" |
| 48 #include "content/public/common/content_switches.h" | 47 #include "content/public/common/content_switches.h" |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 } | 520 } |
| 522 } | 521 } |
| 523 | 522 |
| 524 void ContentSettingsHandler::InitializePage() { | 523 void ContentSettingsHandler::InitializePage() { |
| 525 media_settings_ = MediaSettingsInfo(); | 524 media_settings_ = MediaSettingsInfo(); |
| 526 RefreshFlashMediaSettings(); | 525 RefreshFlashMediaSettings(); |
| 527 | 526 |
| 528 UpdateHandlersEnabledRadios(); | 527 UpdateHandlersEnabledRadios(); |
| 529 UpdateAllExceptionsViewsFromModel(); | 528 UpdateAllExceptionsViewsFromModel(); |
| 530 UpdateProtectedContentExceptionsButton(); | 529 UpdateProtectedContentExceptionsButton(); |
| 530 |
| 531 // For Plugins, allow flag to override displayed content setting. |
| 532 if (PluginsFieldTrial::IsForcePluginPowerSaverEnabled()) { |
| 533 web_ui()->CallJavascriptFunction( |
| 534 "ContentSettings.disablePluginsAllowOption"); |
| 535 } |
| 531 } | 536 } |
| 532 | 537 |
| 533 void ContentSettingsHandler::OnContentSettingChanged( | 538 void ContentSettingsHandler::OnContentSettingChanged( |
| 534 const ContentSettingsPattern& primary_pattern, | 539 const ContentSettingsPattern& primary_pattern, |
| 535 const ContentSettingsPattern& secondary_pattern, | 540 const ContentSettingsPattern& secondary_pattern, |
| 536 ContentSettingsType content_type, | 541 ContentSettingsType content_type, |
| 537 std::string resource_identifier) { | 542 std::string resource_identifier) { |
| 538 const ContentSettingsDetails details( | 543 const ContentSettingsDetails details( |
| 539 primary_pattern, secondary_pattern, content_type, resource_identifier); | 544 primary_pattern, secondary_pattern, content_type, resource_identifier); |
| 540 // TODO(estade): we pretend update_all() is always true. | 545 // TODO(estade): we pretend update_all() is always true. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 UpdateFlashMediaLinksVisibility(); | 604 UpdateFlashMediaLinksVisibility(); |
| 600 } | 605 } |
| 601 } | 606 } |
| 602 | 607 |
| 603 void ContentSettingsHandler::UpdateSettingDefaultFromModel( | 608 void ContentSettingsHandler::UpdateSettingDefaultFromModel( |
| 604 ContentSettingsType type) { | 609 ContentSettingsType type) { |
| 605 std::string provider_id; | 610 std::string provider_id; |
| 606 ContentSetting default_setting = | 611 ContentSetting default_setting = |
| 607 GetContentSettingsMap()->GetDefaultContentSetting(type, &provider_id); | 612 GetContentSettingsMap()->GetDefaultContentSetting(type, &provider_id); |
| 608 | 613 |
| 609 // For Plugins, display the obsolete ASK setting as BLOCK. | 614 #if defined(ENABLE_PLUGINS) |
| 610 if (type == ContentSettingsType::CONTENT_SETTINGS_TYPE_PLUGINS && | 615 default_setting = |
| 611 default_setting == ContentSetting::CONTENT_SETTING_ASK) { | 616 PluginsFieldTrial::EffectiveContentSetting(type, default_setting); |
| 612 default_setting = ContentSetting::CONTENT_SETTING_BLOCK; | 617 #endif |
| 613 } | |
| 614 | 618 |
| 615 base::DictionaryValue filter_settings; | 619 base::DictionaryValue filter_settings; |
| 616 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", | 620 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", |
| 617 ContentSettingToString(default_setting)); | 621 ContentSettingToString(default_setting)); |
| 618 filter_settings.SetString( | 622 filter_settings.SetString( |
| 619 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id); | 623 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id); |
| 620 | 624 |
| 621 web_ui()->CallJavascriptFunction( | 625 web_ui()->CallJavascriptFunction( |
| 622 "ContentSettings.setContentFilterSettingsValue", filter_settings); | 626 "ContentSettings.setContentFilterSettingsValue", filter_settings); |
| 623 } | 627 } |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 | 1624 |
| 1621 // Exceptions apply only when the feature is enabled. | 1625 // Exceptions apply only when the feature is enabled. |
| 1622 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1626 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1623 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1627 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1624 web_ui()->CallJavascriptFunction( | 1628 web_ui()->CallJavascriptFunction( |
| 1625 "ContentSettings.enableProtectedContentExceptions", | 1629 "ContentSettings.enableProtectedContentExceptions", |
| 1626 base::FundamentalValue(enable_exceptions)); | 1630 base::FundamentalValue(enable_exceptions)); |
| 1627 } | 1631 } |
| 1628 | 1632 |
| 1629 } // namespace options | 1633 } // namespace options |
| OLD | NEW |