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

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 nits and removed NTP cache stuff 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";
23
24 }
25
26 // static
27 void SyncPromoTrial::Activate() {
28 // The end date (February 21, 2012) is approximately 2 weeks into M17 stable.
29 scoped_refptr<base::FieldTrial> trial(
30 new base::FieldTrial(kSyncPromoMsgTrialName, 1000, "MsgA", 2012, 2, 21));
31 g_sync_promo_experiment_a = base::FieldTrial::kDefaultGroupNumber;
32
33 // Try to give the user a consistent experience, if possible.
34 if (base::FieldTrialList::IsOneTimeRandomizationEnabled())
35 trial->UseOneTimeRandomization();
36
37 // Each group has probability 0.5%, leaving the control with 98.5%.
38 g_sync_promo_experiment_b = trial->AppendGroup("MsgB", 50);
39 g_sync_promo_experiment_c = trial->AppendGroup("MsgC", 50);
40 g_sync_promo_experiment_d = trial->AppendGroup("MsgD", 50);
41 }
42
43 // static
44 bool SyncPromoTrial::IsExperimentActive() {
45 return base::FieldTrialList::FindValue(kSyncPromoMsgTrialName) !=
46 base::FieldTrial::kNotFinalized;
47 }
48
49 // static
50 SyncPromoTrial::Group SyncPromoTrial::GetGroup() {
51 // Promo message A is also the default value, so display it if there is no
52 // active experiment.
53 if (!IsExperimentActive())
54 return PROMO_MSG_A;
55
56 const int group = base::FieldTrialList::FindValue(kSyncPromoMsgTrialName);
57 if (group == g_sync_promo_experiment_a)
58 return PROMO_MSG_A;
59 else if (group == g_sync_promo_experiment_b)
60 return PROMO_MSG_B;
61 else if (group == g_sync_promo_experiment_c)
62 return PROMO_MSG_C;
63 else if (group == g_sync_promo_experiment_d)
64 return PROMO_MSG_D;
65
66 NOTREACHED();
67 return PROMO_MSG_A;
68 }
69
70 // static
71 int SyncPromoTrial::GetMessageBodyResID() {
72 // Note that GetGroup and the switch will take care of the !IsExperimentActive
73 // case for us.
74 Group group = GetGroup();
75 switch (group) {
76 case PROMO_MSG_A:
77 return IDS_SYNC_PROMO_MESSAGE_BODY_A;
78 case PROMO_MSG_B:
79 return IDS_SYNC_PROMO_MESSAGE_BODY_B;
80 case PROMO_MSG_C:
81 return IDS_SYNC_PROMO_MESSAGE_BODY_C;
82 case PROMO_MSG_D:
83 return IDS_SYNC_PROMO_MESSAGE_BODY_D;
84 case PROMO_MSG_MAX:
85 break;
86 }
87
88 NOTREACHED();
89 return IDS_SYNC_PROMO_MESSAGE_BODY_A;
90 }
91
92 // static
93 void SyncPromoTrial::RecordUserSawMessage() {
94 DCHECK(IsExperimentActive());
95 UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageDisplayed",
96 GetGroup(),
97 PROMO_MSG_MAX);
98 }
99
100 // static
101 void SyncPromoTrial::RecordUserSignedIn() {
102 DCHECK(IsExperimentActive());
103 UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageOnSignIn",
104 GetGroup(),
105 PROMO_MSG_MAX);
106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698