Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Side by Side Diff: chrome/browser/ui/webui/options/content_settings_handler.cc

Issue 1033103002: Plugin Power Saver: Overhaul plugin-power-saver flags. Show in UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gypi i hope Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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::EnableForcePluginPowerSaver()) {
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
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 // For Plugins, allow flag to override displayed content setting.
610 if (type == ContentSettingsType::CONTENT_SETTINGS_TYPE_PLUGINS && 615 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior.
611 default_setting == ContentSetting::CONTENT_SETTING_ASK) { 616 if (type == ContentSettingsType::CONTENT_SETTINGS_TYPE_PLUGINS) {
612 default_setting = ContentSetting::CONTENT_SETTING_BLOCK; 617 if (default_setting == ContentSetting::CONTENT_SETTING_ALLOW &&
618 PluginsFieldTrial::EnableForcePluginPowerSaver()) {
619 default_setting =
620 ContentSetting::CONTENT_SETTING_DETECT_IMPORTANT_CONTENT;
621 } else if (default_setting == ContentSetting::CONTENT_SETTING_ASK) {
622 default_setting = ContentSetting::CONTENT_SETTING_BLOCK;
623 }
613 } 624 }
614 625
615 base::DictionaryValue filter_settings; 626 base::DictionaryValue filter_settings;
616 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", 627 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value",
617 ContentSettingToString(default_setting)); 628 ContentSettingToString(default_setting));
618 filter_settings.SetString( 629 filter_settings.SetString(
619 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id); 630 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id);
620 631
621 web_ui()->CallJavascriptFunction( 632 web_ui()->CallJavascriptFunction(
622 "ContentSettings.setContentFilterSettingsValue", filter_settings); 633 "ContentSettings.setContentFilterSettingsValue", filter_settings);
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 1631
1621 // Exceptions apply only when the feature is enabled. 1632 // Exceptions apply only when the feature is enabled.
1622 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1633 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1623 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1634 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1624 web_ui()->CallJavascriptFunction( 1635 web_ui()->CallJavascriptFunction(
1625 "ContentSettings.enableProtectedContentExceptions", 1636 "ContentSettings.enableProtectedContentExceptions",
1626 base::FundamentalValue(enable_exceptions)); 1637 base::FundamentalValue(enable_exceptions));
1627 } 1638 }
1628 1639
1629 } // namespace options 1640 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698