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

Side by Side Diff: chrome/browser/ui/webui/sync_promo_handler.cc

Issue 8528054: Sync Promo: Add more UMA metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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_handler.h" 5 #include "chrome/browser/ui/webui/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 "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/sync/profile_sync_service.h" 13 #include "chrome/browser/sync/profile_sync_service.h"
13 #include "chrome/browser/sync/sync_setup_flow.h" 14 #include "chrome/browser/sync/sync_setup_flow.h"
14 #include "chrome/browser/tabs/tab_strip_model.h" 15 #include "chrome/browser/tabs/tab_strip_model.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_list.h" 17 #include "chrome/browser/ui/browser_list.h"
17 #include "chrome/browser/ui/webui/sync_promo_ui.h" 18 #include "chrome/browser/ui/webui/sync_promo_ui.h"
18 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/extensions/extension_constants.h" 20 #include "chrome/common/extensions/extension_constants.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
21 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
22 #include "content/browser/tab_contents/tab_contents.h" 23 #include "content/browser/tab_contents/tab_contents.h"
24 #include "content/public/browser/notification_details.h"
23 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/notification_details.h" 26
27 namespace {
28
29 // This was added because of the need to change the existing UMA enum for the
30 // sync promo mid-flight. Ideally these values would be contiguous, but the
31 // real world is not always ideal.
32 static bool IsValidUserFlowAction(int action) {
33 return (action >= extension_misc::SYNC_PROMO_FIRST_VALID_JS_ACTION &&
34 action <= extension_misc::SYNC_PROMO_LAST_VALID_JS_ACTION) ||
35 action == extension_misc::SYNC_PROMO_LEFT_DURING_THROBBER;
36 }
37
38 } // namespace
25 39
26 SyncPromoHandler::SyncPromoHandler(ProfileManager* profile_manager) 40 SyncPromoHandler::SyncPromoHandler(ProfileManager* profile_manager)
27 : SyncSetupHandler(profile_manager), 41 : SyncSetupHandler(profile_manager),
28 window_already_closed_(false) { 42 window_already_closed_(false) {
29 } 43 }
30 44
31 SyncPromoHandler::~SyncPromoHandler() { 45 SyncPromoHandler::~SyncPromoHandler() {
32 } 46 }
33 47
34 // static 48 // static
(...skipping 25 matching lines...) Expand all
60 return SyncSetupHandler::Attach(web_ui); 74 return SyncSetupHandler::Attach(web_ui);
61 } 75 }
62 76
63 void SyncPromoHandler::RegisterMessages() { 77 void SyncPromoHandler::RegisterMessages() {
64 web_ui_->RegisterMessageCallback("SyncPromo:Close", 78 web_ui_->RegisterMessageCallback("SyncPromo:Close",
65 base::Bind(&SyncPromoHandler::HandleCloseSyncPromo, 79 base::Bind(&SyncPromoHandler::HandleCloseSyncPromo,
66 base::Unretained(this))); 80 base::Unretained(this)));
67 web_ui_->RegisterMessageCallback("SyncPromo:Initialize", 81 web_ui_->RegisterMessageCallback("SyncPromo:Initialize",
68 base::Bind(&SyncPromoHandler::HandleInitializeSyncPromo, 82 base::Bind(&SyncPromoHandler::HandleInitializeSyncPromo,
69 base::Unretained(this))); 83 base::Unretained(this)));
84 web_ui_->RegisterMessageCallback("SyncPromo:RecordSignInAttempts",
85 base::Bind(&SyncPromoHandler::HandleRecordSignInAttempts,
86 base::Unretained(this)));
87 web_ui_->RegisterMessageCallback("SyncPromo:RecordThrobberTime",
88 base::Bind(&SyncPromoHandler::HandleRecordThrobberTime,
89 base::Unretained(this)));
90 web_ui_->RegisterMessageCallback("SyncPromo:ShowAdvancedSettings",
91 base::Bind(&SyncPromoHandler::HandleShowAdvancedSettings,
92 base::Unretained(this)));
70 web_ui_->RegisterMessageCallback("SyncPromo:UserFlowAction", 93 web_ui_->RegisterMessageCallback("SyncPromo:UserFlowAction",
71 base::Bind(&SyncPromoHandler::HandleUserFlowAction, 94 base::Bind(&SyncPromoHandler::HandleUserFlowAction,
72 base::Unretained(this))); 95 base::Unretained(this)));
73 web_ui_->RegisterMessageCallback("SyncPromo:ShowAdvancedSettings",
74 base::Bind(&SyncPromoHandler::HandleShowAdvancedSettings,
75 base::Unretained(this)));
76 SyncSetupHandler::RegisterMessages(); 96 SyncSetupHandler::RegisterMessages();
77 } 97 }
78 98
79 void SyncPromoHandler::ShowConfigure(const base::DictionaryValue& args) { 99 void SyncPromoHandler::ShowConfigure(const base::DictionaryValue& args) {
80 bool usePassphrase = false; 100 bool usePassphrase = false;
81 args.GetBoolean("usePassphrase", &usePassphrase); 101 args.GetBoolean("usePassphrase", &usePassphrase);
82 102
83 if (usePassphrase) { 103 if (usePassphrase) {
84 // If a passphrase is required then we must show the configure pane. 104 // If a passphrase is required then we must show the configure pane.
85 SyncSetupHandler::ShowConfigure(args); 105 SyncSetupHandler::ShowConfigure(args);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 void SyncPromoHandler::HandleShowAdvancedSettings( 181 void SyncPromoHandler::HandleShowAdvancedSettings(
162 const base::ListValue* args) { 182 const base::ListValue* args) {
163 CloseSyncSetup(); 183 CloseSyncSetup();
164 std::string url(chrome::kChromeUISettingsURL); 184 std::string url(chrome::kChromeUISettingsURL);
165 url += chrome::kSyncSetupSubPage; 185 url += chrome::kSyncSetupSubPage;
166 web_ui_->tab_contents()->OpenURL(GURL(url), GURL(), CURRENT_TAB, 186 web_ui_->tab_contents()->OpenURL(GURL(url), GURL(), CURRENT_TAB,
167 content::PAGE_TRANSITION_LINK); 187 content::PAGE_TRANSITION_LINK);
168 RecordUserFlowAction(extension_misc::SYNC_PROMO_ADVANCED_CLICKED); 188 RecordUserFlowAction(extension_misc::SYNC_PROMO_ADVANCED_CLICKED);
169 } 189 }
170 190
191 // TODO(dbeam): Replace with metricsHandler:recordHistogramTime when it exists.
192 void SyncPromoHandler::HandleRecordThrobberTime(const base::ListValue* args) {
193 double time_double;
194 CHECK(args->GetDouble(0, &time_double));
195 UMA_HISTOGRAM_TIMES("SyncPromo.ThrobberTime",
196 base::TimeDelta::FromMilliseconds(time_double));
197 }
198
199 // TODO(dbeam): Replace with metricsHandler:recordHistogramCount when it exists.
200 void SyncPromoHandler::HandleRecordSignInAttempts(const base::ListValue* args) {
201 double count_double;
202 CHECK(args->GetDouble(0, &count_double));
203 UMA_HISTOGRAM_COUNTS("SyncPromo.SignInAttempts", count_double);
204 }
205
171 void SyncPromoHandler::HandleUserFlowAction(const base::ListValue* args) { 206 void SyncPromoHandler::HandleUserFlowAction(const base::ListValue* args) {
172 double action_double; 207 double action_double;
173 CHECK(args->GetDouble(0, &action_double)); 208 CHECK(args->GetDouble(0, &action_double));
174 int action = static_cast<int>(action_double); 209 int action = static_cast<int>(action_double);
175 if (action >= extension_misc::SYNC_PROMO_FIRST_VALID_JS_ACTION && 210
176 action <= extension_misc::SYNC_PROMO_LAST_VALID_JS_ACTION) { 211 if (IsValidUserFlowAction(action))
177 RecordUserFlowAction(action); 212 RecordUserFlowAction(action);
178 } else { 213 else
179 NOTREACHED() << "Attempt to record invalid user flow action on sync promo."; 214 NOTREACHED() << "Attempt to record invalid user flow action on sync promo.";
180 }
181 215
216 // TODO(dbeam): Should this be here or in a separate handler? This method was
Evan Stade 2011/11/15 17:45:19 agree it should be separate
Dan Beam 2011/11/15 18:37:13 Done.
217 // meant solely for UMA reporting.
182 if (action == extension_misc::SYNC_PROMO_SKIP_CLICKED) 218 if (action == extension_misc::SYNC_PROMO_SKIP_CLICKED)
183 SyncPromoUI::SetUserSkippedSyncPromo(Profile::FromWebUI(web_ui_)); 219 SyncPromoUI::SetUserSkippedSyncPromo(Profile::FromWebUI(web_ui_));
184 } 220 }
185 221
186 int SyncPromoHandler::GetViewCount() const { 222 int SyncPromoHandler::GetViewCount() const {
187 // The locally persistent number of times the user has seen the sync promo. 223 // The locally persistent number of times the user has seen the sync promo.
188 return prefs_->GetInteger(prefs::kSyncPromoViewCount); 224 return prefs_->GetInteger(prefs::kSyncPromoViewCount);
189 } 225 }
190 226
191 int SyncPromoHandler::IncrementViewCountBy(unsigned int amount) { 227 int SyncPromoHandler::IncrementViewCountBy(unsigned int amount) {
192 // Let the user increment by 0 if they really want. It might be useful for a 228 // Let the user increment by 0 if they really want. It might be useful for a
193 // weird way of sending preference change notifications... 229 // weird way of sending preference change notifications...
194 int adjusted = GetViewCount() + amount; 230 int adjusted = GetViewCount() + amount;
195 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted); 231 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted);
196 return adjusted; 232 return adjusted;
197 } 233 }
198 234
199 void SyncPromoHandler::RecordUserFlowAction(int action) { 235 void SyncPromoHandler::RecordUserFlowAction(int action) {
200 // Send an enumeration to our single user flow histogram. 236 // Send an enumeration to our single user flow histogram.
201 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, 237 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action,
202 extension_misc::SYNC_PROMO_BUCKET_BOUNDARY); 238 extension_misc::SYNC_PROMO_BUCKET_BOUNDARY);
203 } 239 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698