Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / chrome_browser_field_trials_desktop.cc
blob7096ba830b78c036b6605f8fb30b835dae9dc491
1 // Copyright 2013 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 "chrome/browser/chrome_browser_field_trials_desktop.h"
7 #include <string>
9 #include "apps/field_trial_names.h"
10 #include "apps/pref_names.h"
11 #include "base/command_line.h"
12 #include "base/metrics/field_trial.h"
13 #include "base/prefs/pref_service.h"
14 #include "base/strings/string_util.h"
15 #include "chrome/browser/auto_launch_trial.h"
16 #include "chrome/browser/google/google_util.h"
17 #include "chrome/browser/gpu/chrome_gpu_util.h"
18 #include "chrome/browser/omnibox/omnibox_field_trial.h"
19 #include "chrome/browser/prerender/prerender_field_trial.h"
20 #include "chrome/browser/profiles/profiles_state.h"
21 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
22 #include "chrome/browser/ui/sync/one_click_signin_helper.h"
23 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/chrome_version_info.h"
25 #include "chrome/common/metrics/variations/variations_util.h"
26 #include "content/public/common/content_constants.h"
27 #include "net/spdy/spdy_session.h"
28 #include "ui/base/layout.h"
30 namespace chrome {
32 namespace {
34 void SetupAppLauncherFieldTrial(PrefService* local_state) {
35 if (base::FieldTrialList::FindFullName(apps::kLauncherPromoTrialName) ==
36 apps::kResetShowLauncherPromoPrefGroupName) {
37 local_state->SetBoolean(apps::prefs::kShowAppLauncherPromo, true);
41 void AutoLaunchChromeFieldTrial() {
42 std::string brand;
43 google_util::GetBrand(&brand);
45 // Create a 100% field trial based on the brand code.
46 if (auto_launch_trial::IsInExperimentGroup(brand)) {
47 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
48 kAutoLaunchTrialAutoLaunchGroup);
49 } else if (auto_launch_trial::IsInControlGroup(brand)) {
50 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
51 kAutoLaunchTrialControlGroup);
55 void SetupInfiniteCacheFieldTrial() {
56 const base::FieldTrial::Probability kDivisor = 100;
58 base::FieldTrial::Probability infinite_cache_probability = 0;
60 scoped_refptr<base::FieldTrial> trial(
61 base::FieldTrialList::FactoryGetFieldTrial(
62 "InfiniteCache", kDivisor, "No", 2013, 12, 31,
63 base::FieldTrial::ONE_TIME_RANDOMIZED, NULL));
64 trial->AppendGroup("Yes", infinite_cache_probability);
65 trial->AppendGroup("Control", infinite_cache_probability);
68 void DisableShowProfileSwitcherTrialIfNecessary() {
69 // This trial is created by the VariationsService, but it needs to be disabled
70 // if multi-profiles isn't enabled or if browser frame avatar menu is
71 // always hidden (Chrome OS).
72 bool avatar_menu_always_hidden = false;
73 #if defined(OS_CHROMEOS)
74 avatar_menu_always_hidden = true;
75 #endif
76 base::FieldTrial* trial = base::FieldTrialList::Find("ShowProfileSwitcher");
77 if (trial && (!profiles::IsMultipleProfilesEnabled() ||
78 avatar_menu_always_hidden)) {
79 trial->Disable();
83 void SetupCacheSensitivityAnalysisFieldTrial() {
84 const base::FieldTrial::Probability kDivisor = 100;
86 base::FieldTrial::Probability sensitivity_analysis_probability = 0;
88 #if defined(OS_ANDROID)
89 switch (chrome::VersionInfo::GetChannel()) {
90 case chrome::VersionInfo::CHANNEL_DEV:
91 sensitivity_analysis_probability = 10;
92 break;
93 case chrome::VersionInfo::CHANNEL_BETA:
94 sensitivity_analysis_probability = 5;
95 break;
96 case chrome::VersionInfo::CHANNEL_STABLE:
97 sensitivity_analysis_probability = 1;
98 break;
99 default:
100 break;
102 #endif
104 scoped_refptr<base::FieldTrial> trial(
105 base::FieldTrialList::FactoryGetFieldTrial(
106 "CacheSensitivityAnalysis", kDivisor, "No", 2013, 06, 15,
107 base::FieldTrial::SESSION_RANDOMIZED, NULL));
108 trial->AppendGroup("ControlA", sensitivity_analysis_probability);
109 trial->AppendGroup("ControlB", sensitivity_analysis_probability);
110 trial->AppendGroup("100A", sensitivity_analysis_probability);
111 trial->AppendGroup("100B", sensitivity_analysis_probability);
112 trial->AppendGroup("200A", sensitivity_analysis_probability);
113 trial->AppendGroup("200B", sensitivity_analysis_probability);
114 // TODO(gavinp,rvargas): Re-add 400 group to field trial if results justify.
117 void SetupLowLatencyFlashAudioFieldTrial() {
118 scoped_refptr<base::FieldTrial> trial(
119 base::FieldTrialList::FactoryGetFieldTrial(
120 content::kLowLatencyFlashAudioFieldTrialName, 100, "Standard",
121 2013, 9, 1, base::FieldTrial::SESSION_RANDOMIZED, NULL));
123 // Trial is enabled for dev / beta / canary users only.
124 if (chrome::VersionInfo::GetChannel() != chrome::VersionInfo::CHANNEL_STABLE)
125 trial->AppendGroup(content::kLowLatencyFlashAudioFieldTrialEnabledName, 25);
128 } // namespace
130 void SetupDesktopFieldTrials(const CommandLine& parsed_command_line,
131 const base::Time& install_time,
132 PrefService* local_state) {
133 prerender::ConfigurePrefetchAndPrerender(parsed_command_line);
134 AutoLaunchChromeFieldTrial();
135 gpu_util::InitializeCompositingFieldTrial();
136 OmniboxFieldTrial::ActivateStaticTrials();
137 SetupInfiniteCacheFieldTrial();
138 SetupCacheSensitivityAnalysisFieldTrial();
139 DisableShowProfileSwitcherTrialIfNecessary();
140 SetupAppLauncherFieldTrial(local_state);
141 SetupLowLatencyFlashAudioFieldTrial();
144 } // namespace chrome