Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc

Issue 9159047: Disable sync promo for Chromium builds (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" 5 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/string_number_conversions.h"
9 #include "base/string_util.h" 10 #include "base/string_util.h"
10 #include "chrome/browser/google/google_util.h" 11 #include "chrome/browser/google/google_util.h"
11 #include "chrome/browser/metrics/metrics_service.h" 12 #include "chrome/browser/metrics/metrics_service.h"
12 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" 15 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
15 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/chrome_version_info.h" 17 #include "chrome/common/chrome_version_info.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "content/public/browser/web_ui.h" 19 #include "content/public/browser/web_ui.h"
(...skipping 13 matching lines...) Expand all
32 }; 33 };
33 34
34 // Flag to make sure sync_promo_trial::Activate() has been called. 35 // Flag to make sure sync_promo_trial::Activate() has been called.
35 bool sync_promo_trial_initialized; 36 bool sync_promo_trial_initialized;
36 37
37 // Checks if a sync promo layout experiment is active. If it is active then the 38 // Checks if a sync promo layout experiment is active. If it is active then the
38 // layout type is return in |type|. 39 // layout type is return in |type|.
39 bool GetActiveLayoutExperiment(LayoutExperimentType* type) { 40 bool GetActiveLayoutExperiment(LayoutExperimentType* type) {
40 DCHECK(type); 41 DCHECK(type);
41 42
42 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSyncPromoVersion)) 43 int version = 0;
43 return false; 44 if (base::StringToInt(CommandLine::ForCurrentProcess()->
45 GetSwitchValueASCII(switches::kSyncPromoVersion), &version)) {
46 switch (version) {
47 case 0:
48 *type = LAYOUT_EXPERIMENT_DEFAULT;
49 return true;
50 case 1:
51 *type = LAYOUT_EXPERIMENT_DEVICES;
52 return true;
53 case 2:
54 *type = LAYOUT_EXPERIMENT_VERBOSE;
55 return true;
56 case 3:
57 *type = LAYOUT_EXPERIMENT_SIMPLE;
58 return true;
59 default:
60 return false;
61 }
62 }
44 63
45 if (chrome::VersionInfo::GetChannel() == 64 if (chrome::VersionInfo::GetChannel() ==
46 chrome::VersionInfo::CHANNEL_STABLE) { 65 chrome::VersionInfo::CHANNEL_STABLE) {
47 std::string brand; 66 std::string brand;
48 if (!google_util::GetBrand(&brand)) 67 if (!google_util::GetBrand(&brand))
49 return false; 68 return false;
50 69
51 if (brand == "GGRG" || brand == "CHCG") 70 if (brand == "GGRG" || brand == "CHCG")
52 *type = LAYOUT_EXPERIMENT_DEFAULT; 71 *type = LAYOUT_EXPERIMENT_DEFAULT;
53 else if (brand == "GGRH" || brand == "CHCH") 72 else if (brand == "GGRH" || brand == "CHCH")
(...skipping 22 matching lines...) Expand all
76 namespace sync_promo_trial { 95 namespace sync_promo_trial {
77 96
78 void Activate() { 97 void Activate() {
79 DCHECK(!sync_promo_trial_initialized); 98 DCHECK(!sync_promo_trial_initialized);
80 sync_promo_trial_initialized = true; 99 sync_promo_trial_initialized = true;
81 100
82 // For stable builds we'll use brand codes to enroll uesrs into experiments. 101 // For stable builds we'll use brand codes to enroll uesrs into experiments.
83 // For dev and beta we don't have brand codes so we randomly enroll users. 102 // For dev and beta we don't have brand codes so we randomly enroll users.
84 if (chrome::VersionInfo::GetChannel() != 103 if (chrome::VersionInfo::GetChannel() !=
85 chrome::VersionInfo::CHANNEL_STABLE) { 104 chrome::VersionInfo::CHANNEL_STABLE) {
105 #if defined(GOOGLE_CHROME_BUILD)
86 // Create a field trial that expires in August 8, 2012. It contains 5 groups 106 // Create a field trial that expires in August 8, 2012. It contains 5 groups
87 // with each group having an equal chance of enrollment. 107 // with each group having an equal chance of enrollment.
88 scoped_refptr<base::FieldTrial> trial(new base::FieldTrial( 108 scoped_refptr<base::FieldTrial> trial(new base::FieldTrial(
89 kLayoutExperimentTrialName, 5, "default", 2012, 8, 1)); 109 kLayoutExperimentTrialName, 5, "default", 2012, 8, 1));
90 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) 110 if (base::FieldTrialList::IsOneTimeRandomizationEnabled())
91 trial->UseOneTimeRandomization(); 111 trial->UseOneTimeRandomization();
92 trial->AppendGroup("", 1); 112 trial->AppendGroup("", 1);
93 trial->AppendGroup("", 1); 113 trial->AppendGroup("", 1);
94 trial->AppendGroup("", 1); 114 trial->AppendGroup("", 1);
95 trial->AppendGroup("", 1); 115 trial->AppendGroup("", 1);
116 #endif
96 } 117 }
97 } 118 }
98 119
99 StartupOverride GetStartupOverrideForCurrentTrial() { 120 StartupOverride GetStartupOverrideForCurrentTrial() {
100 DCHECK(sync_promo_trial_initialized); 121 DCHECK(sync_promo_trial_initialized);
101 122
102 LayoutExperimentType type; 123 LayoutExperimentType type;
103 if (GetActiveLayoutExperiment(&type)) { 124 if (GetActiveLayoutExperiment(&type)) {
104 return type == LAYOUT_EXPERIMENT_NONE ? STARTUP_OVERRIDE_HIDE : 125 return type == LAYOUT_EXPERIMENT_NONE ? STARTUP_OVERRIDE_HIDE :
105 STARTUP_OVERRIDE_SHOW; 126 STARTUP_OVERRIDE_SHOW;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 return true; 184 return true;
164 case LAYOUT_EXPERIMENT_SIMPLE: 185 case LAYOUT_EXPERIMENT_SIMPLE:
165 *version = 3; 186 *version = 3;
166 return true; 187 return true;
167 default: 188 default:
168 return false; 189 return false;
169 } 190 }
170 } 191 }
171 192
172 } // namespace sync_promo_trial 193 } // namespace sync_promo_trial
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698