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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 web_ui_->RegisterMessageCallback("SyncPromo:UserFlowAction", | 115 web_ui_->RegisterMessageCallback("SyncPromo:UserFlowAction", |
116 base::Bind(&SyncPromoHandler::HandleUserFlowAction, | 116 base::Bind(&SyncPromoHandler::HandleUserFlowAction, |
117 base::Unretained(this))); | 117 base::Unretained(this))); |
118 web_ui_->RegisterMessageCallback("SyncPromo:UserSkipped", | 118 web_ui_->RegisterMessageCallback("SyncPromo:UserSkipped", |
119 base::Bind(&SyncPromoHandler::HandleUserSkipped, | 119 base::Bind(&SyncPromoHandler::HandleUserSkipped, |
120 base::Unretained(this))); | 120 base::Unretained(this))); |
121 SyncSetupHandler::RegisterMessages(); | 121 SyncSetupHandler::RegisterMessages(); |
122 } | 122 } |
123 | 123 |
124 void SyncPromoHandler::ShowGaiaSuccessAndClose() { | 124 void SyncPromoHandler::ShowGaiaSuccessAndClose() { |
125 if (sync_promo_trial::IsExperimentActive()) | 125 RecordExperimentOutcomesOnSignIn(); |
126 sync_promo_trial::RecordUserSignedIn(); | |
127 | |
128 SyncSetupHandler::ShowGaiaSuccessAndClose(); | 126 SyncSetupHandler::ShowGaiaSuccessAndClose(); |
129 } | 127 } |
130 | 128 |
131 void SyncPromoHandler::ShowGaiaSuccessAndSettingUp() { | 129 void SyncPromoHandler::ShowGaiaSuccessAndSettingUp() { |
132 if (sync_promo_trial::IsExperimentActive()) | 130 RecordExperimentOutcomesOnSignIn(); |
133 sync_promo_trial::RecordUserSignedIn(); | |
134 | |
135 SyncSetupHandler::ShowGaiaSuccessAndSettingUp(); | 131 SyncSetupHandler::ShowGaiaSuccessAndSettingUp(); |
136 } | 132 } |
137 | 133 |
138 void SyncPromoHandler::ShowConfigure(const base::DictionaryValue& args) { | 134 void SyncPromoHandler::ShowConfigure(const base::DictionaryValue& args) { |
139 bool usePassphrase = false; | 135 bool usePassphrase = false; |
140 args.GetBoolean("usePassphrase", &usePassphrase); | 136 args.GetBoolean("usePassphrase", &usePassphrase); |
141 | 137 |
142 if (usePassphrase) { | 138 if (usePassphrase) { |
143 // If a passphrase is required then we must show the configure pane. | 139 // If a passphrase is required then we must show the configure pane. |
144 SyncSetupHandler::ShowConfigure(args); | 140 SyncSetupHandler::ShowConfigure(args); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 default: { | 172 default: { |
177 NOTREACHED(); | 173 NOTREACHED(); |
178 } | 174 } |
179 } | 175 } |
180 } | 176 } |
181 | 177 |
182 void SyncPromoHandler::StepWizardForShowSetupUI() { | 178 void SyncPromoHandler::StepWizardForShowSetupUI() { |
183 } | 179 } |
184 | 180 |
185 void SyncPromoHandler::ShowSetupUI() { | 181 void SyncPromoHandler::ShowSetupUI() { |
186 // SyncSetupWizard::Step should be called in StepWizardForShowSetupUI above, | 182 // SyncSetupWizard::Step should be called in StepWizardForShowSetupUI above, |
187 // but it causes the sync promo page to not set focus properly to the login | 183 // but it causes the sync promo page to not set focus properly to the login |
188 // email address. This happens because focus is lost between the call to | 184 // email address. This happens because focus is lost between the call to |
189 // StepWizardForShowSetupUI and ShowSetupUI. | 185 // StepWizardForShowSetupUI and ShowSetupUI. |
190 // TODO(binji): Move this function back and fix the focus the right way. | 186 // TODO(binji): Move this function back and fix the focus the right way. |
191 ProfileSyncService* service = | 187 ProfileSyncService* service = |
192 Profile::FromWebUI(web_ui_)->GetProfileSyncService(); | 188 Profile::FromWebUI(web_ui_)->GetProfileSyncService(); |
193 service->get_wizard().Step(SyncSetupWizard::GetLoginState()); | 189 service->get_wizard().Step(SyncSetupWizard::GetLoginState()); |
194 } | 190 } |
195 | 191 |
196 void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) { | 192 void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) { |
197 CloseSyncSetup(); | 193 CloseSyncSetup(); |
198 | 194 |
199 // If the user has signed in then set the pref to show them NTP bubble | 195 // If the user has signed in then set the pref to show them NTP bubble |
200 // confirming that they're signed in. | 196 // confirming that they're signed in. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 void SyncPromoHandler::HandleUserSkipped(const base::ListValue* args) { | 265 void SyncPromoHandler::HandleUserSkipped(const base::ListValue* args) { |
270 SyncPromoUI::SetUserSkippedSyncPromo(Profile::FromWebUI(web_ui_)); | 266 SyncPromoUI::SetUserSkippedSyncPromo(Profile::FromWebUI(web_ui_)); |
271 RecordUserFlowAction(SYNC_PROMO_SKIP_CLICKED); | 267 RecordUserFlowAction(SYNC_PROMO_SKIP_CLICKED); |
272 } | 268 } |
273 | 269 |
274 int SyncPromoHandler::GetViewCount() const { | 270 int SyncPromoHandler::GetViewCount() const { |
275 // The locally persistent number of times the user has seen the sync promo. | 271 // The locally persistent number of times the user has seen the sync promo. |
276 return prefs_->GetInteger(prefs::kSyncPromoViewCount); | 272 return prefs_->GetInteger(prefs::kSyncPromoViewCount); |
277 } | 273 } |
278 | 274 |
279 int SyncPromoHandler::IncrementViewCountBy(unsigned int amount) { | 275 int SyncPromoHandler::IncrementViewCountBy(size_t amount) { |
280 // Let the user increment by 0 if they really want. It might be useful for a | 276 // Let the user increment by 0 if they really want. It might be useful for a |
281 // weird way of sending preference change notifications... | 277 // weird way of sending preference change notifications... |
282 int adjusted = GetViewCount() + amount; | 278 int adjusted = GetViewCount() + amount; |
283 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted); | 279 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted); |
284 return adjusted; | 280 return adjusted; |
285 } | 281 } |
286 | 282 |
| 283 void SyncPromoHandler::RecordExperimentOutcomesOnSignIn() { |
| 284 if (sync_promo_trial::IsExperimentActive()) |
| 285 sync_promo_trial::RecordUserSignedIn(); |
| 286 if (sync_promo_trial::IsPartOfBrandTrialToEnable()) { |
| 287 bool is_start_up = SyncPromoUI::GetIsLaunchPageForSyncPromoURL( |
| 288 web_ui_->tab_contents()->GetURL()); |
| 289 Profile* profile = Profile::FromWebUI(web_ui_); |
| 290 sync_promo_trial::RecordUserSignedInWithTrialBrand(is_start_up, profile); |
| 291 } |
| 292 } |
| 293 |
287 void SyncPromoHandler::RecordUserFlowAction(int action) { | 294 void SyncPromoHandler::RecordUserFlowAction(int action) { |
288 // Send an enumeration to our single user flow histogram. | 295 // Send an enumeration to our single user flow histogram. |
289 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, | 296 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, |
290 SYNC_PROMO_BUCKET_BOUNDARY); | 297 SYNC_PROMO_BUCKET_BOUNDARY); |
291 } | 298 } |
OLD | NEW |