| 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/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" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) { | 194 void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) { |
| 195 CloseSyncSetup(); | 195 CloseSyncSetup(); |
| 196 | 196 |
| 197 // If the user has signed in then set the pref to show them NTP bubble | 197 // If the user has signed in then set the pref to show them NTP bubble |
| 198 // confirming that they're signed in. | 198 // confirming that they're signed in. |
| 199 std::string username = prefs_->GetString(prefs::kGoogleServicesUsername); | 199 std::string username = prefs_->GetString(prefs::kGoogleServicesUsername); |
| 200 if (!username.empty()) | 200 if (!username.empty()) |
| 201 prefs_->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); | 201 prefs_->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); |
| 202 | 202 |
| 203 GURL url = SyncPromoUI::GetNextPageURLForSyncPromoURL( | 203 // If the browser window is being closed then don't try to navigate to |
| 204 web_ui()->GetWebContents()->GetURL()); | 204 // another URL. This prevents the browser window from flashing during |
| 205 OpenURLParams params( | 205 // close. |
| 206 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); | 206 Browser* browser = |
| 207 web_ui()->GetWebContents()->OpenURL(params); | 207 BrowserList::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
| 208 if (browser && !browser->IsAttemptingToCloseBrowser()) { |
| 209 GURL url = SyncPromoUI::GetNextPageURLForSyncPromoURL( |
| 210 web_ui()->GetWebContents()->GetURL()); |
| 211 OpenURLParams params( |
| 212 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); |
| 213 web_ui()->GetWebContents()->OpenURL(params); |
| 214 } |
| 208 } | 215 } |
| 209 | 216 |
| 210 void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) { | 217 void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) { |
| 211 // If the promo is also the Chrome launch page, we want to show the title and | 218 // If the promo is also the Chrome launch page, we want to show the title and |
| 212 // log an event if we are running an experiment. | 219 // log an event if we are running an experiment. |
| 213 bool is_launch_page = SyncPromoUI::GetIsLaunchPageForSyncPromoURL( | 220 bool is_launch_page = SyncPromoUI::GetIsLaunchPageForSyncPromoURL( |
| 214 web_ui()->GetWebContents()->GetURL()); | 221 web_ui()->GetWebContents()->GetURL()); |
| 215 if (is_launch_page && sync_promo_trial::IsExperimentActive()) | 222 if (is_launch_page && sync_promo_trial::IsExperimentActive()) |
| 216 sync_promo_trial::RecordUserSawMessage(); | 223 sync_promo_trial::RecordUserSawMessage(); |
| 217 base::FundamentalValue visible(is_launch_page); | 224 base::FundamentalValue visible(is_launch_page); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 Profile* profile = Profile::FromWebUI(web_ui()); | 300 Profile* profile = Profile::FromWebUI(web_ui()); |
| 294 sync_promo_trial::RecordUserSignedInWithTrialBrand(is_start_up, profile); | 301 sync_promo_trial::RecordUserSignedInWithTrialBrand(is_start_up, profile); |
| 295 } | 302 } |
| 296 } | 303 } |
| 297 | 304 |
| 298 void SyncPromoHandler::RecordUserFlowAction(int action) { | 305 void SyncPromoHandler::RecordUserFlowAction(int action) { |
| 299 // Send an enumeration to our single user flow histogram. | 306 // Send an enumeration to our single user flow histogram. |
| 300 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, | 307 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, |
| 301 SYNC_PROMO_BUCKET_BOUNDARY); | 308 SYNC_PROMO_BUCKET_BOUNDARY); |
| 302 } | 309 } |
| OLD | NEW |