blob: 891acad3555b6c71870a28cdce66d07f32e1f5ff [file] [log] [blame]
[email protected]ae9e12a2012-07-31 17:48:121// Copyright (c) 2012 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.
4
5#include "chrome/browser/chrome_browser_field_trials.h"
6
7#include <string>
8
9#include "base/command_line.h"
10#include "base/metrics/field_trial.h"
[email protected]a7c94bc2013-03-26 21:38:1511#include "base/prefs/pref_service.h"
[email protected]e7463412013-06-10 22:53:4612#include "base/strings/string_util.h"
[email protected]4dcb7972013-06-28 15:15:4113#include "base/time/time.h"
[email protected]684fcc12013-03-08 22:50:0214#include "chrome/browser/omnibox/omnibox_field_trial.h"
[email protected]ae9e12a2012-07-31 17:48:1215#include "chrome/common/chrome_switches.h"
[email protected]9a3de3e32013-04-23 19:05:2116#include "chrome/common/chrome_version_info.h"
[email protected]e90c7562013-02-27 20:22:1817#include "chrome/common/metrics/variations/uniformity_field_trials.h"
[email protected]a7c94bc2013-03-26 21:38:1518#include "chrome/common/pref_names.h"
[email protected]ae9e12a2012-07-31 17:48:1219
[email protected]aa61db02013-04-23 00:23:4920#if defined(OS_ANDROID) || defined(OS_IOS)
21#include "chrome/browser/chrome_browser_field_trials_mobile.h"
22#else
23#include "chrome/browser/chrome_browser_field_trials_desktop.h"
24#endif
[email protected]ae9e12a2012-07-31 17:48:1225
[email protected]ae9e12a2012-07-31 17:48:1226ChromeBrowserFieldTrials::ChromeBrowserFieldTrials(
[email protected]e86df8dc2013-03-30 13:18:2827 const CommandLine& parsed_command_line)
28 : parsed_command_line_(parsed_command_line) {
[email protected]ae9e12a2012-07-31 17:48:1229}
30
31ChromeBrowserFieldTrials::~ChromeBrowserFieldTrials() {
32}
33
[email protected]a7c94bc2013-03-26 21:38:1534void ChromeBrowserFieldTrials::SetupFieldTrials(PrefService* local_state) {
35 const base::Time install_time = base::Time::FromTimeT(
36 local_state->GetInt64(prefs::kInstallDate));
37 DCHECK(!install_time.is_null());
[email protected]ebc60b72013-04-21 06:15:4038
[email protected]aa61db02013-04-23 00:23:4939 // Field trials that are shared by all platforms.
[email protected]e90c7562013-02-27 20:22:1840 chrome_variations::SetupUniformityFieldTrials(install_time);
[email protected]ebc60b72013-04-21 06:15:4041 InstantiateDynamicTrials();
[email protected]63ad35d52013-04-02 00:17:2142
43#if defined(OS_ANDROID) || defined(OS_IOS)
[email protected]aa61db02013-04-23 00:23:4944 chrome::SetupMobileFieldTrials(
45 parsed_command_line_, install_time, local_state);
46#else
47 chrome::SetupDesktopFieldTrials(
48 parsed_command_line_, install_time, local_state);
[email protected]e3e94f72012-09-14 02:11:4249#endif
[email protected]a0cdf262013-02-01 01:12:1250}
51
[email protected]bd557d42012-11-01 15:49:0952void ChromeBrowserFieldTrials::InstantiateDynamicTrials() {
53 // Call |FindValue()| on the trials below, which may come from the server, to
54 // ensure they get marked as "used" for the purposes of data reporting.
55 base::FieldTrialList::FindValue("UMA-Dynamic-Binary-Uniformity-Trial");
56 base::FieldTrialList::FindValue("UMA-Dynamic-Uniformity-Trial");
57 base::FieldTrialList::FindValue("InstantDummy");
[email protected]0f73d292012-11-09 21:57:0258 base::FieldTrialList::FindValue("InstantChannel");
[email protected]d68206f2012-11-17 15:58:4859 base::FieldTrialList::FindValue("Test0PercentDefault");
[email protected]6785d8072013-10-11 23:42:0960 // The following trials are used from renderer process.
61 // Mark here so they will be sync-ed.
[email protected]c7f30a12013-10-21 21:42:1762 base::FieldTrialList::FindValue("CLD1VsCLD2");
[email protected]afcc6822013-06-27 17:40:4663 base::FieldTrialList::FindValue("MouseEventPreconnect");
[email protected]dc1f8542013-01-30 05:10:2964 // Activate the autocomplete dynamic field trials.
[email protected]684fcc12013-03-08 22:50:0265 OmniboxFieldTrial::ActivateDynamicTrials();
[email protected]bd557d42012-11-01 15:49:0966}