summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-28 23:27:31 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-28 23:27:31 +0000
commit2cd52d0ff030ebe10537cc8fdc56a9cdafbdf1e8 (patch)
tree6f8115e2ef8f450ac926a93d3d561a28c26bfcca
parentecf392af2af30d532779569f51b5f3bc2292b267 (diff)
downloadchromium_src-2cd52d0ff030ebe10537cc8fdc56a9cdafbdf1e8.zip
chromium_src-2cd52d0ff030ebe10537cc8fdc56a9cdafbdf1e8.tar.gz
chromium_src-2cd52d0ff030ebe10537cc8fdc56a9cdafbdf1e8.tar.bz2
Enable sync promo layout experiments
This CL enables the new sync promo layouts using two different methods: - for stable channel the sync promo layout is determined by the brand code - for all other channels users are randomly assigned a layout using base::FieldTrial BUG=111292 TEST= Review URL: https://chromiumcodereview.appspot.com/9223007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119625 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd11
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc22
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_handler.h4
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc18
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc291
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_trial.h91
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc23
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler.cc11
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler2.cc10
9 files changed, 184 insertions, 297 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index fcabc40..f3599a2 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -11002,18 +11002,9 @@ Some features may be unavailable. Please check that the profile exists and you
<message name="IDS_SYNC_PROMO_MESSAGE_TITLE_SHORT" desc="A short sync promo message displayed under the title.">
Sign in to get your bookmarks, history, and settings on all your devices.
</message>
- <message name="IDS_SYNC_PROMO_MESSAGE_BODY_A" desc="The body of the sync promo message. This is experiment choice 0, and the control/default message.">
+ <message name="IDS_SYNC_PROMO_MESSAGE_BODY" desc="The body of the sync promo message.">
Get your bookmarks, history, and settings on all your devices.
</message>
- <message name="IDS_SYNC_PROMO_MESSAGE_BODY_B" desc="The body of the sync promo message. Experiment choice 1.">
- Back up your bookmarks, history, and settings online.
- </message>
- <message name="IDS_SYNC_PROMO_MESSAGE_BODY_C" desc="The body of the sync promo message. Experiment choice 2.">
- Sync your personalized browser features between all your devices.
- </message>
- <message name="IDS_SYNC_PROMO_MESSAGE_BODY_D" desc="The body of the sync promo message. Experiment choice 3.">
- Get your bookmarks, history, and settings on all your devices. Plus, you'll be automatically signed in to your favorite Google services.
- </message>
<message name="IDS_SYNC_PROMO_SKIP_BUTTON" desc="The link button at the bottom to let the user skip the sync promo.">
Skip for now
</message>
diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc
index 0ae59e1..0335566 100644
--- a/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc
@@ -127,12 +127,12 @@ void SyncPromoHandler::RegisterMessages() {
}
void SyncPromoHandler::ShowGaiaSuccessAndClose() {
- RecordExperimentOutcomesOnSignIn();
+ sync_promo_trial::RecordUserSignedIn(web_ui());
SyncSetupHandler::ShowGaiaSuccessAndClose();
}
void SyncPromoHandler::ShowGaiaSuccessAndSettingUp() {
- RecordExperimentOutcomesOnSignIn();
+ sync_promo_trial::RecordUserSignedIn(web_ui());
SyncSetupHandler::ShowGaiaSuccessAndSettingUp();
}
@@ -218,13 +218,6 @@ void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) {
}
void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) {
- // If the promo is also the Chrome launch page, we want to show the title and
- // log an event if we are running an experiment.
- bool is_launch_page = SyncPromoUI::GetIsLaunchPageForSyncPromoURL(
- web_ui()->GetWebContents()->GetURL());
- if (is_launch_page && sync_promo_trial::IsExperimentActive())
- sync_promo_trial::RecordUserSawMessage();
-
base::FundamentalValue version(SyncPromoUI::GetSyncPromoVersion());
web_ui()->CallJavascriptFunction("SyncSetupOverlay.showPromoVersion",
version);
@@ -295,17 +288,6 @@ int SyncPromoHandler::IncrementViewCountBy(size_t amount) {
return adjusted;
}
-void SyncPromoHandler::RecordExperimentOutcomesOnSignIn() {
- if (sync_promo_trial::IsExperimentActive())
- sync_promo_trial::RecordUserSignedIn();
- if (sync_promo_trial::IsPartOfBrandTrialToEnable()) {
- bool is_start_up = SyncPromoUI::GetIsLaunchPageForSyncPromoURL(
- web_ui()->GetWebContents()->GetURL());
- Profile* profile = Profile::FromWebUI(web_ui());
- sync_promo_trial::RecordUserSignedInWithTrialBrand(is_start_up, profile);
- }
-}
-
void SyncPromoHandler::RecordUserFlowAction(int action) {
// Send an enumeration to our single user flow histogram.
UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action,
diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_handler.h b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.h
index bd94ad9..7381126 100644
--- a/chrome/browser/ui/webui/sync_promo/sync_promo_handler.h
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.h
@@ -72,10 +72,6 @@ class SyncPromoHandler : public SyncSetupHandler {
// amount. Returns the new total view count.
int IncrementViewCountBy(size_t amount);
- // Record the outcome of the sync promo experiment (currently if the user
- // signs in to sync or not).
- void RecordExperimentOutcomesOnSignIn();
-
// Record a user's flow through the promo to our histogram in UMA.
void RecordUserFlowAction(int action);
diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc
index 9dbdbb1..6e96dab 100644
--- a/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc
@@ -57,13 +57,6 @@ static bool IsValidUserFlowAction(int action) {
action == SYNC_PROMO_LEFT_DURING_THROBBER;
}
-static void RecordExperimentOutcomesOnSignIn() {
- if (sync_promo_trial::IsExperimentActive())
- sync_promo_trial::RecordUserSignedIn();
- if (sync_promo_trial::IsPartOfBrandTrialToEnable())
- sync_promo_trial::RecordUserSignedInWithTrialBrand();
-}
-
} // namespace
namespace options2 {
@@ -134,12 +127,12 @@ void SyncPromoHandler2::RegisterMessages() {
}
void SyncPromoHandler2::ShowGaiaSuccessAndClose() {
- RecordExperimentOutcomesOnSignIn();
+ sync_promo_trial::RecordUserSignedIn(web_ui());
SyncSetupHandler2::ShowGaiaSuccessAndClose();
}
void SyncPromoHandler2::ShowGaiaSuccessAndSettingUp() {
- RecordExperimentOutcomesOnSignIn();
+ sync_promo_trial::RecordUserSignedIn(web_ui());
SyncSetupHandler2::ShowGaiaSuccessAndSettingUp();
}
@@ -221,13 +214,6 @@ void SyncPromoHandler2::HandleCloseSyncPromo(const base::ListValue* args) {
}
void SyncPromoHandler2::HandleInitializeSyncPromo(const base::ListValue* args) {
- // If the promo is also the Chrome launch page, we want to show the title and
- // log an event if we are running an experiment.
- bool is_launch_page = SyncPromoUI::GetIsLaunchPageForSyncPromoURL(
- web_ui_->tab_contents()->GetURL());
- if (is_launch_page && sync_promo_trial::IsExperimentActive())
- sync_promo_trial::RecordUserSawMessage();
-
base::FundamentalValue version(SyncPromoUI::GetSyncPromoVersion());
web_ui_->CallJavascriptFunction("SyncSetupOverlay.showPromoVersion",
version);
diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc
index cd34c3f..e00caf5 100644
--- a/chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc
@@ -1,187 +1,172 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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/sync_promo_trial.h"
+#include "base/command_line.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 "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/chrome_version_info.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui.h"
#include "grit/generated_resources.h"
-namespace sync_promo_trial {
-
-// 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 kSyncPromoEnabledTrialName[] = "SyncPromoEnabled";
-const char kSyncPromoMsgTrialName[] = "SyncPromoMsg";
-
-const char kSyncPromoEnabledWithApps[] = "EnabledWithDefaultApps";
-const char kSyncPromoEnabledWithoutApps[] = "EnabledWithoutDefaultApps";
-const char kSyncPromoDisabledWithoutAppsA[] = "DisabledWithoutDefaultAppsA";
-const char kSyncPromoDisabledWithoutAppsB[] = "DisabledWithoutDefaultAppsB";
-
-void Activate() {
- // The end date (February 21, 2012) is approximately 2 weeks into M17 stable.
- scoped_refptr<base::FieldTrial> trial(
- new base::FieldTrial(kSyncPromoMsgTrialName, 1000, "MsgA", 2012, 2, 21));
- 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", 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);
-
- // 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,
- kSyncPromoDisabledWithoutAppsA);
- } else if (LowerCaseEqualsASCII(brand, "ecbb")) {
- base::FieldTrialList::CreateFieldTrial(kSyncPromoEnabledTrialName,
- kSyncPromoDisabledWithoutAppsB);
+namespace {
+
+const char kLayoutExperimentTrialName[] = "SyncPromoLayoutExperiment";
+
+enum LayoutExperimentType {
+ LAYOUT_EXPERIMENT_DEFAULT = 0,
+ LAYOUT_EXPERIMENT_DEVICES,
+ LAYOUT_EXPERIMENT_VERBOSE,
+ LAYOUT_EXPERIMENT_SIMPLE,
+ LAYOUT_EXPERIMENT_NONE,
+ LAYOUT_EXPERIMENT_BOUNDARY,
+};
+
+// Flag to make sure sync_promo_trial::Activate() has been called.
+bool sync_promo_trial_initialized;
+
+// Checks if a sync promo layout experiment is active. If it is active then the
+// layout type is return in |type|.
+bool GetActiveLayoutExperiment(LayoutExperimentType* type) {
+ DCHECK(type);
+
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSyncPromoVersion))
+ return false;
+
+ if (chrome::VersionInfo::GetChannel() ==
+ chrome::VersionInfo::CHANNEL_STABLE) {
+ std::string brand;
+ if (!google_util::GetBrand(&brand))
+ return false;
+
+ if (brand == "GGRG" || brand == "CHCG")
+ *type = LAYOUT_EXPERIMENT_DEFAULT;
+ else if (brand == "GGRH" || brand == "CHCH")
+ *type = LAYOUT_EXPERIMENT_DEVICES;
+ else if (brand == "GGRI" || brand == "CHCI")
+ *type = LAYOUT_EXPERIMENT_VERBOSE;
+ else if (brand == "GGRJ" || brand == "CHCJ")
+ *type = LAYOUT_EXPERIMENT_SIMPLE;
+ else if (brand == "GGRL" || brand == "CHCL")
+ *type = LAYOUT_EXPERIMENT_NONE;
+ else
+ return false;
+ } else {
+ if (!base::FieldTrialList::TrialExists(kLayoutExperimentTrialName))
+ return false;
+ int value = base::FieldTrialList::FindValue(kLayoutExperimentTrialName) -
+ base::FieldTrial::kDefaultGroupNumber;
+ *type = static_cast<LayoutExperimentType>(value);
}
-}
-
-bool IsExperimentActive() {
- return base::FieldTrialList::FindValue(kSyncPromoMsgTrialName) !=
- 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.
- 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;
+ return true;
}
-int GetSyncPromoBrandUMABucketFromGroup() {
- DCHECK(IsPartOfBrandTrialToEnable());
+} // namespace
- 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 == kSyncPromoDisabledWithoutAppsA)
- return WITHOUT_SYNC_PROMO_WITHOUT_DEFAULT_APPS_A;
- else if (group == kSyncPromoDisabledWithoutAppsB)
- return WITHOUT_SYNC_PROMO_WITHOUT_DEFAULT_APPS_B;
-
- NOTREACHED();
- return SYNC_PROMO_AND_DEFAULT_APPS_BOUNDARY + 1;
-}
+namespace sync_promo_trial {
-int GetMessageBodyResID() {
- // Note that GetGroup and the switch will take care of the !IsExperimentActive
- // case for us.
- Group group = GetGroup();
- switch (group) {
- case PROMO_MSG_A:
- return IDS_SYNC_PROMO_MESSAGE_BODY_A;
- case PROMO_MSG_B:
- return IDS_SYNC_PROMO_MESSAGE_BODY_B;
- case PROMO_MSG_C:
- return IDS_SYNC_PROMO_MESSAGE_BODY_C;
- case PROMO_MSG_D:
- return IDS_SYNC_PROMO_MESSAGE_BODY_D;
- case PROMO_MSG_MAX:
- break;
+void Activate() {
+ DCHECK(!sync_promo_trial_initialized);
+ sync_promo_trial_initialized = true;
+
+ // For stable builds we'll use brand codes to enroll uesrs into experiments.
+ // For dev and beta we don't have brand codes so we randomly enroll users.
+ if (chrome::VersionInfo::GetChannel() !=
+ chrome::VersionInfo::CHANNEL_STABLE) {
+ // Create a field trial that expires in August 8, 2012. It contains 5 groups
+ // with each group having an equal chance of enrollment.
+ scoped_refptr<base::FieldTrial> trial(new base::FieldTrial(
+ kLayoutExperimentTrialName, 5, "default", 2012, 8, 1));
+ if (base::FieldTrialList::IsOneTimeRandomizationEnabled())
+ trial->UseOneTimeRandomization();
+ trial->AppendGroup("", 1);
+ trial->AppendGroup("", 1);
+ trial->AppendGroup("", 1);
+ trial->AppendGroup("", 1);
}
-
- NOTREACHED();
- return IDS_SYNC_PROMO_MESSAGE_BODY_A;
}
-void RecordUserSawMessage() {
- DCHECK(IsExperimentActive());
- UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageDisplayed",
- GetGroup(),
- PROMO_MSG_MAX);
-}
+StartupOverride GetStartupOverrideForCurrentTrial() {
+ DCHECK(sync_promo_trial_initialized);
-void RecordUserShownPromoWithTrialBrand(bool is_at_startup, Profile* profile) {
- DCHECK(IsPartOfBrandTrialToEnable());
- if (is_at_startup) {
- DCHECK(SyncPromoUI::HasShownPromoAtStartup(profile));
- UMA_HISTOGRAM_ENUMERATION("SyncPromo.ShownPromoWithBrandAtStartup",
- GetSyncPromoBrandUMABucketFromGroup(),
- SYNC_PROMO_AND_DEFAULT_APPS_BOUNDARY);
- } else {
- UMA_HISTOGRAM_ENUMERATION("SyncPromo.ShownPromoWithBrand",
- GetSyncPromoBrandUMABucketFromGroup(),
- SYNC_PROMO_AND_DEFAULT_APPS_BOUNDARY);
+ LayoutExperimentType type;
+ if (GetActiveLayoutExperiment(&type)) {
+ return type == LAYOUT_EXPERIMENT_NONE ? STARTUP_OVERRIDE_HIDE :
+ STARTUP_OVERRIDE_SHOW;
}
+ return STARTUP_OVERRIDE_NONE;
}
-void RecordUserSignedIn() {
- DCHECK(IsExperimentActive());
- UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageOnSignIn",
- GetGroup(),
- PROMO_MSG_MAX);
+void RecordUserShownPromo(content::WebUI* web_ui) {
+ DCHECK(sync_promo_trial_initialized);
+
+ LayoutExperimentType type;
+ if (GetActiveLayoutExperiment(&type)) {
+ bool is_at_startup = SyncPromoUI::GetIsLaunchPageForSyncPromoURL(
+ web_ui->GetWebContents()->GetURL());
+ if (is_at_startup) {
+ DCHECK(SyncPromoUI::HasShownPromoAtStartup(Profile::FromWebUI(web_ui)));
+ UMA_HISTOGRAM_ENUMERATION("SyncPromo.ShownPromoWithLayoutExpAtStartup",
+ type, LAYOUT_EXPERIMENT_BOUNDARY);
+ } else {
+ UMA_HISTOGRAM_ENUMERATION("SyncPromo.ShownPromoWithLayoutExp",
+ type, LAYOUT_EXPERIMENT_BOUNDARY);
+ }
+ }
}
-void RecordUserSignedInWithTrialBrand(bool is_at_startup, Profile* profile) {
- DCHECK(IsPartOfBrandTrialToEnable());
- if (is_at_startup) {
- DCHECK(SyncPromoUI::HasShownPromoAtStartup(profile));
- UMA_HISTOGRAM_ENUMERATION("SyncPromo.SignedInWithBrandAtStartup",
- GetSyncPromoBrandUMABucketFromGroup(),
- SYNC_PROMO_AND_DEFAULT_APPS_BOUNDARY);
- } else {
- UMA_HISTOGRAM_ENUMERATION("SyncPromo.SignedInWithBrand",
- GetSyncPromoBrandUMABucketFromGroup(),
- SYNC_PROMO_AND_DEFAULT_APPS_BOUNDARY);
+void RecordUserSignedIn(content::WebUI* web_ui) {
+ DCHECK(sync_promo_trial_initialized);
+
+ LayoutExperimentType type;
+ if (GetActiveLayoutExperiment(&type)) {
+ bool is_at_startup = SyncPromoUI::GetIsLaunchPageForSyncPromoURL(
+ web_ui->GetWebContents()->GetURL());
+ if (is_at_startup) {
+ DCHECK(SyncPromoUI::HasShownPromoAtStartup(Profile::FromWebUI(web_ui)));
+ UMA_HISTOGRAM_ENUMERATION("SyncPromo.SignedInWithLayoutExpAtStartup",
+ type, LAYOUT_EXPERIMENT_BOUNDARY);
+ } else {
+ UMA_HISTOGRAM_ENUMERATION("SyncPromo.SignedInWithLayoutExp",
+ type, LAYOUT_EXPERIMENT_BOUNDARY);
+ }
}
}
-bool ShouldShowAtStartupBasedOnBrand() {
- DCHECK(IsPartOfBrandTrialToEnable());
- std::string name =
- base::FieldTrialList::Find(kSyncPromoEnabledTrialName)->group_name();
- return name == kSyncPromoEnabledWithApps ||
- name == kSyncPromoEnabledWithoutApps;
+bool GetSyncPromoVersionForCurrentTrial(int* version) {
+ DCHECK(sync_promo_trial_initialized);
+ DCHECK(version);
+
+ LayoutExperimentType type;
+ if (!GetActiveLayoutExperiment(&type))
+ return false;
+
+ switch (type) {
+ case LAYOUT_EXPERIMENT_DEFAULT:
+ *version = 0;
+ return true;
+ case LAYOUT_EXPERIMENT_DEVICES:
+ *version = 1;
+ return true;
+ case LAYOUT_EXPERIMENT_VERBOSE:
+ *version = 2;
+ return true;
+ case LAYOUT_EXPERIMENT_SIMPLE:
+ *version = 3;
+ return true;
+ default:
+ return false;
+ }
}
} // namespace sync_promo_trial
diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_trial.h b/chrome/browser/ui/webui/sync_promo/sync_promo_trial.h
index aec50a6..19ab4bb 100644
--- a/chrome/browser/ui/webui/sync_promo/sync_promo_trial.h
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_trial.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -8,79 +8,38 @@
#include "base/basictypes.h"
class Profile;
+namespace content {
+class WebUI;
+}
-// These helpers manage the Sync Promo field trial.
-//
-// The sync promo experiment involves changing the message body in the sign in
-// promo (see SyncPromoHandler) to see if that has any effect on sign in.
namespace sync_promo_trial {
- enum Group {
- // "Get your bookmarks, history, and settings on all your devices."
- // This is also the default message group.
- PROMO_MSG_A = 0,
-
- // "Back up your bookmarks, history, and settings to the web."
- PROMO_MSG_B,
-
- // "Sync your personalized browser features between all your devices."
- PROMO_MSG_C,
-
- // "You'll be automatically signed into to your favorite Google services."
- PROMO_MSG_D,
-
- // Bounding max value needed for UMA histogram macro.
- PROMO_MSG_MAX,
- };
-
- enum SyncPromoEnabledBrandUMABuckets {
- WITH_SYNC_PROMO_WITH_DEFAULT_APPS = 0,
- WITH_SYNC_PROMO_WITHOUT_DEFAULT_APPS,
- WITHOUT_SYNC_PROMO_WITHOUT_DEFAULT_APPS_A,
- WITHOUT_SYNC_PROMO_WITHOUT_DEFAULT_APPS_B,
- SYNC_PROMO_AND_DEFAULT_APPS_BOUNDARY,
- };
- // Activate the field trial. Before this call, all calls to GetGroup will
- // return PROMO_MSG_A. *** MUST NOT BE CALLED MORE THAN ONCE. ***
- void Activate();
+enum StartupOverride {
+ STARTUP_OVERRIDE_NONE,
+ STARTUP_OVERRIDE_SHOW,
+ STARTUP_OVERRIDE_HIDE,
+};
- // Returns true iff the experiment has been set up and is active. If this
- // is false, the caller should not record stats for this experiment.
- bool IsExperimentActive();
+// Activate the field trial.
+void Activate();
- // If the user has been tagged with a brand code at install time that
- // determines if they should see the sync promo or not.
- bool IsPartOfBrandTrialToEnable();
+// Returns the start up override value for any currently running sync promo
+// trials.
+StartupOverride GetStartupOverrideForCurrentTrial();
- // Return the field trial group this client belongs to.
- Group GetGroup();
+// Records that the user was shown the sync promo for any currently running sync
+// promo trials. |web_ui| is the web UI where the promo was shown.
+void RecordUserShownPromo(content::WebUI* web_ui);
- // Return the UMA bucket
- int GetSyncPromoBrandUMABucketFromGroup();
+// Records that the user signed into sync for any currently running sync promo
+// trials. |web_ui| is the web UI where the user signed into sync.
+void RecordUserSignedIn(content::WebUI* web_ui);
- // Return the resource ID for the Sync Promo message body associated with this
- // client.
- int GetMessageBodyResID();
+// Returns true if a sync promo trial is running that overrides the sync promo
+// version. If such a trial is running then on return |version| will contain the
+// version of the sync promo to show. |version| must not be NULL.
+bool GetSyncPromoVersionForCurrentTrial(int* version);
- // Record the appropriate UMA stat for when a user sees the sync promo
- // message.
- void RecordUserSawMessage();
-
- // Record that a user was shown the promo when tagged with an experimental
- // brand code.
- void RecordUserShownPromoWithTrialBrand(bool is_at_startup, Profile* profile);
-
- // Record the appropriate UMA stat for when a user successfully signs in to
- // GAIA.
- void RecordUserSignedIn();
-
- // Record that a user signed in while tagged with a brand code currently being
- // used in a field trial.
- void RecordUserSignedInWithTrialBrand(bool is_at_startup, Profile* profile);
-
- // If we've been tagged with any of the experimental brands to show the sync
- // promo.
- bool ShouldShowAtStartupBasedOnBrand();
-}
+} // namespace sync_promo_trial
#endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_TRIAL_H_
diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc
index 63d6aec..6545bdf 100644
--- a/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc
@@ -128,11 +128,7 @@ SyncPromoUI::SyncPromoUI(content::WebUI* web_ui) : WebUIController(web_ui) {
html_source->set_default_resource(IDR_SYNC_PROMO_HTML);
profile->GetChromeURLDataManager()->AddDataSource(html_source);
- if (sync_promo_trial::IsPartOfBrandTrialToEnable()) {
- bool is_start_up = GetIsLaunchPageForSyncPromoURL(
- web_ui->GetWebContents()->GetURL());
- sync_promo_trial::RecordUserShownPromoWithTrialBrand(is_start_up, profile);
- }
+ sync_promo_trial::RecordUserShownPromo(web_ui);
}
// static
@@ -202,10 +198,17 @@ bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile,
if (show_count >= kSyncPromoShowAtStartupMaximum)
return false;
- // If the current install has a brand code that's part of an experiment, honor
- // that before master prefs.
- if (sync_promo_trial::IsPartOfBrandTrialToEnable())
- return sync_promo_trial::ShouldShowAtStartupBasedOnBrand();
+ // If the current install is part of trial then let the trial determine if we
+ // should show the promo or not.
+ switch (sync_promo_trial::GetStartupOverrideForCurrentTrial()) {
+ case sync_promo_trial::STARTUP_OVERRIDE_NONE:
+ // No override so simply continue.
+ break;
+ case sync_promo_trial::STARTUP_OVERRIDE_SHOW:
+ return true;
+ case sync_promo_trial::STARTUP_OVERRIDE_HIDE:
+ return false;
+ }
// This pref can be set in the master preferences file to allow or disallow
// showing the sync promo at startup.
@@ -298,6 +301,8 @@ int SyncPromoUI::GetSyncPromoVersion() {
GetSwitchValueASCII(switches::kSyncPromoVersion), &version)) {
return version;
}
+ if (sync_promo_trial::GetSyncPromoVersionForCurrentTrial(&version))
+ return version;
// Default promo version is 0.
return 0;
}
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
index 5b7246d..6eef3b9 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -21,7 +21,6 @@
#include "chrome/browser/sync/sync_setup_flow.h"
#include "chrome/browser/sync/util/oauth.h"
#include "chrome/browser/ui/browser_list.h"
-#include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h"
#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
#include "chrome/common/net/gaia/gaia_constants.h"
#include "chrome/common/url_constants.h"
@@ -247,15 +246,6 @@ void SyncSetupHandler::GetStaticLocalizedValues(
google_util::StringAppendGoogleLocaleParam(
chrome::kSyncErrorsHelpURL));
- // The experimental body string only appears if we are on the launch page
- // version of the Sync Promo.
- int message_body_resource_id = IDS_SYNC_PROMO_MESSAGE_BODY_A;
- if (is_launch_page)
- message_body_resource_id = sync_promo_trial::GetMessageBodyResID();
- localized_strings->SetString(
- "promoMessageBody",
- GetStringUTF16(message_body_resource_id));
-
std::string create_account_url = google_util::StringAppendGoogleLocaleParam(
chrome::kSyncCreateNewAccountURL);
string16 create_account = GetStringUTF16(IDS_SYNC_CREATE_ACCOUNT);
@@ -361,6 +351,7 @@ void SyncSetupHandler::GetStaticLocalizedValues(
{ "promoVerboseServicesBody", IDS_SYNC_PROMO_V_SERVICES_BODY },
{ "promoVerboseSignUp", IDS_SYNC_PROMO_V_SIGN_UP },
{ "promoTitleShort", IDS_SYNC_PROMO_MESSAGE_TITLE_SHORT },
+ { "promoMessageBody", IDS_SYNC_PROMO_MESSAGE_BODY },
};
RegisterStrings(localized_strings, resources, arraysize(resources));
diff --git a/chrome/browser/ui/webui/sync_setup_handler2.cc b/chrome/browser/ui/webui/sync_setup_handler2.cc
index bdeb392..82c89ec 100644
--- a/chrome/browser/ui/webui/sync_setup_handler2.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler2.cc
@@ -250,15 +250,6 @@ void SyncSetupHandler2::GetStaticLocalizedValues(
google_util::StringAppendGoogleLocaleParam(
chrome::kSyncErrorsHelpURL));
- // The experimental body string only appears if we are on the launch page
- // version of the Sync Promo.
- int message_body_resource_id = IDS_SYNC_PROMO_MESSAGE_BODY_A;
- if (is_launch_page)
- message_body_resource_id = sync_promo_trial::GetMessageBodyResID();
- localized_strings->SetString(
- "promoMessageBody",
- GetStringUTF16(message_body_resource_id));
-
std::string create_account_url = google_util::StringAppendGoogleLocaleParam(
chrome::kSyncCreateNewAccountURL);
string16 create_account = GetStringUTF16(IDS_SYNC_CREATE_ACCOUNT);
@@ -364,6 +355,7 @@ void SyncSetupHandler2::GetStaticLocalizedValues(
{ "promoVerboseServicesBody", IDS_SYNC_PROMO_V_SERVICES_BODY },
{ "promoVerboseSignUp", IDS_SYNC_PROMO_V_SIGN_UP },
{ "promoTitleShort", IDS_SYNC_PROMO_MESSAGE_TITLE_SHORT },
+ { "promoMessageBody", IDS_SYNC_PROMO_MESSAGE_BODY },
};
RegisterStrings(localized_strings, resources, arraysize(resources));