Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc

Issue 8933003: [Sync Promo UI] Changing sync promo to honor brand codes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removing supposedly needless .gypi deps Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_handler2.h" 5 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler2.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
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 SyncPromoHandler2::SyncPromoHandler2(ProfileManager* profile_manager) 69 SyncPromoHandler2::SyncPromoHandler2(ProfileManager* profile_manager)
63 : SyncSetupHandler2(profile_manager), 70 : SyncSetupHandler2(profile_manager),
64 window_already_closed_(false) { 71 window_already_closed_(false) {
65 } 72 }
66 73
67 SyncPromoHandler2::~SyncPromoHandler2() { 74 SyncPromoHandler2::~SyncPromoHandler2() {
68 } 75 }
69 76
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 web_ui_->RegisterMessageCallback("SyncPromo:UserFlowAction", 122 web_ui_->RegisterMessageCallback("SyncPromo:UserFlowAction",
116 base::Bind(&SyncPromoHandler2::HandleUserFlowAction, 123 base::Bind(&SyncPromoHandler2::HandleUserFlowAction,
117 base::Unretained(this))); 124 base::Unretained(this)));
118 web_ui_->RegisterMessageCallback("SyncPromo:UserSkipped", 125 web_ui_->RegisterMessageCallback("SyncPromo:UserSkipped",
119 base::Bind(&SyncPromoHandler2::HandleUserSkipped, 126 base::Bind(&SyncPromoHandler2::HandleUserSkipped,
120 base::Unretained(this))); 127 base::Unretained(this)));
121 SyncSetupHandler2::RegisterMessages(); 128 SyncSetupHandler2::RegisterMessages();
122 } 129 }
123 130
124 void SyncPromoHandler2::ShowGaiaSuccessAndClose() { 131 void SyncPromoHandler2::ShowGaiaSuccessAndClose() {
125 if (sync_promo_trial::IsExperimentActive()) 132 RecordExperimentOutcomesOnSignIn();
126 sync_promo_trial::RecordUserSignedIn();
127
128 SyncSetupHandler2::ShowGaiaSuccessAndClose(); 133 SyncSetupHandler2::ShowGaiaSuccessAndClose();
129 } 134 }
130 135
131 void SyncPromoHandler2::ShowGaiaSuccessAndSettingUp() { 136 void SyncPromoHandler2::ShowGaiaSuccessAndSettingUp() {
132 if (sync_promo_trial::IsExperimentActive()) 137 RecordExperimentOutcomesOnSignIn();
133 sync_promo_trial::RecordUserSignedIn();
134
135 SyncSetupHandler2::ShowGaiaSuccessAndSettingUp(); 138 SyncSetupHandler2::ShowGaiaSuccessAndSettingUp();
136 } 139 }
137 140
138 void SyncPromoHandler2::ShowConfigure(const base::DictionaryValue& args) { 141 void SyncPromoHandler2::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 SyncSetupHandler2::ShowConfigure(args); 147 SyncSetupHandler2::ShowConfigure(args);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 242
240 // TODO(dbeam): Replace with metricsHandler:recordHistogramTime when it exists. 243 // TODO(dbeam): Replace with metricsHandler:recordHistogramTime when it exists.
241 void SyncPromoHandler2::HandleRecordThrobberTime(const base::ListValue* args) { 244 void SyncPromoHandler2::HandleRecordThrobberTime(const base::ListValue* args) {
242 double time_double; 245 double time_double;
243 CHECK(args->GetDouble(0, &time_double)); 246 CHECK(args->GetDouble(0, &time_double));
244 UMA_HISTOGRAM_TIMES("SyncPromo.ThrobberTime", 247 UMA_HISTOGRAM_TIMES("SyncPromo.ThrobberTime",
245 base::TimeDelta::FromMilliseconds(time_double)); 248 base::TimeDelta::FromMilliseconds(time_double));
246 } 249 }
247 250
248 // TODO(dbeam): Replace with metricsHandler:recordHistogramCount when it exists. 251 // TODO(dbeam): Replace with metricsHandler:recordHistogramCount when it exists.
249 void SyncPromoHandler2::HandleRecordSignInAttempts(const base::ListValue* args) { 252 void SyncPromoHandler2::HandleRecordSignInAttempts(
253 const base::ListValue* args) {
250 double count_double; 254 double count_double;
251 CHECK(args->GetDouble(0, &count_double)); 255 CHECK(args->GetDouble(0, &count_double));
252 UMA_HISTOGRAM_COUNTS("SyncPromo.SignInAttempts", count_double); 256 UMA_HISTOGRAM_COUNTS("SyncPromo.SignInAttempts", count_double);
253 } 257 }
254 258
255 void SyncPromoHandler2::HandleUserFlowAction(const base::ListValue* args) { 259 void SyncPromoHandler2::HandleUserFlowAction(const base::ListValue* args) {
256 double action_double; 260 double action_double;
257 CHECK(args->GetDouble(0, &action_double)); 261 CHECK(args->GetDouble(0, &action_double));
258 int action = static_cast<int>(action_double); 262 int action = static_cast<int>(action_double);
259 263
260 if (IsValidUserFlowAction(action)) 264 if (IsValidUserFlowAction(action))
261 RecordUserFlowAction(action); 265 RecordUserFlowAction(action);
262 else 266 else
263 NOTREACHED() << "Attempt to record invalid user flow action on sync promo."; 267 NOTREACHED() << "Attempt to record invalid user flow action on sync promo.";
264 } 268 }
265 269
266 void SyncPromoHandler2::HandleUserSkipped(const base::ListValue* args) { 270 void SyncPromoHandler2::HandleUserSkipped(const base::ListValue* args) {
267 SyncPromoUI::SetUserSkippedSyncPromo(Profile::FromWebUI(web_ui_)); 271 SyncPromoUI::SetUserSkippedSyncPromo(Profile::FromWebUI(web_ui_));
268 RecordUserFlowAction(SYNC_PROMO_SKIP_CLICKED); 272 RecordUserFlowAction(SYNC_PROMO_SKIP_CLICKED);
269 } 273 }
270 274
271 int SyncPromoHandler2::GetViewCount() const { 275 int SyncPromoHandler2::GetViewCount() const {
272 // The locally persistent number of times the user has seen the sync promo. 276 // The locally persistent number of times the user has seen the sync promo.
273 return prefs_->GetInteger(prefs::kSyncPromoViewCount); 277 return prefs_->GetInteger(prefs::kSyncPromoViewCount);
274 } 278 }
275 279
276 int SyncPromoHandler2::IncrementViewCountBy(unsigned int amount) { 280 int SyncPromoHandler2::IncrementViewCountBy(size_t amount) {
277 // Let the user increment by 0 if they really want. It might be useful for a 281 // Let the user increment by 0 if they really want. It might be useful for a
278 // weird way of sending preference change notifications... 282 // weird way of sending preference change notifications...
279 int adjusted = GetViewCount() + amount; 283 int adjusted = GetViewCount() + amount;
280 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted); 284 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted);
281 return adjusted; 285 return adjusted;
282 } 286 }
283 287
284 void SyncPromoHandler2::RecordUserFlowAction(int action) { 288 void SyncPromoHandler2::RecordUserFlowAction(int action) {
285 // Send an enumeration to our single user flow histogram. 289 // Send an enumeration to our single user flow histogram.
286 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, 290 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action,
287 SYNC_PROMO_BUCKET_BOUNDARY); 291 SYNC_PROMO_BUCKET_BOUNDARY);
288 } 292 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_promo/sync_promo_handler2.h ('k') | chrome/browser/ui/webui/sync_promo/sync_promo_trial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698