Fire an error if a pref used in the UI is missing once all prefs are fetched.
[chromium-blink-merge.git] / chrome / browser / chrome_browser_field_trials_desktop.cc
blobd836695c8aad7e6b05e533f5fb9aeeec91894a5f
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 "base/command_line.h"
10 #include "base/metrics/field_trial.h"
11 #include "base/strings/string_util.h"
12 #include "chrome/browser/auto_launch_trial.h"
13 #include "chrome/browser/google/google_brand.h"
14 #include "chrome/browser/prerender/prerender_field_trial.h"
15 #include "chrome/browser/profiles/profiles_state.h"
16 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/chrome_version_info.h"
19 #include "chrome/common/variations/variations_util.h"
20 #include "components/variations/variations_associated_data.h"
21 #include "content/public/common/content_constants.h"
22 #include "net/spdy/spdy_session.h"
23 #include "ui/base/layout.h"
25 namespace chrome {
27 namespace {
29 void AutoLaunchChromeFieldTrial() {
30 std::string brand;
31 google_brand::GetBrand(&brand);
33 // Create a 100% field trial based on the brand code.
34 if (auto_launch_trial::IsInExperimentGroup(brand)) {
35 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
36 kAutoLaunchTrialAutoLaunchGroup);
37 } else if (auto_launch_trial::IsInControlGroup(brand)) {
38 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
39 kAutoLaunchTrialControlGroup);
43 void SetupInfiniteCacheFieldTrial() {
44 const base::FieldTrial::Probability kDivisor = 100;
46 base::FieldTrial::Probability infinite_cache_probability = 0;
48 scoped_refptr<base::FieldTrial> trial(
49 base::FieldTrialList::FactoryGetFieldTrial(
50 "InfiniteCache", kDivisor, "No", 2013, 12, 31,
51 base::FieldTrial::ONE_TIME_RANDOMIZED, NULL));
52 trial->AppendGroup("Yes", infinite_cache_probability);
53 trial->AppendGroup("Control", infinite_cache_probability);
56 void DisableShowProfileSwitcherTrialIfNecessary() {
57 // This trial is created by the VariationsService, but it needs to be disabled
58 // if multi-profiles isn't enabled.
59 base::FieldTrial* trial = base::FieldTrialList::Find("ShowProfileSwitcher");
60 if (trial && !profiles::IsMultipleProfilesEnabled())
61 trial->Disable();
64 void SetupLightSpeedTrials() {
65 if (!variations::GetVariationParamValue("LightSpeed", "NoGpu").empty()) {
66 base::CommandLine::ForCurrentProcess()->AppendSwitch(
67 switches::kDisableGpu);
71 } // namespace
73 void SetupDesktopFieldTrials(const base::CommandLine& parsed_command_line) {
74 prerender::ConfigurePrerender(parsed_command_line);
75 AutoLaunchChromeFieldTrial();
76 SetupInfiniteCacheFieldTrial();
77 DisableShowProfileSwitcherTrialIfNecessary();
78 SetupLightSpeedTrials();
81 } // namespace chrome