| 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_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 "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/sync/profile_sync_service.h" | 12 #include "chrome/browser/sync/profile_sync_service.h" |
| 13 #include "chrome/browser/sync/sync_setup_flow.h" | 13 #include "chrome/browser/sync/sync_setup_flow.h" |
| 14 #include "chrome/browser/tabs/tab_strip_model.h" | 14 #include "chrome/browser/tabs/tab_strip_model.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list.h" |
| 17 #include "chrome/browser/ui/webui/sync_promo_ui.h" | 17 #include "chrome/browser/ui/webui/sync_promo_ui.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/extensions/extension_constants.h" | 19 #include "chrome/common/extensions/extension_constants.h" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 22 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
| 23 #include "content/common/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/notification_details.h" | 24 #include "content/public/browser/notification_details.h" |
| 25 | 25 |
| 26 SyncPromoHandler::SyncPromoHandler(ProfileManager* profile_manager) | 26 SyncPromoHandler::SyncPromoHandler(ProfileManager* profile_manager) |
| 27 : SyncSetupHandler(profile_manager), | 27 : SyncSetupHandler(profile_manager), |
| 28 window_already_closed_(false) { | 28 window_already_closed_(false) { |
| 29 } | 29 } |
| 30 | 30 |
| 31 SyncPromoHandler::~SyncPromoHandler() { | 31 SyncPromoHandler::~SyncPromoHandler() { |
| 32 } | 32 } |
| 33 | 33 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 46 DCHECK(prefs_); | 46 DCHECK(prefs_); |
| 47 // Ignore events from view-source:chrome://syncpromo. | 47 // Ignore events from view-source:chrome://syncpromo. |
| 48 if (!web_ui->tab_contents()->controller().GetActiveEntry()-> | 48 if (!web_ui->tab_contents()->controller().GetActiveEntry()-> |
| 49 IsViewSourceMode()) { | 49 IsViewSourceMode()) { |
| 50 // Listen to see if the tab we're in gets closed. | 50 // Listen to see if the tab we're in gets closed. |
| 51 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING, | 51 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING, |
| 52 content::Source<NavigationController>( | 52 content::Source<NavigationController>( |
| 53 &web_ui->tab_contents()->controller())); | 53 &web_ui->tab_contents()->controller())); |
| 54 // Listen to see if the window we're in gets closed. | 54 // Listen to see if the window we're in gets closed. |
| 55 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, | 55 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, |
| 56 NotificationService::AllSources()); | 56 content::NotificationService::AllSources()); |
| 57 } | 57 } |
| 58 return SyncSetupHandler::Attach(web_ui); | 58 return SyncSetupHandler::Attach(web_ui); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void SyncPromoHandler::RegisterMessages() { | 61 void SyncPromoHandler::RegisterMessages() { |
| 62 web_ui_->RegisterMessageCallback("SyncPromo:Close", | 62 web_ui_->RegisterMessageCallback("SyncPromo:Close", |
| 63 base::Bind(&SyncPromoHandler::HandleCloseSyncPromo, | 63 base::Bind(&SyncPromoHandler::HandleCloseSyncPromo, |
| 64 base::Unretained(this))); | 64 base::Unretained(this))); |
| 65 web_ui_->RegisterMessageCallback("SyncPromo:Initialize", | 65 web_ui_->RegisterMessageCallback("SyncPromo:Initialize", |
| 66 base::Bind(&SyncPromoHandler::HandleInitializeSyncPromo, | 66 base::Bind(&SyncPromoHandler::HandleInitializeSyncPromo, |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // Send an enumeration to our single user flow histogram. | 197 // Send an enumeration to our single user flow histogram. |
| 198 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, | 198 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, |
| 199 extension_misc::SYNC_PROMO_BUCKET_BOUNDARY); | 199 extension_misc::SYNC_PROMO_BUCKET_BOUNDARY); |
| 200 } | 200 } |
| 201 | 201 |
| 202 bool SyncPromoHandler::IsWelcomePage() { | 202 bool SyncPromoHandler::IsWelcomePage() { |
| 203 // If there's no previous page on this tab then it means that the promo was | 203 // If there's no previous page on this tab then it means that the promo was |
| 204 // displayed at startup. | 204 // displayed at startup. |
| 205 return !web_ui_->tab_contents()->controller().CanGoBack(); | 205 return !web_ui_->tab_contents()->controller().CanGoBack(); |
| 206 } | 206 } |
| OLD | NEW |