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