app_shell: Add version number in user agent
[chromium-blink-merge.git] / chrome / browser / chrome_browser_field_trials_mobile.cc
blob3bc52cbd0175dde139a97ef8d88295f97ccd9682
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_mobile.h"
7 #include <string>
9 #include "base/command_line.h"
10 #include "base/metrics/field_trial.h"
11 #include "base/prefs/pref_service.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/chrome_version_info.h"
15 #if defined(OS_ANDROID)
16 #include "chrome/browser/prerender/prerender_field_trial.h"
17 #endif
19 namespace chrome {
21 namespace {
23 // Base function used by all data reduction proxy field trials. A trial is
24 // only conducted for installs that are in the "Enabled" group. They are always
25 // enabled on DEV and BETA channels, and for STABLE, a percentage will be
26 // controlled from the server. Until the percentage is learned from the server,
27 // a client-side configuration is used.
28 void DataCompressionProxyBaseFieldTrial(
29 const char* trial_name,
30 const base::FieldTrial::Probability enabled_group_probability,
31 const base::FieldTrial::Probability total_probability) {
32 const char kEnabled[] = "Enabled";
33 const char kDisabled[] = "Disabled";
35 // Find out if this is a stable channel.
36 const bool kIsStableChannel =
37 chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE;
39 // Experiment enabled until Jan 1, 2015. By default, disabled.
40 scoped_refptr<base::FieldTrial> trial(
41 base::FieldTrialList::FactoryGetFieldTrial(
42 trial_name,
43 total_probability,
44 kDisabled, 2015, 1, 1, base::FieldTrial::ONE_TIME_RANDOMIZED, NULL));
46 // Non-stable channels will run with probability 1.
47 const int kEnabledGroup = trial->AppendGroup(
48 kEnabled,
49 kIsStableChannel ? enabled_group_probability : total_probability);
51 const int v = trial->group();
52 VLOG(1) << trial_name << " enabled group id: " << kEnabledGroup
53 << ". Selected group id: " << v;
56 void DataCompressionProxyFieldTrials() {
57 // Governs the rollout of the compression proxy for Chrome on mobile
58 // platforms. In all channels, the percentage will be controlled from the
59 // server, and is configured to be 100% = 1000 / 1000 until overridden by the
60 // server.
61 DataCompressionProxyBaseFieldTrial(
62 "DataCompressionProxyRollout", 1000, 1000);
64 // Governs the rollout of the _promo_ for the compression proxy
65 // independently from the rollout of compression proxy. The enabled
66 // percentage is configured to be 10% = 100 / 1000 until overridden by the
67 // server. When this trial is "Enabled," users get a promo, whereas
68 // otherwise, compression is available without a promo.
69 DataCompressionProxyBaseFieldTrial(
70 "DataCompressionProxyPromoVisibility", 100, 1000);
73 } // namespace
75 void SetupMobileFieldTrials(const CommandLine& parsed_command_line) {
76 DataCompressionProxyFieldTrials();
77 #if defined(OS_ANDROID)
78 prerender::ConfigurePrerender(parsed_command_line);
79 #endif
82 } // namespace chrome