Revert r196089 "Add default values for Latin script font prefs."
[chromium-blink-merge.git] / chrome / browser / chrome_browser_field_trials_desktop.cc
blob90c882dded8b93704060f7d7eccb2d4e76f5a6ce
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/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/profile_manager.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 "net/spdy/spdy_session.h"
27 #include "ui/base/layout.h"
29 #if defined(OS_WIN)
30 #include "net/socket/tcp_client_socket_win.h"
31 #endif // defined(OS_WIN)
33 namespace chrome {
35 namespace {
37 void SetupAppLauncherFieldTrial(PrefService* local_state) {
38 if (base::FieldTrialList::FindFullName(apps::kLauncherPromoTrialName) ==
39 apps::kResetShowLauncherPromoPrefGroupName) {
40 local_state->SetBoolean(apps::prefs::kShowAppLauncherPromo, true);
44 void AutoLaunchChromeFieldTrial() {
45 std::string brand;
46 google_util::GetBrand(&brand);
48 // Create a 100% field trial based on the brand code.
49 if (auto_launch_trial::IsInExperimentGroup(brand)) {
50 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
51 kAutoLaunchTrialAutoLaunchGroup);
52 } else if (auto_launch_trial::IsInControlGroup(brand)) {
53 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
54 kAutoLaunchTrialControlGroup);
58 void SetUpInfiniteCacheFieldTrial() {
59 const base::FieldTrial::Probability kDivisor = 100;
61 base::FieldTrial::Probability infinite_cache_probability = 0;
63 scoped_refptr<base::FieldTrial> trial(
64 base::FieldTrialList::FactoryGetFieldTrial("InfiniteCache", kDivisor,
65 "No", 2013, 12, 31, NULL));
66 trial->UseOneTimeRandomization();
67 trial->AppendGroup("Yes", infinite_cache_probability);
68 trial->AppendGroup("Control", infinite_cache_probability);
71 void DisableShowProfileSwitcherTrialIfNecessary() {
72 // This trial is created by the VariationsService, but it needs to be disabled
73 // if multi-profiles isn't enabled or if browser frame avatar menu is
74 // always hidden (Chrome OS).
75 bool avatar_menu_always_hidden = false;
76 #if defined(OS_CHROMEOS)
77 avatar_menu_always_hidden = true;
78 #endif
79 base::FieldTrial* trial = base::FieldTrialList::Find("ShowProfileSwitcher");
80 if (trial && (!ProfileManager::IsMultipleProfilesEnabled() ||
81 avatar_menu_always_hidden)) {
82 trial->Disable();
86 void SetUpCacheSensitivityAnalysisFieldTrial() {
87 const base::FieldTrial::Probability kDivisor = 100;
89 base::FieldTrial::Probability sensitivity_analysis_probability = 0;
91 #if defined(OS_ANDROID)
92 switch (chrome::VersionInfo::GetChannel()) {
93 case chrome::VersionInfo::CHANNEL_DEV:
94 sensitivity_analysis_probability = 10;
95 break;
96 case chrome::VersionInfo::CHANNEL_BETA:
97 sensitivity_analysis_probability = 5;
98 break;
99 case chrome::VersionInfo::CHANNEL_STABLE:
100 sensitivity_analysis_probability = 1;
101 break;
102 default:
103 break;
105 #endif
107 scoped_refptr<base::FieldTrial> trial(
108 base::FieldTrialList::FactoryGetFieldTrial("CacheSensitivityAnalysis",
109 kDivisor, "No",
110 2013, 06, 15, NULL));
111 trial->AppendGroup("ControlA", sensitivity_analysis_probability);
112 trial->AppendGroup("ControlB", sensitivity_analysis_probability);
113 trial->AppendGroup("100A", sensitivity_analysis_probability);
114 trial->AppendGroup("100B", sensitivity_analysis_probability);
115 trial->AppendGroup("200A", sensitivity_analysis_probability);
116 trial->AppendGroup("200B", sensitivity_analysis_probability);
117 // TODO(gavinp,rvargas): Re-add 400 group to field trial if results justify.
120 void WindowsOverlappedTCPReadsFieldTrial(
121 const CommandLine& parsed_command_line) {
122 #if defined(OS_WIN)
123 if (parsed_command_line.HasSwitch(switches::kOverlappedRead)) {
124 std::string option =
125 parsed_command_line.GetSwitchValueASCII(switches::kOverlappedRead);
126 if (LowerCaseEqualsASCII(option, "off"))
127 net::TCPClientSocketWin::DisableOverlappedReads();
128 } else {
129 const base::FieldTrial::Probability kDivisor = 2; // 1 in 2 chance
130 const base::FieldTrial::Probability kOverlappedReadProbability = 1;
131 scoped_refptr<base::FieldTrial> overlapped_reads_trial(
132 base::FieldTrialList::FactoryGetFieldTrial("OverlappedReadImpact",
133 kDivisor, "OverlappedReadEnabled", 2013, 6, 1, NULL));
134 int overlapped_reads_disabled_group =
135 overlapped_reads_trial->AppendGroup("OverlappedReadDisabled",
136 kOverlappedReadProbability);
137 int assigned_group = overlapped_reads_trial->group();
138 if (assigned_group == overlapped_reads_disabled_group)
139 net::TCPClientSocketWin::DisableOverlappedReads();
141 #endif
144 } // namespace
146 void SetupDesktopFieldTrials(const CommandLine& parsed_command_line,
147 const base::Time& install_time,
148 PrefService* local_state) {
149 prerender::ConfigurePrefetchAndPrerender(parsed_command_line);
150 AutoLaunchChromeFieldTrial();
151 gpu_util::InitializeCompositingFieldTrial();
152 OmniboxFieldTrial::ActivateStaticTrials();
153 SetUpInfiniteCacheFieldTrial();
154 SetUpCacheSensitivityAnalysisFieldTrial();
155 DisableShowProfileSwitcherTrialIfNecessary();
156 WindowsOverlappedTCPReadsFieldTrial(parsed_command_line);
157 SetupAppLauncherFieldTrial(local_state);
160 } // namespace chrome