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

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

Issue 9225053: Add a blocking version of the sync promo dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments 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_util.h" 9 #include "base/string_util.h"
10 #include "chrome/browser/google/google_util.h" 10 #include "chrome/browser/google/google_util.h"
(...skipping 10 matching lines...) Expand all
21 namespace { 21 namespace {
22 22
23 const char kLayoutExperimentTrialName[] = "SyncPromoLayoutExperiment"; 23 const char kLayoutExperimentTrialName[] = "SyncPromoLayoutExperiment";
24 24
25 enum LayoutExperimentType { 25 enum LayoutExperimentType {
26 LAYOUT_EXPERIMENT_DEFAULT = 0, 26 LAYOUT_EXPERIMENT_DEFAULT = 0,
27 LAYOUT_EXPERIMENT_DEVICES, 27 LAYOUT_EXPERIMENT_DEVICES,
28 LAYOUT_EXPERIMENT_VERBOSE, 28 LAYOUT_EXPERIMENT_VERBOSE,
29 LAYOUT_EXPERIMENT_SIMPLE, 29 LAYOUT_EXPERIMENT_SIMPLE,
30 LAYOUT_EXPERIMENT_NONE, 30 LAYOUT_EXPERIMENT_NONE,
31 LAYOUT_EXPERIMENT_DIALOG,
31 LAYOUT_EXPERIMENT_BOUNDARY, 32 LAYOUT_EXPERIMENT_BOUNDARY,
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);
(...skipping 10 matching lines...) Expand all
51 if (brand == "GGRG" || brand == "CHCG") 52 if (brand == "GGRG" || brand == "CHCG")
52 *type = LAYOUT_EXPERIMENT_DEFAULT; 53 *type = LAYOUT_EXPERIMENT_DEFAULT;
53 else if (brand == "GGRH" || brand == "CHCH") 54 else if (brand == "GGRH" || brand == "CHCH")
54 *type = LAYOUT_EXPERIMENT_DEVICES; 55 *type = LAYOUT_EXPERIMENT_DEVICES;
55 else if (brand == "GGRI" || brand == "CHCI") 56 else if (brand == "GGRI" || brand == "CHCI")
56 *type = LAYOUT_EXPERIMENT_VERBOSE; 57 *type = LAYOUT_EXPERIMENT_VERBOSE;
57 else if (brand == "GGRJ" || brand == "CHCJ") 58 else if (brand == "GGRJ" || brand == "CHCJ")
58 *type = LAYOUT_EXPERIMENT_SIMPLE; 59 *type = LAYOUT_EXPERIMENT_SIMPLE;
59 else if (brand == "GGRL" || brand == "CHCL") 60 else if (brand == "GGRL" || brand == "CHCL")
60 *type = LAYOUT_EXPERIMENT_NONE; 61 *type = LAYOUT_EXPERIMENT_NONE;
62 else if (brand == "GGRK" || brand == "CHCK")
63 *type = LAYOUT_EXPERIMENT_DIALOG;
61 else 64 else
62 return false; 65 return false;
63 } else { 66 } else {
64 if (!base::FieldTrialList::TrialExists(kLayoutExperimentTrialName)) 67 if (!base::FieldTrialList::TrialExists(kLayoutExperimentTrialName))
65 return false; 68 return false;
66 int value = base::FieldTrialList::FindValue(kLayoutExperimentTrialName) - 69 int value = base::FieldTrialList::FindValue(kLayoutExperimentTrialName) -
67 base::FieldTrial::kDefaultGroupNumber; 70 base::FieldTrial::kDefaultGroupNumber;
68 *type = static_cast<LayoutExperimentType>(value); 71 *type = static_cast<LayoutExperimentType>(value);
69 } 72 }
70 73
71 return true; 74 return true;
72 } 75 }
73 76
74 } // namespace 77 } // namespace
75 78
76 namespace sync_promo_trial { 79 namespace sync_promo_trial {
77 80
78 void Activate() { 81 void Activate() {
79 DCHECK(!sync_promo_trial_initialized); 82 DCHECK(!sync_promo_trial_initialized);
80 sync_promo_trial_initialized = true; 83 sync_promo_trial_initialized = true;
81 84
82 // For stable builds we'll use brand codes to enroll uesrs into experiments. 85 // 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. 86 // For dev and beta we don't have brand codes so we randomly enroll users.
84 if (chrome::VersionInfo::GetChannel() != 87 if (chrome::VersionInfo::GetChannel() !=
85 chrome::VersionInfo::CHANNEL_STABLE) { 88 chrome::VersionInfo::CHANNEL_STABLE) {
86 // Create a field trial that expires in August 8, 2012. It contains 5 groups 89 // Create a field trial that expires in August 8, 2012. It contains 6 groups
87 // with each group having an equal chance of enrollment. 90 // with each group having an equal chance of enrollment.
88 scoped_refptr<base::FieldTrial> trial(new base::FieldTrial( 91 scoped_refptr<base::FieldTrial> trial(new base::FieldTrial(
89 kLayoutExperimentTrialName, 5, "default", 2012, 8, 1)); 92 kLayoutExperimentTrialName, 5, "default", 2012, 8, 1));
90 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) 93 if (base::FieldTrialList::IsOneTimeRandomizationEnabled())
91 trial->UseOneTimeRandomization(); 94 trial->UseOneTimeRandomization();
92 trial->AppendGroup("", 1); 95 trial->AppendGroup("", 1);
93 trial->AppendGroup("", 1); 96 trial->AppendGroup("", 1);
94 trial->AppendGroup("", 1); 97 trial->AppendGroup("", 1);
95 trial->AppendGroup("", 1); 98 trial->AppendGroup("", 1);
99 trial->AppendGroup("", 1);
96 } 100 }
97 } 101 }
98 102
99 StartupOverride GetStartupOverrideForCurrentTrial() { 103 StartupOverride GetStartupOverrideForCurrentTrial() {
100 DCHECK(sync_promo_trial_initialized); 104 DCHECK(sync_promo_trial_initialized);
101 105
102 LayoutExperimentType type; 106 LayoutExperimentType type;
103 if (GetActiveLayoutExperiment(&type)) { 107 if (GetActiveLayoutExperiment(&type)) {
104 return type == LAYOUT_EXPERIMENT_NONE ? STARTUP_OVERRIDE_HIDE : 108 return type == LAYOUT_EXPERIMENT_NONE ? STARTUP_OVERRIDE_HIDE :
105 STARTUP_OVERRIDE_SHOW; 109 STARTUP_OVERRIDE_SHOW;
(...skipping 30 matching lines...) Expand all
136 DCHECK(SyncPromoUI::HasShownPromoAtStartup(Profile::FromWebUI(web_ui))); 140 DCHECK(SyncPromoUI::HasShownPromoAtStartup(Profile::FromWebUI(web_ui)));
137 UMA_HISTOGRAM_ENUMERATION("SyncPromo.SignedInWithLayoutExpAtStartup", 141 UMA_HISTOGRAM_ENUMERATION("SyncPromo.SignedInWithLayoutExpAtStartup",
138 type, LAYOUT_EXPERIMENT_BOUNDARY); 142 type, LAYOUT_EXPERIMENT_BOUNDARY);
139 } else { 143 } else {
140 UMA_HISTOGRAM_ENUMERATION("SyncPromo.SignedInWithLayoutExp", 144 UMA_HISTOGRAM_ENUMERATION("SyncPromo.SignedInWithLayoutExp",
141 type, LAYOUT_EXPERIMENT_BOUNDARY); 145 type, LAYOUT_EXPERIMENT_BOUNDARY);
142 } 146 }
143 } 147 }
144 } 148 }
145 149
146 bool GetSyncPromoVersionForCurrentTrial(int* version) { 150 bool GetSyncPromoVersionForCurrentTrial(SyncPromoUI::Version* version) {
147 DCHECK(sync_promo_trial_initialized); 151 DCHECK(sync_promo_trial_initialized);
148 DCHECK(version); 152 DCHECK(version);
149 153
150 LayoutExperimentType type; 154 LayoutExperimentType type;
151 if (!GetActiveLayoutExperiment(&type)) 155 if (!GetActiveLayoutExperiment(&type))
152 return false; 156 return false;
153 157
154 switch (type) { 158 switch (type) {
155 case LAYOUT_EXPERIMENT_DEFAULT: 159 case LAYOUT_EXPERIMENT_DEFAULT:
156 *version = 0; 160 *version = SyncPromoUI::VERSION_DEFAULT;
157 return true; 161 return true;
158 case LAYOUT_EXPERIMENT_DEVICES: 162 case LAYOUT_EXPERIMENT_DEVICES:
159 *version = 1; 163 *version = SyncPromoUI::VERSION_DEVICES;
160 return true; 164 return true;
161 case LAYOUT_EXPERIMENT_VERBOSE: 165 case LAYOUT_EXPERIMENT_VERBOSE:
162 *version = 2; 166 *version = SyncPromoUI::VERSION_VERBOSE;
163 return true; 167 return true;
164 case LAYOUT_EXPERIMENT_SIMPLE: 168 case LAYOUT_EXPERIMENT_SIMPLE:
165 *version = 3; 169 *version = SyncPromoUI::VERSION_SIMPLE;
170 return true;
171 case LAYOUT_EXPERIMENT_DIALOG:
172 *version = SyncPromoUI::VERSION_DIALOG;
166 return true; 173 return true;
167 default: 174 default:
168 return false; 175 return false;
169 } 176 }
170 } 177 }
171 178
172 } // namespace sync_promo_trial 179 } // namespace sync_promo_trial
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_promo/sync_promo_trial.h ('k') | chrome/browser/ui/webui/sync_promo/sync_promo_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698