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" 11 #include "base/prefs/pref_service.h" 12 #include "base/strings/string_util.h" 13 #include "base/time/time.h" 14 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_version_info.h" 16 #include "chrome/common/variations/uniformity_field_trials.h" 17 #include "components/metrics/metrics_pref_names.h" 18 #include "components/omnibox/omnibox_field_trial.h" 19 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 25 ChromeBrowserFieldTrials(const CommandLine & parsed_command_line)26ChromeBrowserFieldTrials::ChromeBrowserFieldTrials( 27 const CommandLine& parsed_command_line) 28 : parsed_command_line_(parsed_command_line) { 29 } 30 ~ChromeBrowserFieldTrials()31ChromeBrowserFieldTrials::~ChromeBrowserFieldTrials() { 32 } 33 SetupFieldTrials(const base::Time & install_time,PrefService * local_state)34void ChromeBrowserFieldTrials::SetupFieldTrials(const base::Time& install_time, 35 PrefService* local_state) { 36 DCHECK(!install_time.is_null()); 37 38 // Field trials that are shared by all platforms. 39 chrome_variations::SetupUniformityFieldTrials(install_time); 40 InstantiateDynamicTrials(); 41 42 #if defined(OS_ANDROID) || defined(OS_IOS) 43 chrome::SetupMobileFieldTrials(parsed_command_line_); 44 #else 45 chrome::SetupDesktopFieldTrials( 46 parsed_command_line_, local_state); 47 #endif 48 } 49 InstantiateDynamicTrials()50void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { 51 // The following trials are used from renderer process. 52 // Mark here so they will be sync-ed. 53 base::FieldTrialList::FindValue("CLD1VsCLD2"); 54 base::FieldTrialList::FindValue("MouseEventPreconnect"); 55 base::FieldTrialList::FindValue("UnauthorizedPluginInfoBar"); 56 base::FieldTrialList::FindValue("DisplayList2dCanvas"); 57 base::FieldTrialList::FindValue("V8ScriptStreaming"); 58 // Activate the autocomplete dynamic field trials. 59 OmniboxFieldTrial::ActivateDynamicTrials(); 60 } 61