[email protected] | ae9e12a | 2012-07-31 17:48:12 | [diff] [blame] | 1 | // 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] | a7c94bc | 2013-03-26 21:38:15 | [diff] [blame] | 11 | #include "base/prefs/pref_service.h" |
[email protected] | e746341 | 2013-06-10 22:53:46 | [diff] [blame] | 12 | #include "base/strings/string_util.h" |
[email protected] | 4dcb797 | 2013-06-28 15:15:41 | [diff] [blame] | 13 | #include "base/time/time.h" |
[email protected] | 684fcc1 | 2013-03-08 22:50:02 | [diff] [blame] | 14 | #include "chrome/browser/omnibox/omnibox_field_trial.h" |
[email protected] | ae9e12a | 2012-07-31 17:48:12 | [diff] [blame] | 15 | #include "chrome/common/chrome_switches.h" |
[email protected] | 9a3de3e3 | 2013-04-23 19:05:21 | [diff] [blame] | 16 | #include "chrome/common/chrome_version_info.h" |
[email protected] | e90c756 | 2013-02-27 20:22:18 | [diff] [blame] | 17 | #include "chrome/common/metrics/variations/uniformity_field_trials.h" |
[email protected] | a7c94bc | 2013-03-26 21:38:15 | [diff] [blame] | 18 | #include "chrome/common/pref_names.h" |
[email protected] | ae9e12a | 2012-07-31 17:48:12 | [diff] [blame] | 19 | |
[email protected] | aa61db0 | 2013-04-23 00:23:49 | [diff] [blame] | 20 | #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] | ae9e12a | 2012-07-31 17:48:12 | [diff] [blame] | 25 | |
[email protected] | ae9e12a | 2012-07-31 17:48:12 | [diff] [blame] | 26 | ChromeBrowserFieldTrials::ChromeBrowserFieldTrials( |
[email protected] | e86df8dc | 2013-03-30 13:18:28 | [diff] [blame] | 27 | const CommandLine& parsed_command_line) |
28 | : parsed_command_line_(parsed_command_line) { | ||||
[email protected] | ae9e12a | 2012-07-31 17:48:12 | [diff] [blame] | 29 | } |
30 | |||||
31 | ChromeBrowserFieldTrials::~ChromeBrowserFieldTrials() { | ||||
32 | } | ||||
33 | |||||
[email protected] | a7c94bc | 2013-03-26 21:38:15 | [diff] [blame] | 34 | void 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] | ebc60b7 | 2013-04-21 06:15:40 | [diff] [blame] | 38 | |
[email protected] | aa61db0 | 2013-04-23 00:23:49 | [diff] [blame] | 39 | // Field trials that are shared by all platforms. |
[email protected] | e90c756 | 2013-02-27 20:22:18 | [diff] [blame] | 40 | chrome_variations::SetupUniformityFieldTrials(install_time); |
[email protected] | ebc60b7 | 2013-04-21 06:15:40 | [diff] [blame] | 41 | InstantiateDynamicTrials(); |
[email protected] | 63ad35d5 | 2013-04-02 00:17:21 | [diff] [blame] | 42 | |
43 | #if defined(OS_ANDROID) || defined(OS_IOS) | ||||
[email protected] | aa61db0 | 2013-04-23 00:23:49 | [diff] [blame] | 44 | 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] | e3e94f7 | 2012-09-14 02:11:42 | [diff] [blame] | 49 | #endif |
[email protected] | a0cdf26 | 2013-02-01 01:12:12 | [diff] [blame] | 50 | } |
51 | |||||
[email protected] | bd557d4 | 2012-11-01 15:49:09 | [diff] [blame] | 52 | void 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] | 0f73d29 | 2012-11-09 21:57:02 | [diff] [blame] | 58 | base::FieldTrialList::FindValue("InstantChannel"); |
[email protected] | d68206f | 2012-11-17 15:58:48 | [diff] [blame] | 59 | base::FieldTrialList::FindValue("Test0PercentDefault"); |
[email protected] | 6785d807 | 2013-10-11 23:42:09 | [diff] [blame] | 60 | // The following trials are used from renderer process. |
61 | // Mark here so they will be sync-ed. | ||||
[email protected] | c7f30a1 | 2013-10-21 21:42:17 | [diff] [blame] | 62 | base::FieldTrialList::FindValue("CLD1VsCLD2"); |
[email protected] | afcc682 | 2013-06-27 17:40:46 | [diff] [blame] | 63 | base::FieldTrialList::FindValue("MouseEventPreconnect"); |
[email protected] | dc1f854 | 2013-01-30 05:10:29 | [diff] [blame] | 64 | // Activate the autocomplete dynamic field trials. |
[email protected] | 684fcc1 | 2013-03-08 22:50:02 | [diff] [blame] | 65 | OmniboxFieldTrial::ActivateDynamicTrials(); |
[email protected] | bd557d4 | 2012-11-01 15:49:09 | [diff] [blame] | 66 | } |