| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/content_settings/core/browser/plugins_field_trial.h" | 5 #include "components/content_settings/core/browser/plugins_field_trial.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "components/plugins/common/plugins_switches.h" | 9 #include "components/plugins/common/plugins_switches.h" |
| 10 | 10 |
| 11 using base::FieldTrialList; |
| 12 |
| 11 namespace content_settings { | 13 namespace content_settings { |
| 12 | 14 |
| 13 // static | 15 // static |
| 14 const char PluginsFieldTrial::kFieldTrialName[] = "ForcePluginPowerSaver"; | 16 const char PluginsFieldTrial::kForceFieldTrial[] = "ForcePluginPowerSaver"; |
| 17 |
| 18 // static |
| 19 const char PluginsFieldTrial::kEnableFieldTrial[] = "PluginPowerSaver"; |
| 15 | 20 |
| 16 // static | 21 // static |
| 17 ContentSetting PluginsFieldTrial::EffectiveContentSetting( | 22 ContentSetting PluginsFieldTrial::EffectiveContentSetting( |
| 18 ContentSettingsType type, | 23 ContentSettingsType type, |
| 19 ContentSetting setting) { | 24 ContentSetting setting) { |
| 20 if (type != CONTENT_SETTINGS_TYPE_PLUGINS) | 25 if (type != CONTENT_SETTINGS_TYPE_PLUGINS) |
| 21 return setting; | 26 return setting; |
| 22 | 27 |
| 23 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior. | 28 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior. |
| 24 if (setting == ContentSetting::CONTENT_SETTING_ASK) | 29 if (setting == ContentSetting::CONTENT_SETTING_ASK) |
| 25 return ContentSetting::CONTENT_SETTING_BLOCK; | 30 return ContentSetting::CONTENT_SETTING_BLOCK; |
| 26 | 31 |
| 27 return setting; | 32 return setting; |
| 28 } | 33 } |
| 29 | 34 |
| 30 // static | 35 // static |
| 31 bool PluginsFieldTrial::IsPluginPowerSaverEnabled() { | 36 bool PluginsFieldTrial::IsPluginPowerSaverEnabled() { |
| 37 std::string enable_group = FieldTrialList::FindFullName(kEnableFieldTrial); |
| 38 std::string force_group = FieldTrialList::FindFullName(kForceFieldTrial); |
| 39 |
| 32 const base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | 40 const base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); |
| 33 if (cl->HasSwitch(plugins::switches::kDisablePluginPowerSaver)) | 41 if (cl->HasSwitch(plugins::switches::kDisablePluginPowerSaver)) |
| 34 return false; | 42 return false; |
| 35 if (cl->HasSwitch(plugins::switches::kEnablePluginPowerSaver)) | 43 if (cl->HasSwitch(plugins::switches::kEnablePluginPowerSaver)) |
| 36 return true; | 44 return true; |
| 37 | 45 |
| 38 std::string group_name = base::FieldTrialList::FindFullName(kFieldTrialName); | 46 if (!enable_group.empty() && enable_group != "Disabled") |
| 39 return !group_name.empty() && group_name != "Disabled"; | 47 return true; |
| 48 if (!force_group.empty() && force_group != "Disabled") |
| 49 return true; |
| 50 |
| 51 return false; |
| 40 } | 52 } |
| 41 | 53 |
| 42 // static | 54 // static |
| 43 ContentSetting PluginsFieldTrial::GetDefaultPluginsContentSetting() { | 55 ContentSetting PluginsFieldTrial::GetDefaultPluginsContentSetting() { |
| 44 return IsPluginPowerSaverEnabled() ? | 56 return IsPluginPowerSaverEnabled() ? |
| 45 ContentSetting::CONTENT_SETTING_DETECT_IMPORTANT_CONTENT : | 57 ContentSetting::CONTENT_SETTING_DETECT_IMPORTANT_CONTENT : |
| 46 ContentSetting::CONTENT_SETTING_ALLOW; | 58 ContentSetting::CONTENT_SETTING_ALLOW; |
| 47 } | 59 } |
| 48 | 60 |
| 49 } // namespace content_settings | 61 } // namespace content_settings |
| OLD | NEW |