OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/sync_promo_handler.h" | 5 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/sync/profile_sync_service.h" | 13 #include "chrome/browser/sync/profile_sync_service.h" |
14 #include "chrome/browser/sync/sync_setup_flow.h" | 14 #include "chrome/browser/sync/sync_setup_flow.h" |
15 #include "chrome/browser/tabs/tab_strip_model.h" | 15 #include "chrome/browser/tabs/tab_strip_model.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
18 #include "chrome/browser/ui/webui/sync_promo_trial.h" | 18 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" |
19 #include "chrome/browser/ui/webui/sync_promo_ui.h" | 19 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
20 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
21 #include "chrome/common/extensions/extension_constants.h" | 21 #include "chrome/common/extensions/extension_constants.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
24 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/browser/tab_contents/tab_contents.h" |
25 #include "content/public/browser/notification_details.h" | 25 #include "content/public/browser/notification_details.h" |
26 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
(...skipping 20 matching lines...) Expand all Loading... |
50 | 50 |
51 // This was added because of the need to change the existing UMA enum for the | 51 // This was added because of the need to change the existing UMA enum for the |
52 // sync promo mid-flight. Ideally these values would be contiguous, but the | 52 // sync promo mid-flight. Ideally these values would be contiguous, but the |
53 // real world is not always ideal. | 53 // real world is not always ideal. |
54 static bool IsValidUserFlowAction(int action) { | 54 static bool IsValidUserFlowAction(int action) { |
55 return (action >= SYNC_PROMO_FIRST_VALID_JS_ACTION && | 55 return (action >= SYNC_PROMO_FIRST_VALID_JS_ACTION && |
56 action <= SYNC_PROMO_LAST_VALID_JS_ACTION) || | 56 action <= SYNC_PROMO_LAST_VALID_JS_ACTION) || |
57 action == SYNC_PROMO_LEFT_DURING_THROBBER; | 57 action == SYNC_PROMO_LEFT_DURING_THROBBER; |
58 } | 58 } |
59 | 59 |
| 60 static void RecordExperimentOutcomesOnSignIn() { |
| 61 if (sync_promo_trial::IsExperimentActive()) |
| 62 sync_promo_trial::RecordUserSignedIn(); |
| 63 if (sync_promo_trial::IsPartOfBrandTrialToEnable()) |
| 64 sync_promo_trial::RecordUserSignedInWithTrialBrand(); |
| 65 } |
| 66 |
60 } // namespace | 67 } // namespace |
61 | 68 |
62 SyncPromoHandler::SyncPromoHandler(ProfileManager* profile_manager) | 69 SyncPromoHandler::SyncPromoHandler(ProfileManager* profile_manager) |
63 : SyncSetupHandler(profile_manager), | 70 : SyncSetupHandler(profile_manager), |
64 window_already_closed_(false) { | 71 window_already_closed_(false) { |
65 } | 72 } |
66 | 73 |
67 SyncPromoHandler::~SyncPromoHandler() { | 74 SyncPromoHandler::~SyncPromoHandler() { |
68 } | 75 } |
69 | 76 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 web_ui_->RegisterMessageCallback("SyncPromo:UserFlowAction", | 122 web_ui_->RegisterMessageCallback("SyncPromo:UserFlowAction", |
116 base::Bind(&SyncPromoHandler::HandleUserFlowAction, | 123 base::Bind(&SyncPromoHandler::HandleUserFlowAction, |
117 base::Unretained(this))); | 124 base::Unretained(this))); |
118 web_ui_->RegisterMessageCallback("SyncPromo:UserSkipped", | 125 web_ui_->RegisterMessageCallback("SyncPromo:UserSkipped", |
119 base::Bind(&SyncPromoHandler::HandleUserSkipped, | 126 base::Bind(&SyncPromoHandler::HandleUserSkipped, |
120 base::Unretained(this))); | 127 base::Unretained(this))); |
121 SyncSetupHandler::RegisterMessages(); | 128 SyncSetupHandler::RegisterMessages(); |
122 } | 129 } |
123 | 130 |
124 void SyncPromoHandler::ShowGaiaSuccessAndClose() { | 131 void SyncPromoHandler::ShowGaiaSuccessAndClose() { |
125 if (sync_promo_trial::IsExperimentActive()) | 132 RecordExperimentOutcomesOnSignIn(); |
126 sync_promo_trial::RecordUserSignedIn(); | |
127 | |
128 SyncSetupHandler::ShowGaiaSuccessAndClose(); | 133 SyncSetupHandler::ShowGaiaSuccessAndClose(); |
129 } | 134 } |
130 | 135 |
131 void SyncPromoHandler::ShowGaiaSuccessAndSettingUp() { | 136 void SyncPromoHandler::ShowGaiaSuccessAndSettingUp() { |
132 if (sync_promo_trial::IsExperimentActive()) | 137 RecordExperimentOutcomesOnSignIn(); |
133 sync_promo_trial::RecordUserSignedIn(); | |
134 | |
135 SyncSetupHandler::ShowGaiaSuccessAndSettingUp(); | 138 SyncSetupHandler::ShowGaiaSuccessAndSettingUp(); |
136 } | 139 } |
137 | 140 |
138 void SyncPromoHandler::ShowConfigure(const base::DictionaryValue& args) { | 141 void SyncPromoHandler::ShowConfigure(const base::DictionaryValue& args) { |
139 bool usePassphrase = false; | 142 bool usePassphrase = false; |
140 args.GetBoolean("usePassphrase", &usePassphrase); | 143 args.GetBoolean("usePassphrase", &usePassphrase); |
141 | 144 |
142 if (usePassphrase) { | 145 if (usePassphrase) { |
143 // If a passphrase is required then we must show the configure pane. | 146 // If a passphrase is required then we must show the configure pane. |
144 SyncSetupHandler::ShowConfigure(args); | 147 SyncSetupHandler::ShowConfigure(args); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 void SyncPromoHandler::HandleUserSkipped(const base::ListValue* args) { | 269 void SyncPromoHandler::HandleUserSkipped(const base::ListValue* args) { |
267 SyncPromoUI::SetUserSkippedSyncPromo(Profile::FromWebUI(web_ui_)); | 270 SyncPromoUI::SetUserSkippedSyncPromo(Profile::FromWebUI(web_ui_)); |
268 RecordUserFlowAction(SYNC_PROMO_SKIP_CLICKED); | 271 RecordUserFlowAction(SYNC_PROMO_SKIP_CLICKED); |
269 } | 272 } |
270 | 273 |
271 int SyncPromoHandler::GetViewCount() const { | 274 int SyncPromoHandler::GetViewCount() const { |
272 // The locally persistent number of times the user has seen the sync promo. | 275 // The locally persistent number of times the user has seen the sync promo. |
273 return prefs_->GetInteger(prefs::kSyncPromoViewCount); | 276 return prefs_->GetInteger(prefs::kSyncPromoViewCount); |
274 } | 277 } |
275 | 278 |
276 int SyncPromoHandler::IncrementViewCountBy(unsigned int amount) { | 279 int SyncPromoHandler::IncrementViewCountBy(size_t amount) { |
277 // Let the user increment by 0 if they really want. It might be useful for a | 280 // Let the user increment by 0 if they really want. It might be useful for a |
278 // weird way of sending preference change notifications... | 281 // weird way of sending preference change notifications... |
279 int adjusted = GetViewCount() + amount; | 282 int adjusted = GetViewCount() + amount; |
280 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted); | 283 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted); |
281 return adjusted; | 284 return adjusted; |
282 } | 285 } |
283 | 286 |
284 void SyncPromoHandler::RecordUserFlowAction(int action) { | 287 void SyncPromoHandler::RecordUserFlowAction(int action) { |
285 // Send an enumeration to our single user flow histogram. | 288 // Send an enumeration to our single user flow histogram. |
286 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, | 289 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, |
287 SYNC_PROMO_BUCKET_BOUNDARY); | 290 SYNC_PROMO_BUCKET_BOUNDARY); |
288 } | 291 } |
OLD | NEW |