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

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

Issue 8689006: Create a field test for sync sign in promo strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: small typo spotted by tmccoy 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_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 "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_ui.h" 19 #include "chrome/browser/ui/webui/sync_promo_ui.h"
19 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/extensions/extension_constants.h" 21 #include "chrome/common/extensions/extension_constants.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
23 #include "content/browser/tab_contents/tab_contents.h" 24 #include "content/browser/tab_contents/tab_contents.h"
24 #include "content/public/browser/notification_details.h" 25 #include "content/public/browser/notification_details.h"
25 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
26 27
27 namespace { 28 namespace {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 base::Unretained(this))); 114 base::Unretained(this)));
114 web_ui_->RegisterMessageCallback("SyncPromo:UserFlowAction", 115 web_ui_->RegisterMessageCallback("SyncPromo:UserFlowAction",
115 base::Bind(&SyncPromoHandler::HandleUserFlowAction, 116 base::Bind(&SyncPromoHandler::HandleUserFlowAction,
116 base::Unretained(this))); 117 base::Unretained(this)));
117 web_ui_->RegisterMessageCallback("SyncPromo:UserSkipped", 118 web_ui_->RegisterMessageCallback("SyncPromo:UserSkipped",
118 base::Bind(&SyncPromoHandler::HandleUserSkipped, 119 base::Bind(&SyncPromoHandler::HandleUserSkipped,
119 base::Unretained(this))); 120 base::Unretained(this)));
120 SyncSetupHandler::RegisterMessages(); 121 SyncSetupHandler::RegisterMessages();
121 } 122 }
122 123
124 void SyncPromoHandler::ShowGaiaSuccessAndClose() {
125 if (sync_promo_trial::IsExperimentActive())
126 sync_promo_trial::RecordUserSignedIn();
127
128 SyncSetupHandler::ShowGaiaSuccessAndClose();
129 }
130
131 void SyncPromoHandler::ShowGaiaSuccessAndSettingUp() {
132 if (sync_promo_trial::IsExperimentActive())
133 sync_promo_trial::RecordUserSignedIn();
134
135 SyncSetupHandler::ShowGaiaSuccessAndSettingUp();
136 }
137
123 void SyncPromoHandler::ShowConfigure(const base::DictionaryValue& args) { 138 void SyncPromoHandler::ShowConfigure(const base::DictionaryValue& args) {
124 bool usePassphrase = false; 139 bool usePassphrase = false;
125 args.GetBoolean("usePassphrase", &usePassphrase); 140 args.GetBoolean("usePassphrase", &usePassphrase);
126 141
127 if (usePassphrase) { 142 if (usePassphrase) {
128 // If a passphrase is required then we must show the configure pane. 143 // If a passphrase is required then we must show the configure pane.
129 SyncSetupHandler::ShowConfigure(args); 144 SyncSetupHandler::ShowConfigure(args);
130 } else { 145 } else {
131 // If no passphrase is required then skip the configure pane and sync 146 // If no passphrase is required then skip the configure pane and sync
132 // everything by default. This makes the first run experience simpler. 147 // everything by default. This makes the first run experience simpler.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 if (!username.empty()) 194 if (!username.empty())
180 prefs_->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); 195 prefs_->SetBoolean(prefs::kSyncPromoShowNTPBubble, true);
181 196
182 GURL url = SyncPromoUI::GetNextPageURLForSyncPromoURL( 197 GURL url = SyncPromoUI::GetNextPageURLForSyncPromoURL(
183 web_ui_->tab_contents()->GetURL()); 198 web_ui_->tab_contents()->GetURL());
184 web_ui_->tab_contents()->OpenURL(url, GURL(), CURRENT_TAB, 199 web_ui_->tab_contents()->OpenURL(url, GURL(), CURRENT_TAB,
185 content::PAGE_TRANSITION_LINK); 200 content::PAGE_TRANSITION_LINK);
186 } 201 }
187 202
188 void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) { 203 void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) {
189 base::FundamentalValue visible(SyncPromoUI::GetShowTitleForSyncPromoURL( 204 // If the promo is also the Chrome launch page, we want to show the title and
190 web_ui_->tab_contents()->GetURL())); 205 // log an event if we are running an experiment.
206 bool is_launch_page = SyncPromoUI::GetIsLaunchPageForSyncPromoURL(
207 web_ui_->tab_contents()->GetURL());
208 if (is_launch_page && sync_promo_trial::IsExperimentActive())
209 sync_promo_trial::RecordUserSawMessage();
210 base::FundamentalValue visible(is_launch_page);
191 web_ui_->CallJavascriptFunction("SyncSetupOverlay.setPromoTitleVisible", 211 web_ui_->CallJavascriptFunction("SyncSetupOverlay.setPromoTitleVisible",
192 visible); 212 visible);
193 213
194 OpenSyncSetup(); 214 OpenSyncSetup();
195 // We don't need to compute anything for this, just do this every time. 215 // We don't need to compute anything for this, just do this every time.
196 RecordUserFlowAction(SYNC_PROMO_VIEWED); 216 RecordUserFlowAction(SYNC_PROMO_VIEWED);
197 // Increment view count first and show natural numbers in stats rather than 0 217 // Increment view count first and show natural numbers in stats rather than 0
198 // based starting point (if it happened to be our first time showing this). 218 // based starting point (if it happened to be our first time showing this).
199 IncrementViewCountBy(1); 219 IncrementViewCountBy(1);
200 // Record +1 for every view. This is the only thing we record that's not part 220 // Record +1 for every view. This is the only thing we record that's not part
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 int adjusted = GetViewCount() + amount; 274 int adjusted = GetViewCount() + amount;
255 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted); 275 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted);
256 return adjusted; 276 return adjusted;
257 } 277 }
258 278
259 void SyncPromoHandler::RecordUserFlowAction(int action) { 279 void SyncPromoHandler::RecordUserFlowAction(int action) {
260 // Send an enumeration to our single user flow histogram. 280 // Send an enumeration to our single user flow histogram.
261 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, 281 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action,
262 SYNC_PROMO_BUCKET_BOUNDARY); 282 SYNC_PROMO_BUCKET_BOUNDARY);
263 } 283 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_promo_handler.h ('k') | chrome/browser/ui/webui/sync_promo_trial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698