summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-28 02:39:49 +0000
committerdbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-28 02:39:49 +0000
commit3c59811d7a2306181591b3b2f701fbb4dbd33242 (patch)
tree6f44d0e82177935aa4662a3623333956b25eff9f
parent701d009f4c2b4ef618990781de267d8642da0946 (diff)
downloadchromium_src-3c59811d7a2306181591b3b2f701fbb4dbd33242.zip
chromium_src-3c59811d7a2306181591b3b2f701fbb4dbd33242.tar.gz
chromium_src-3c59811d7a2306181591b3b2f701fbb4dbd33242.tar.bz2
Merge 114608, 115692 to 963 (M17) branch.
[Sync Promo UI] Changing sync promo to honor brand codes. Also, this CL moves chrome/browser/ui/webui/sync_promo_* to chrome/browser/ui/webui/sync_promo/sync_promo_*. BUG=107223 R=stevet@chromium.org,rogerta@chromium.org,sail@chromium.org TEST=The sync promo responds to brand code and records results of the field trial correctly. Review URL: http://codereview.chromium.org/8933003 [Sync Promo UI] Change data reporting to differentiate between startup and other means of getting to the full page sync promo. R=stevet@chromium.org,sail@chromium.org TEST=about:histograms, Ctrl+f "WithBrand" BUG=107223 Review URL: http://codereview.chromium.org/9007041 Review URL: http://codereview.chromium.org/8992034 git-svn-id: svn://svn.chromium.org/chrome/branches/963/src@115861 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_browser_main.cc2
-rw-r--r--chrome/browser/prefs/browser_prefs.cc2
-rw-r--r--chrome/browser/profiles/profile_manager.cc2
-rw-r--r--chrome/browser/ui/browser_init.cc2
-rw-r--r--chrome/browser/ui/webui/chrome_web_ui_factory.cc2
-rw-r--r--chrome/browser/ui/webui/ntp/ntp_login_handler.cc2
-rw-r--r--chrome/browser/ui/webui/ntp/ntp_resource_cache.cc2
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc (renamed from chrome/browser/ui/webui/sync_promo_handler.cc)37
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_handler.h (renamed from chrome/browser/ui/webui/sync_promo_handler.h)15
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc187
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_trial.h (renamed from chrome/browser/ui/webui/sync_promo_trial.h)35
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc (renamed from chrome/browser/ui/webui/sync_promo_ui.cc)26
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_ui.h (renamed from chrome/browser/ui/webui/sync_promo_ui.h)9
-rw-r--r--chrome/browser/ui/webui/sync_promo_trial.cc100
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler.cc4
-rw-r--r--chrome/chrome_browser.gypi12
16 files changed, 292 insertions, 147 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index baeeed4..068e195 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -77,7 +77,7 @@
#include "chrome/browser/translate/translate_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h"
-#include "chrome/browser/ui/webui/sync_promo_trial.h"
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 4e01282..51fdbf9 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -58,7 +58,7 @@
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
#include "chrome/browser/ui/webui/options/extension_settings_handler.h"
#include "chrome/browser/ui/webui/plugins_ui.h"
-#include "chrome/browser/ui/webui/sync_promo_ui.h"
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
#include "chrome/browser/upgrade_detector.h"
#include "chrome/browser/web_resource/promo_resource_service.h"
#include "chrome/common/pref_names.h"
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 4861ac7..e2180fe 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -25,7 +25,7 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/webui/sync_promo_ui.h"
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index 84cb6ea..5ceb564 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -63,7 +63,7 @@
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
-#include "chrome/browser/ui/webui/sync_promo_ui.h"
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_result_codes.h"
diff --git a/chrome/browser/ui/webui/chrome_web_ui_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_factory.cc
index 05e3523..b9d489c 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_factory.cc
@@ -60,7 +60,7 @@
#include "chrome/browser/ui/webui/chromeos/system_info_ui.h"
#include "chrome/browser/ui/webui/active_downloads_ui.h"
#else
-#include "chrome/browser/ui/webui/sync_promo_ui.h"
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
#endif
#if defined(USE_VIRTUAL_KEYBOARD)
diff --git a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
index dc7f087..3b9698e 100644
--- a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
@@ -25,7 +25,7 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
-#include "chrome/browser/ui/webui/sync_promo_ui.h"
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
#include "chrome/browser/ui/webui/web_ui_util.h"
#include "chrome/browser/web_resource/promo_resource_service.h"
#include "chrome/common/chrome_notification_types.h"
diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
index 2c6a1e5..b6817a5 100644
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -26,7 +26,7 @@
#include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
#include "chrome/browser/ui/webui/ntp/ntp_login_handler.h"
-#include "chrome/browser/ui/webui/sync_promo_ui.h"
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
#include "chrome/browser/ui/webui/sync_setup_handler.h"
#include "chrome/browser/web_resource/promo_resource_service.h"
#include "chrome/common/chrome_notification_types.h"
diff --git a/chrome/browser/ui/webui/sync_promo_handler.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc
index 1287a4d..86e9454 100644
--- a/chrome/browser/ui/webui/sync_promo_handler.cc
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc
@@ -2,7 +2,7 @@
// 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_handler.h"
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -15,8 +15,8 @@
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
-#include "chrome/browser/ui/webui/sync_promo_trial.h"
-#include "chrome/browser/ui/webui/sync_promo_ui.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/chrome_notification_types.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
@@ -122,16 +122,12 @@ void SyncPromoHandler::RegisterMessages() {
}
void SyncPromoHandler::ShowGaiaSuccessAndClose() {
- if (sync_promo_trial::IsExperimentActive())
- sync_promo_trial::RecordUserSignedIn();
-
+ RecordExperimentOutcomesOnSignIn();
SyncSetupHandler::ShowGaiaSuccessAndClose();
}
void SyncPromoHandler::ShowGaiaSuccessAndSettingUp() {
- if (sync_promo_trial::IsExperimentActive())
- sync_promo_trial::RecordUserSignedIn();
-
+ RecordExperimentOutcomesOnSignIn();
SyncSetupHandler::ShowGaiaSuccessAndSettingUp();
}
@@ -183,11 +179,11 @@ void SyncPromoHandler::StepWizardForShowSetupUI() {
}
void SyncPromoHandler::ShowSetupUI() {
- // SyncSetupWizard::Step should be called in StepWizardForShowSetupUI above,
- // but it causes the sync promo page to not set focus properly to the login
- // email address. This happens because focus is lost between the call to
- // StepWizardForShowSetupUI and ShowSetupUI.
- // TODO(binji): Move this function back and fix the focus the right way.
+ // SyncSetupWizard::Step should be called in StepWizardForShowSetupUI above,
+ // but it causes the sync promo page to not set focus properly to the login
+ // email address. This happens because focus is lost between the call to
+ // StepWizardForShowSetupUI and ShowSetupUI.
+ // TODO(binji): Move this function back and fix the focus the right way.
ProfileSyncService* service =
Profile::FromWebUI(web_ui_)->GetProfileSyncService();
service->get_wizard().Step(SyncSetupWizard::GetLoginState());
@@ -276,7 +272,7 @@ int SyncPromoHandler::GetViewCount() const {
return prefs_->GetInteger(prefs::kSyncPromoViewCount);
}
-int SyncPromoHandler::IncrementViewCountBy(unsigned int amount) {
+int SyncPromoHandler::IncrementViewCountBy(size_t amount) {
// Let the user increment by 0 if they really want. It might be useful for a
// weird way of sending preference change notifications...
int adjusted = GetViewCount() + amount;
@@ -284,6 +280,17 @@ int SyncPromoHandler::IncrementViewCountBy(unsigned int 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_->tab_contents()->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_handler.h b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.h
index d0534e4..c1f4737 100644
--- a/chrome/browser/ui/webui/sync_promo_handler.h
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_HANDLER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_HANDLER_H_
#pragma once
#include "chrome/browser/ui/webui/sync_setup_handler.h"
@@ -70,14 +70,15 @@ class SyncPromoHandler : public SyncSetupHandler {
// Increment the local view count by the specified non-negative integer
// amount. Returns the new total view count.
- int IncrementViewCountBy(unsigned int amount);
+ 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);
- // Load any experiments that run on the promo page.
- void LoadPromoExperiments();
-
// Use this to register for certain notifications (currently when tabs or
// windows close).
content::NotificationRegistrar registrar_;
@@ -94,4 +95,4 @@ class SyncPromoHandler : public SyncSetupHandler {
DISALLOW_COPY_AND_ASSIGN(SyncPromoHandler);
};
-#endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_HANDLER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_HANDLER_H_
diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc
new file mode 100644
index 0000000..cd34c3f
--- /dev/null
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc
@@ -0,0 +1,187 @@
+// 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/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 "chrome/browser/ui/webui/sync_promo/sync_promo_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);
+ }
+}
+
+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;
+}
+
+int GetSyncPromoBrandUMABucketFromGroup() {
+ 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 == 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;
+}
+
+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;
+ }
+
+ NOTREACHED();
+ return IDS_SYNC_PROMO_MESSAGE_BODY_A;
+}
+
+void RecordUserSawMessage() {
+ DCHECK(IsExperimentActive());
+ UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageDisplayed",
+ GetGroup(),
+ PROMO_MSG_MAX);
+}
+
+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);
+ }
+}
+
+void RecordUserSignedIn() {
+ DCHECK(IsExperimentActive());
+ UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageOnSignIn",
+ GetGroup(),
+ PROMO_MSG_MAX);
+}
+
+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);
+ }
+}
+
+bool ShouldShowAtStartupBasedOnBrand() {
+ DCHECK(IsPartOfBrandTrialToEnable());
+ std::string name =
+ base::FieldTrialList::Find(kSyncPromoEnabledTrialName)->group_name();
+ return name == kSyncPromoEnabledWithApps ||
+ name == kSyncPromoEnabledWithoutApps;
+}
+
+} // namespace sync_promo_trial
diff --git a/chrome/browser/ui/webui/sync_promo_trial.h b/chrome/browser/ui/webui/sync_promo/sync_promo_trial.h
index 5186bb5..aec50a6 100644
--- a/chrome/browser/ui/webui/sync_promo_trial.h
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_trial.h
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_TRIAL_H_
-#define CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_TRIAL_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_TRIAL_H_
+#define CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_TRIAL_H_
#include "base/basictypes.h"
+class Profile;
+
// These helpers manage the Sync Promo field trial.
//
// The sync promo experiment involves changing the message body in the sign in
@@ -30,6 +32,14 @@ namespace sync_promo_trial {
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();
@@ -38,9 +48,16 @@ namespace sync_promo_trial {
// is false, the caller should not record stats for this experiment.
bool IsExperimentActive();
+ // 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();
+
// Return the field trial group this client belongs to.
Group GetGroup();
+ // Return the UMA bucket
+ int GetSyncPromoBrandUMABucketFromGroup();
+
// Return the resource ID for the Sync Promo message body associated with this
// client.
int GetMessageBodyResID();
@@ -49,9 +66,21 @@ namespace sync_promo_trial {
// 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();
}
-#endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_TRIAL_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_TRIAL_H_
diff --git a/chrome/browser/ui/webui/sync_promo_ui.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc
index 756aeb9..7251d28 100644
--- a/chrome/browser/ui/webui/sync_promo_ui.cc
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc
@@ -2,7 +2,7 @@
// 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_ui.h"
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
#include "base/command_line.h"
#include "base/utf_string_conversions.h"
@@ -15,7 +15,8 @@
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
#include "chrome/browser/ui/webui/options/core_options_handler.h"
-#include "chrome/browser/ui/webui/sync_promo_handler.h"
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h"
+#include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h"
#include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -121,6 +122,16 @@ SyncPromoUI::SyncPromoUI(TabContents* contents) : ChromeWebUI(contents) {
html_source->add_resource_path(kSyncPromoJsFile, IDR_SYNC_PROMO_JS);
html_source->set_default_resource(IDR_SYNC_PROMO_HTML);
profile->GetChromeURLDataManager()->AddDataSource(html_source);
+
+ if (sync_promo_trial::IsPartOfBrandTrialToEnable()) {
+ bool is_start_up = GetIsLaunchPageForSyncPromoURL(contents->GetURL());
+ sync_promo_trial::RecordUserShownPromoWithTrialBrand(is_start_up, profile);
+ }
+}
+
+// static
+bool SyncPromoUI::HasShownPromoAtStartup(Profile* profile) {
+ return profile->GetPrefs()->HasPrefPath(prefs::kSyncPromoStartupCount);
}
// static
@@ -157,8 +168,10 @@ void SyncPromoUI::RegisterUserPrefs(PrefService* prefs) {
SyncPromoHandler::RegisterUserPrefs(prefs);
}
+// static
bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile,
bool is_new_profile) {
+ DCHECK(profile);
if (!ShouldShowSyncPromo(profile))
return false;
@@ -166,9 +179,8 @@ bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile,
if (command_line.HasSwitch(switches::kNoFirstRun))
is_new_profile = false;
- PrefService *prefs = profile->GetPrefs();
if (!is_new_profile) {
- if (!prefs->HasPrefPath(prefs::kSyncPromoStartupCount))
+ if (!HasShownPromoAtStartup(profile))
return false;
}
@@ -179,10 +191,16 @@ bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile,
if (g_browser_process->GetApplicationLocale() == "zh-CN")
return false;
+ PrefService* prefs = profile->GetPrefs();
int show_count = prefs->GetInteger(prefs::kSyncPromoStartupCount);
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();
+
// This pref can be set in the master preferences file to allow or disallow
// showing the sync promo at startup.
if (prefs->HasPrefPath(prefs::kSyncPromoShowOnFirstRunAllowed))
diff --git a/chrome/browser/ui/webui/sync_promo_ui.h b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.h
index d089406..5079c10 100644
--- a/chrome/browser/ui/webui/sync_promo_ui.h
+++ b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_UI_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_UI_H_
#pragma once
#include "chrome/browser/ui/webui/chrome_web_ui.h"
@@ -30,6 +30,9 @@ class SyncPromoUI : public ChromeWebUI {
// of the number of times we've displayed it.
static void DidShowSyncPromoAtStartup(Profile* profile);
+ // Returns true if a user has seen the sync promo at startup previously.
+ static bool HasShownPromoAtStartup(Profile* profile);
+
// Returns true if the user has previously skipped the sync promo.
static bool HasUserSkippedSyncPromo(Profile* profile);
@@ -58,4 +61,4 @@ class SyncPromoUI : public ChromeWebUI {
DISALLOW_COPY_AND_ASSIGN(SyncPromoUI);
};
-#endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_UI_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_UI_H_
diff --git a/chrome/browser/ui/webui/sync_promo_trial.cc b/chrome/browser/ui/webui/sync_promo_trial.cc
deleted file mode 100644
index 4003144..0000000
--- a/chrome/browser/ui/webui/sync_promo_trial.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-// 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"
-#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 kSyncPromoMsgTrialName[] = "SyncPromoMsg";
-
-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);
-}
-
-bool IsExperimentActive() {
- return base::FieldTrialList::FindValue(kSyncPromoMsgTrialName) !=
- base::FieldTrial::kNotFinalized;
-}
-
-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;
-}
-
-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;
- }
-
- NOTREACHED();
- return IDS_SYNC_PROMO_MESSAGE_BODY_A;
-}
-
-void RecordUserSawMessage() {
- DCHECK(IsExperimentActive());
- UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageDisplayed",
- GetGroup(),
- PROMO_MSG_MAX);
-}
-
-void RecordUserSignedIn() {
- DCHECK(IsExperimentActive());
- UMA_HISTOGRAM_ENUMERATION("SyncPromo.MessageOnSignIn",
- GetGroup(),
- PROMO_MSG_MAX);
-}
-
-} // namespace sync_promo_trial
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
index 0bf3f86..15937b7 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -23,8 +23,8 @@
#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_trial.h"
-#include "chrome/browser/ui/webui/sync_promo_ui.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/browser/ui/webui/user_selectable_sync_type.h"
#include "chrome/common/net/gaia/gaia_constants.h"
#include "chrome/common/pref_names.h"
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index ced1b0f..65e7bc7 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3922,12 +3922,12 @@
'browser/ui/webui/ssl_client_certificate_selector_webui.h',
'browser/ui/webui/sync_internals_ui.cc',
'browser/ui/webui/sync_internals_ui.h',
- 'browser/ui/webui/sync_promo_handler.cc',
- 'browser/ui/webui/sync_promo_handler.h',
- 'browser/ui/webui/sync_promo_trial.cc',
- 'browser/ui/webui/sync_promo_trial.h',
- 'browser/ui/webui/sync_promo_ui.cc',
- 'browser/ui/webui/sync_promo_ui.h',
+ 'browser/ui/webui/sync_promo/sync_promo_handler.cc',
+ 'browser/ui/webui/sync_promo/sync_promo_handler.h',
+ 'browser/ui/webui/sync_promo/sync_promo_trial.cc',
+ 'browser/ui/webui/sync_promo/sync_promo_trial.h',
+ 'browser/ui/webui/sync_promo/sync_promo_ui.cc',
+ 'browser/ui/webui/sync_promo/sync_promo_ui.h',
'browser/ui/webui/sync_setup_handler.cc',
'browser/ui/webui/sync_setup_handler.h',
'browser/ui/webui/task_manager_dialog.cc',