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

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

Issue 8689006: Create a field test for sync sign in promo strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressed sail's comments 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/sync_promo_trial.h"
6
7 #include "base/metrics/field_trial.h"
8 #include "chrome/browser/metrics/metrics_service.h"
9 #include "chrome/browser/prefs/pref_service.h"
10 #include "grit/generated_resources.h"
11
12 namespace {
13
14 // 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
16 // file for what these groups represent.
17 int g_sync_promo_experiment_a = 0;
18 int g_sync_promo_experiment_b = 0;
19 int g_sync_promo_experiment_c = 0;
20 int g_sync_promo_experiment_d = 0;
21
22 const char* kSyncPromoMsgTrialName = "SyncPromoMsg";
sail 2011/11/28 20:33:09 const char kSyncPromoMsgTrialName[] = ...?
SteveT 2011/11/28 20:40:59 Done.
23
24 }
25
26 // static
27 void SyncPromoTrial::Activate() {
28 // TODO(stevet): Verify with jeffreyc that this date (March 12, 2012) is
29 // approx 2 weeks into M17 stable.
30 scoped_refptr<base::FieldTrial> trial(
31 new base::FieldTrial(kSyncPromoMsgTrialName, 1000, "MsgA", 2012, 3, 12));
32 g_sync_promo_experiment_a = base::FieldTrial::kDefaultGroupNumber;
33
34 // Try to give the user a consistent experience, if possible.
35 if (base::FieldTrialList::IsOneTimeRandomizationEnabled())
36 trial->UseOneTimeRandomization();
37
38 // Each group has probability 0.5%, leaving the control with 98.5%.
39 g_sync_promo_experiment_b = trial->AppendGroup("MsgB", 50);
40 g_sync_promo_experiment_c = trial->AppendGroup("MsgC", 50);
41 g_sync_promo_experiment_d = trial->AppendGroup("MsgD", 50);
42 }
43
44 // static
45 bool SyncPromoTrial::IsExperimentActive() {
46 return base::FieldTrialList::FindValue(kSyncPromoMsgTrialName) !=
47 base::FieldTrial::kNotFinalized;
48 }
49
50 // static
51 SyncPromoTrial::Group SyncPromoTrial::GetGroup() {
52 // Promo message A is also the default value, so display it if there is no
53 // active experiment.
54 if (!IsExperimentActive())
55 return PROMO_MSG_A;
56
57 const int group = base::FieldTrialList::FindValue(kSyncPromoMsgTrialName);
58 if (group == g_sync_promo_experiment_a)
59 return PROMO_MSG_A;
60 else if (group == g_sync_promo_experiment_b)
61 return PROMO_MSG_B;
62 else if (group == g_sync_promo_experiment_c)
63 return PROMO_MSG_C;
64 else if (group == g_sync_promo_experiment_d)
65 return PROMO_MSG_D;
66
67 NOTREACHED();
68 return PROMO_MSG_A;
69 }
70
71 // static
72 int SyncPromoTrial::GetMessageBodyResID() {
73 // Note that GetGroup and the switch will take care of the !IsExperimentActive
74 // case for us.
75 Group group = GetGroup();
76 switch (group) {
77 case PROMO_MSG_A:
78 return IDS_SYNC_PROMO_MESSAGE_BODY_A;
79 case PROMO_MSG_B:
80 return IDS_SYNC_PROMO_MESSAGE_BODY_B;
81 case PROMO_MSG_C:
82 return IDS_SYNC_PROMO_MESSAGE_BODY_C;
83 case PROMO_MSG_D:
84 return IDS_SYNC_PROMO_MESSAGE_BODY_D;
85 }
86
87 NOTREACHED();
88 return IDS_SYNC_PROMO_MESSAGE_BODY_A;
89 }
90
91 // static
92 void SyncPromoTrial::RecordUserSawMessage() {
93 DCHECK(IsExperimentActive());
94 UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageDisplayed",
95 GetGroup(),
96 PROMO_MSG_MAX);
97 }
98
99 // static
100 void SyncPromoTrial::RecordUserSignedIn() {
101 DCHECK(IsExperimentActive());
102 UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageOnSignIn",
103 GetGroup(),
104 PROMO_MSG_MAX);
105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698