Index: chrome/browser/ui/webui/sync_promo_trial.cc |
=================================================================== |
--- chrome/browser/ui/webui/sync_promo_trial.cc (revision 0) |
+++ chrome/browser/ui/webui/sync_promo_trial.cc (revision 0) |
@@ -0,0 +1,84 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/ui/webui/sync_promo_trial.h" |
+ |
+#include "base/metrics/field_trial.h" |
+#include "chrome/browser/metrics/metrics_service.h" |
+#include "chrome/browser/prefs/pref_service.h" |
+ |
+namespace { |
+ |
+// Field trial IDs of the control and experiment groups. Though they are not |
+// literally "const", they are set only once, in Activate() below. See the .h |
+// file for what these groups represent. |
+int g_sync_promo_experiment_a = 0; |
+int g_sync_promo_experiment_b = 0; |
+int g_sync_promo_experiment_c = 0; |
+int g_sync_promo_experiment_d = 0; |
+ |
+const char* kSyncPromoMsgTrialName = "SyncPromoMsg"; |
+ |
+} |
+ |
+// static |
+void SyncPromoTrial::Activate() { |
+ // TODO(stevet): Verify with jeffreyc that this date (March 12, 2012) is |
+ // approx 2 weeks into M17 stable. |
+ scoped_refptr<base::FieldTrial> trial( |
+ new base::FieldTrial(kSyncPromoMsgTrialName, 1000, "MsgA", 2012, 3, 12)); |
+ g_sync_promo_experiment_a = base::FieldTrial::kDefaultGroupNumber; |
+ |
+ // Try to give the user a consistent experience, if possible. |
+ if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) |
+ trial->UseOneTimeRandomization(); |
+ |
+ // Each group has probability 0.5%, leaving the control with 98.5%. |
+ g_sync_promo_experiment_b = trial->AppendGroup("MsgB", 5); |
+ g_sync_promo_experiment_c = trial->AppendGroup("MsgC", 5); |
+ g_sync_promo_experiment_d = trial->AppendGroup("MsgD", 5); |
+} |
+ |
+// static |
+bool SyncPromoTrial::IsExperimentActive() { |
+ return base::FieldTrialList::FindValue(kSyncPromoMsgTrialName) != |
+ base::FieldTrial::kNotFinalized; |
+} |
+ |
+// static |
+SyncPromoTrial::Group SyncPromoTrial::GetGroup() { |
+ // Promo message A is also the default value, so display it if there is no |
+ // active experiment. |
+ if (!IsExperimentActive()) |
+ return PROMO_MSG_A; |
+ |
+ const int group = base::FieldTrialList::FindValue(kSyncPromoMsgTrialName); |
+ if (group == g_sync_promo_experiment_a) |
+ return PROMO_MSG_A; |
+ else if (group == g_sync_promo_experiment_b) |
+ return PROMO_MSG_B; |
+ else if (group == g_sync_promo_experiment_c) |
+ return PROMO_MSG_C; |
+ else if (group == g_sync_promo_experiment_d) |
+ return PROMO_MSG_D; |
+ |
+ NOTREACHED(); |
+ return PROMO_MSG_A; |
+} |
+ |
+// static |
+void SyncPromoTrial::RecordUserSawMessage() { |
+ DCHECK(IsExperimentActive()); |
+ UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageDisplayed", |
+ GetGroup(), |
+ PROMO_MSG_MAX); |
+} |
+ |
+// static |
+void SyncPromoTrial::RecordUserSignedIn() { |
+ DCHECK(IsExperimentActive()); |
+ UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageOnSignIn", |
+ GetGroup(), |
+ PROMO_MSG_MAX); |
+} |
Property changes on: chrome/browser/ui/webui/sync_promo_trial.cc |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |