Index: chrome/browser/ui/webui/sync_promo_trial.cc |
diff --git a/chrome/browser/ui/webui/sync_promo_trial.cc b/chrome/browser/ui/webui/sync_promo_trial.cc |
index 4003144b5b1baba172d233dd0fc6230299497c33..14b3a95bfeb260c4635184c8c19c77b2988f0298 100644 |
--- a/chrome/browser/ui/webui/sync_promo_trial.cc |
+++ b/chrome/browser/ui/webui/sync_promo_trial.cc |
@@ -5,6 +5,8 @@ |
#include "chrome/browser/ui/webui/sync_promo_trial.h" |
#include "base/metrics/field_trial.h" |
+#include "base/string_util.h" |
+#include "chrome/browser/google/google_util.h" |
#include "chrome/browser/metrics/metrics_service.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "grit/generated_resources.h" |
@@ -19,8 +21,14 @@ int g_sync_promo_experiment_b = 0; |
int g_sync_promo_experiment_c = 0; |
int g_sync_promo_experiment_d = 0; |
+const char kSyncPromoEnabledTrialName[] = "SyncPromoEnabled"; |
const char kSyncPromoMsgTrialName[] = "SyncPromoMsg"; |
+const char kSyncPromoEnabledWithApps[] = "EnabledWithDefaultApps"; |
+const char kSyncPromoEnabledWithoutApps[] = "EnabledWithoutDefaultApps"; |
+const char kSyncPromoDisabledWithApps[] = "DisabledWithDefaultApps"; |
+const char kSyncPromoDisabledWithoutApps[] = "DisabledWithoutDefaultApps"; |
+ |
void Activate() { |
// The end date (February 21, 2012) is approximately 2 weeks into M17 stable. |
scoped_refptr<base::FieldTrial> trial( |
@@ -35,6 +43,28 @@ void Activate() { |
g_sync_promo_experiment_b = trial->AppendGroup("MsgB", 50); |
g_sync_promo_experiment_c = trial->AppendGroup("MsgC", 50); |
g_sync_promo_experiment_d = trial->AppendGroup("MsgD", 50); |
+ |
+ // Determine whether we should show the sync promo via brand code. |
+ std::string brand; |
+ google_util::GetBrand(&brand); |
+ |
+ brand = "ECSB"; |
+ 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.
|
+ |
+ // Create a field trial based on the brand code. |
+ if (LowerCaseEqualsASCII(brand, "ecba")) { |
+ base::FieldTrialList::CreateFieldTrial(kSyncPromoEnabledTrialName, |
+ kSyncPromoEnabledWithApps); |
+ } else if (LowerCaseEqualsASCII(brand, "ecsa")) { |
+ base::FieldTrialList::CreateFieldTrial(kSyncPromoEnabledTrialName, |
+ kSyncPromoEnabledWithoutApps); |
+ } else if (LowerCaseEqualsASCII(brand, "ecsb")) { |
+ base::FieldTrialList::CreateFieldTrial(kSyncPromoEnabledTrialName, |
+ kSyncPromoDisabledWithApps); |
+ } else if (LowerCaseEqualsASCII(brand, "ecbb")) { |
+ base::FieldTrialList::CreateFieldTrial(kSyncPromoEnabledTrialName, |
+ kSyncPromoDisabledWithoutApps); |
+ } |
} |
bool IsExperimentActive() { |
@@ -42,6 +72,10 @@ bool IsExperimentActive() { |
base::FieldTrial::kNotFinalized; |
} |
+bool IsPartOfBrandTrialToEnable() { |
+ return base::FieldTrialList::TrialExists(kSyncPromoEnabledTrialName); |
+} |
+ |
Group GetGroup() { |
// Promo message A is also the default value, so display it if there is no |
// active experiment. |
@@ -62,6 +96,26 @@ Group GetGroup() { |
return PROMO_MSG_A; |
} |
+int GetSyncPromoAndDefaultAppsCombination() { |
+ // This should never happen, but it doesn't hurt to CHECK(). |
+ DCHECK(IsPartOfBrandTrialToEnable()); |
+ |
+ std::string group = |
+ base::FieldTrialList::Find(kSyncPromoEnabledTrialName)->group_name(); |
+ |
+ if (group == kSyncPromoEnabledWithApps) |
+ return WITH_SYNC_PROMO_WITH_DEFAULT_APPS; |
+ else if (group == kSyncPromoEnabledWithoutApps) |
+ return WITH_SYNC_PROMO_WITHOUT_DEFAULT_APPS; |
+ else if (group == kSyncPromoDisabledWithApps) |
+ return WITHOUT_SYNC_PROMO_WITH_DEFAULT_APPS; |
+ else if (group == kSyncPromoDisabledWithoutApps) |
+ return WITH_SYNC_PROMO_WITH_DEFAULT_APPS; |
+ |
+ NOTREACHED(); |
+ return SYNC_PROMO_AND_DEFAULT_APPS_BOUNDARY + 1; |
+} |
+ |
int GetMessageBodyResID() { |
// Note that GetGroup and the switch will take care of the !IsExperimentActive |
// case for us. |
@@ -97,4 +151,19 @@ void RecordUserSignedIn() { |
PROMO_MSG_MAX); |
} |
+void RecordUserSignedInWithTrialBrand() { |
+ DCHECK(IsPartOfBrandTrialToEnable()); |
+ UMA_HISTOGRAM_ENUMERATION("SyncPromo.SignedInWithBrand", |
+ GetSyncPromoAndDefaultAppsCombination(), |
+ 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.
|
+} |
+ |
+bool ShouldShowAtStartupBasedOnBrand() { |
+ DCHECK(IsPartOfBrandTrialToEnable()); |
+ std::string name = |
+ base::FieldTrialList::Find(kSyncPromoEnabledTrialName)->group_name(); |
+ return name == kSyncPromoEnabledWithApps || |
+ name == kSyncPromoEnabledWithoutApps; |
+} |
+ |
} // namespace sync_promo_trial |