Chromium Code Reviews| 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 namespace content_settings { | 11 namespace content_settings { |
| 12 | 12 |
| 13 // static | 13 // static |
| 14 const char PluginsFieldTrial::kFieldTrialName[] = "ForcePluginPowerSaver"; | 14 const char PluginsFieldTrial::kForceFieldTrial[] = "ForcePluginPowerSaver"; |
| 15 | |
| 16 // static | |
| 17 const char PluginsFieldTrial::kEnableFieldTrial[] = "PluginPowerSaver"; | |
| 15 | 18 |
| 16 // static | 19 // static |
| 17 ContentSetting PluginsFieldTrial::EffectiveContentSetting( | 20 ContentSetting PluginsFieldTrial::EffectiveContentSetting( |
| 18 ContentSettingsType type, | 21 ContentSettingsType type, |
| 19 ContentSetting setting) { | 22 ContentSetting setting) { |
| 20 if (type != CONTENT_SETTINGS_TYPE_PLUGINS) | 23 if (type != CONTENT_SETTINGS_TYPE_PLUGINS) |
| 21 return setting; | 24 return setting; |
| 22 | 25 |
| 23 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior. | 26 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior. |
| 24 if (setting == ContentSetting::CONTENT_SETTING_ASK) | 27 if (setting == ContentSetting::CONTENT_SETTING_ASK) |
| 25 return ContentSetting::CONTENT_SETTING_BLOCK; | 28 return ContentSetting::CONTENT_SETTING_BLOCK; |
| 26 | 29 |
| 27 return setting; | 30 return setting; |
| 28 } | 31 } |
| 29 | 32 |
| 30 // static | 33 // static |
| 31 bool PluginsFieldTrial::IsPluginPowerSaverEnabled() { | 34 bool PluginsFieldTrial::IsPluginPowerSaverEnabled() { |
| 32 const base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | 35 const base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); |
| 33 if (cl->HasSwitch(plugins::switches::kDisablePluginPowerSaver)) | 36 if (cl->HasSwitch(plugins::switches::kDisablePluginPowerSaver)) |
| 34 return false; | 37 return false; |
| 35 if (cl->HasSwitch(plugins::switches::kEnablePluginPowerSaver)) | 38 if (cl->HasSwitch(plugins::switches::kEnablePluginPowerSaver)) |
| 36 return true; | 39 return true; |
| 37 | 40 |
| 38 std::string group_name = base::FieldTrialList::FindFullName(kFieldTrialName); | 41 std::string group = base::FieldTrialList::FindFullName(kEnableFieldTrial); |
|
Bernhard Bauer
2015/04/29 16:23:24
According to go/finch-and-flags, you should get th
Dan Beam
2015/04/29 17:59:28
Done.
| |
| 39 return !group_name.empty() && group_name != "Disabled"; | 42 if (!group.empty() && group != "Disabled") |
| 43 return true; | |
| 44 | |
| 45 group = base::FieldTrialList::FindFullName(kForceFieldTrial); | |
| 46 if (!group.empty() && group != "Disabled") | |
| 47 return true; | |
| 48 | |
| 49 return false; | |
| 40 } | 50 } |
| 41 | 51 |
| 42 // static | 52 // static |
| 43 ContentSetting PluginsFieldTrial::GetDefaultPluginsContentSetting() { | 53 ContentSetting PluginsFieldTrial::GetDefaultPluginsContentSetting() { |
| 44 return IsPluginPowerSaverEnabled() ? | 54 return IsPluginPowerSaverEnabled() ? |
| 45 ContentSetting::CONTENT_SETTING_DETECT_IMPORTANT_CONTENT : | 55 ContentSetting::CONTENT_SETTING_DETECT_IMPORTANT_CONTENT : |
| 46 ContentSetting::CONTENT_SETTING_ALLOW; | 56 ContentSetting::CONTENT_SETTING_ALLOW; |
| 47 } | 57 } |
| 48 | 58 |
| 49 } // namespace content_settings | 59 } // namespace content_settings |
| OLD | NEW |