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