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

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

Issue 8933003: [Sync Promo UI] Changing sync promo to honor brand codes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years 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
« no previous file with comments | « chrome/browser/ui/webui/sync_promo_trial.h ('k') | chrome/browser/ui/webui/sync_promo_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_trial.h" 5 #include "chrome/browser/ui/webui/sync_promo_trial.h"
6 6
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 #include "base/string_util.h"
9 #include "chrome/browser/google/google_util.h"
8 #include "chrome/browser/metrics/metrics_service.h" 10 #include "chrome/browser/metrics/metrics_service.h"
9 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
10 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
11 13
12 namespace sync_promo_trial { 14 namespace sync_promo_trial {
13 15
14 // Field trial IDs of the control and experiment groups. Though they are not 16 // Field trial IDs of the control and experiment groups. Though they are not
15 // literally "const", they are set only once, in Activate() below. See the .h 17 // literally "const", they are set only once, in Activate() below. See the .h
16 // file for what these groups represent. 18 // file for what these groups represent.
17 int g_sync_promo_experiment_a = 0; 19 int g_sync_promo_experiment_a = 0;
18 int g_sync_promo_experiment_b = 0; 20 int g_sync_promo_experiment_b = 0;
19 int g_sync_promo_experiment_c = 0; 21 int g_sync_promo_experiment_c = 0;
20 int g_sync_promo_experiment_d = 0; 22 int g_sync_promo_experiment_d = 0;
21 23
24 const char kSyncPromoEnabledTrialName[] = "SyncPromoEnabled";
22 const char kSyncPromoMsgTrialName[] = "SyncPromoMsg"; 25 const char kSyncPromoMsgTrialName[] = "SyncPromoMsg";
23 26
27 const char kSyncPromoEnabledWithApps[] = "EnabledWithDefaultApps";
28 const char kSyncPromoEnabledWithoutApps[] = "EnabledWithoutDefaultApps";
29 const char kSyncPromoDisabledWithApps[] = "DisabledWithDefaultApps";
30 const char kSyncPromoDisabledWithoutApps[] = "DisabledWithoutDefaultApps";
31
24 void Activate() { 32 void Activate() {
25 // The end date (February 21, 2012) is approximately 2 weeks into M17 stable. 33 // The end date (February 21, 2012) is approximately 2 weeks into M17 stable.
26 scoped_refptr<base::FieldTrial> trial( 34 scoped_refptr<base::FieldTrial> trial(
27 new base::FieldTrial(kSyncPromoMsgTrialName, 1000, "MsgA", 2012, 2, 21)); 35 new base::FieldTrial(kSyncPromoMsgTrialName, 1000, "MsgA", 2012, 2, 21));
28 g_sync_promo_experiment_a = base::FieldTrial::kDefaultGroupNumber; 36 g_sync_promo_experiment_a = base::FieldTrial::kDefaultGroupNumber;
29 37
30 // Try to give the user a consistent experience, if possible. 38 // Try to give the user a consistent experience, if possible.
31 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) 39 if (base::FieldTrialList::IsOneTimeRandomizationEnabled())
32 trial->UseOneTimeRandomization(); 40 trial->UseOneTimeRandomization();
33 41
34 // Each group has probability 0.5%, leaving the control with 98.5%. 42 // Each group has probability 0.5%, leaving the control with 98.5%.
35 g_sync_promo_experiment_b = trial->AppendGroup("MsgB", 50); 43 g_sync_promo_experiment_b = trial->AppendGroup("MsgB", 50);
36 g_sync_promo_experiment_c = trial->AppendGroup("MsgC", 50); 44 g_sync_promo_experiment_c = trial->AppendGroup("MsgC", 50);
37 g_sync_promo_experiment_d = trial->AppendGroup("MsgD", 50); 45 g_sync_promo_experiment_d = trial->AppendGroup("MsgD", 50);
46
47 // Determine whether we should show the sync promo via brand code.
48 std::string brand;
49 google_util::GetBrand(&brand);
50
51 brand = "ECSB";
52 LOG(ERROR) << "brand: " << brand;
SteveT 2011/12/13 15:19:03 Don't forget to clean this up at the end of the re
Roger Tawa OOO till Jul 10th 2011/12/13 16:00:53 See GetBrand() for details, but for linux, the bra
Dan Beam 2011/12/14 00:16:54 Done.
53
54 // Create a field trial based on the brand code.
55 if (LowerCaseEqualsASCII(brand, "ecba")) {
56 base::FieldTrialList::CreateFieldTrial(kSyncPromoEnabledTrialName,
57 kSyncPromoEnabledWithApps);
58 } else if (LowerCaseEqualsASCII(brand, "ecsa")) {
59 base::FieldTrialList::CreateFieldTrial(kSyncPromoEnabledTrialName,
60 kSyncPromoEnabledWithoutApps);
61 } else if (LowerCaseEqualsASCII(brand, "ecsb")) {
62 base::FieldTrialList::CreateFieldTrial(kSyncPromoEnabledTrialName,
63 kSyncPromoDisabledWithApps);
64 } else if (LowerCaseEqualsASCII(brand, "ecbb")) {
65 base::FieldTrialList::CreateFieldTrial(kSyncPromoEnabledTrialName,
66 kSyncPromoDisabledWithoutApps);
67 }
38 } 68 }
39 69
40 bool IsExperimentActive() { 70 bool IsExperimentActive() {
41 return base::FieldTrialList::FindValue(kSyncPromoMsgTrialName) != 71 return base::FieldTrialList::FindValue(kSyncPromoMsgTrialName) !=
42 base::FieldTrial::kNotFinalized; 72 base::FieldTrial::kNotFinalized;
43 } 73 }
44 74
75 bool IsPartOfBrandTrialToEnable() {
76 return base::FieldTrialList::TrialExists(kSyncPromoEnabledTrialName);
77 }
78
45 Group GetGroup() { 79 Group GetGroup() {
46 // Promo message A is also the default value, so display it if there is no 80 // Promo message A is also the default value, so display it if there is no
47 // active experiment. 81 // active experiment.
48 if (!IsExperimentActive()) 82 if (!IsExperimentActive())
49 return PROMO_MSG_A; 83 return PROMO_MSG_A;
50 84
51 const int group = base::FieldTrialList::FindValue(kSyncPromoMsgTrialName); 85 const int group = base::FieldTrialList::FindValue(kSyncPromoMsgTrialName);
52 if (group == g_sync_promo_experiment_a) 86 if (group == g_sync_promo_experiment_a)
53 return PROMO_MSG_A; 87 return PROMO_MSG_A;
54 else if (group == g_sync_promo_experiment_b) 88 else if (group == g_sync_promo_experiment_b)
55 return PROMO_MSG_B; 89 return PROMO_MSG_B;
56 else if (group == g_sync_promo_experiment_c) 90 else if (group == g_sync_promo_experiment_c)
57 return PROMO_MSG_C; 91 return PROMO_MSG_C;
58 else if (group == g_sync_promo_experiment_d) 92 else if (group == g_sync_promo_experiment_d)
59 return PROMO_MSG_D; 93 return PROMO_MSG_D;
60 94
61 NOTREACHED(); 95 NOTREACHED();
62 return PROMO_MSG_A; 96 return PROMO_MSG_A;
63 } 97 }
64 98
99 int GetSyncPromoAndDefaultAppsCombination() {
100 // This should never happen, but it doesn't hurt to CHECK().
101 DCHECK(IsPartOfBrandTrialToEnable());
102
103 std::string group =
104 base::FieldTrialList::Find(kSyncPromoEnabledTrialName)->group_name();
105
106 if (group == kSyncPromoEnabledWithApps)
107 return WITH_SYNC_PROMO_WITH_DEFAULT_APPS;
108 else if (group == kSyncPromoEnabledWithoutApps)
109 return WITH_SYNC_PROMO_WITHOUT_DEFAULT_APPS;
110 else if (group == kSyncPromoDisabledWithApps)
111 return WITHOUT_SYNC_PROMO_WITH_DEFAULT_APPS;
112 else if (group == kSyncPromoDisabledWithoutApps)
113 return WITH_SYNC_PROMO_WITH_DEFAULT_APPS;
114
115 NOTREACHED();
116 return SYNC_PROMO_AND_DEFAULT_APPS_BOUNDARY + 1;
117 }
118
65 int GetMessageBodyResID() { 119 int GetMessageBodyResID() {
66 // Note that GetGroup and the switch will take care of the !IsExperimentActive 120 // Note that GetGroup and the switch will take care of the !IsExperimentActive
67 // case for us. 121 // case for us.
68 Group group = GetGroup(); 122 Group group = GetGroup();
69 switch (group) { 123 switch (group) {
70 case PROMO_MSG_A: 124 case PROMO_MSG_A:
71 return IDS_SYNC_PROMO_MESSAGE_BODY_A; 125 return IDS_SYNC_PROMO_MESSAGE_BODY_A;
72 case PROMO_MSG_B: 126 case PROMO_MSG_B:
73 return IDS_SYNC_PROMO_MESSAGE_BODY_B; 127 return IDS_SYNC_PROMO_MESSAGE_BODY_B;
74 case PROMO_MSG_C: 128 case PROMO_MSG_C:
(...skipping 15 matching lines...) Expand all
90 PROMO_MSG_MAX); 144 PROMO_MSG_MAX);
91 } 145 }
92 146
93 void RecordUserSignedIn() { 147 void RecordUserSignedIn() {
94 DCHECK(IsExperimentActive()); 148 DCHECK(IsExperimentActive());
95 UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageOnSignIn", 149 UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageOnSignIn",
96 GetGroup(), 150 GetGroup(),
97 PROMO_MSG_MAX); 151 PROMO_MSG_MAX);
98 } 152 }
99 153
154 void RecordUserSignedInWithTrialBrand() {
155 DCHECK(IsPartOfBrandTrialToEnable());
156 UMA_HISTOGRAM_ENUMERATION("SyncPromo.SignedInWithBrand",
157 GetSyncPromoAndDefaultAppsCombination(),
158 SYNC_PROMO_AND_DEFAULT_APPS_BOUNDARY);
SteveT 2011/12/13 15:19:03 A couple questions/points about this UMA histogram
Dan Beam 2011/12/14 00:16:54 Done.
159 }
160
161 bool ShouldShowAtStartupBasedOnBrand() {
162 DCHECK(IsPartOfBrandTrialToEnable());
163 std::string name =
164 base::FieldTrialList::Find(kSyncPromoEnabledTrialName)->group_name();
165 return name == kSyncPromoEnabledWithApps ||
166 name == kSyncPromoEnabledWithoutApps;
167 }
168
100 } // namespace sync_promo_trial 169 } // namespace sync_promo_trial
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_promo_trial.h ('k') | chrome/browser/ui/webui/sync_promo_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698