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
3 // found in the LICENSE file.
5 #include "components/content_settings/core/browser/plugins_field_trial.h"
7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h"
9 #include "components/plugins/common/plugins_switches.h"
11 using base::FieldTrialList
;
13 namespace content_settings
{
16 const char PluginsFieldTrial::kForceFieldTrial
[] = "ForcePluginPowerSaver";
19 const char PluginsFieldTrial::kEnableFieldTrial
[] = "PluginPowerSaver";
22 ContentSetting
PluginsFieldTrial::EffectiveContentSetting(
23 ContentSettingsType type
,
24 ContentSetting setting
) {
25 if (type
!= CONTENT_SETTINGS_TYPE_PLUGINS
)
28 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior.
29 if (setting
== ContentSetting::CONTENT_SETTING_ASK
)
30 return ContentSetting::CONTENT_SETTING_BLOCK
;
36 bool PluginsFieldTrial::IsPluginPowerSaverEnabled() {
37 std::string enable_group
= FieldTrialList::FindFullName(kEnableFieldTrial
);
38 std::string force_group
= FieldTrialList::FindFullName(kForceFieldTrial
);
40 const base::CommandLine
* cl
= base::CommandLine::ForCurrentProcess();
41 if (cl
->HasSwitch(plugins::switches::kDisablePluginPowerSaver
))
43 if (cl
->HasSwitch(plugins::switches::kEnablePluginPowerSaver
))
46 if (!enable_group
.empty() && enable_group
!= "Disabled")
48 if (!force_group
.empty() && force_group
!= "Disabled")
55 ContentSetting
PluginsFieldTrial::GetDefaultPluginsContentSetting() {
56 return IsPluginPowerSaverEnabled() ?
57 ContentSetting::CONTENT_SETTING_DETECT_IMPORTANT_CONTENT
:
58 ContentSetting::CONTENT_SETTING_ALLOW
;
61 } // namespace content_settings