OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 SyncPromoHandler::SyncPromoHandler(ProfileManager* profile_manager) | 71 SyncPromoHandler::SyncPromoHandler(ProfileManager* profile_manager) |
72 : SyncSetupHandler(profile_manager), | 72 : SyncSetupHandler(profile_manager), |
73 prefs_(NULL), | 73 prefs_(NULL), |
74 window_already_closed_(false) { | 74 window_already_closed_(false) { |
75 } | 75 } |
76 | 76 |
77 SyncPromoHandler::~SyncPromoHandler() { | 77 SyncPromoHandler::~SyncPromoHandler() { |
78 } | 78 } |
79 | 79 |
80 // static | 80 // static |
81 void SyncPromoHandler::RegisterUserPrefs(PrefRegistrySyncable* registry) { | 81 void SyncPromoHandler::RegisterUserPrefs( |
82 registry->RegisterIntegerPref(prefs::kSyncPromoViewCount, 0, | 82 user_prefs::PrefRegistrySyncable* registry) { |
83 PrefRegistrySyncable::UNSYNCABLE_PREF); | 83 registry->RegisterIntegerPref( |
84 registry->RegisterBooleanPref(prefs::kSyncPromoShowNTPBubble, false, | 84 prefs::kSyncPromoViewCount, |
85 PrefRegistrySyncable::UNSYNCABLE_PREF); | 85 0, |
86 registry->RegisterStringPref(prefs::kSyncPromoErrorMessage, std::string(), | 86 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
87 PrefRegistrySyncable::UNSYNCABLE_PREF); | 87 registry->RegisterBooleanPref( |
| 88 prefs::kSyncPromoShowNTPBubble, |
| 89 false, |
| 90 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 91 registry->RegisterStringPref( |
| 92 prefs::kSyncPromoErrorMessage, |
| 93 std::string(), |
| 94 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
88 } | 95 } |
89 | 96 |
90 void SyncPromoHandler::RegisterMessages() { | 97 void SyncPromoHandler::RegisterMessages() { |
91 // Keep a reference to the preferences service for convenience and it's | 98 // Keep a reference to the preferences service for convenience and it's |
92 // probably a little faster that getting it via Profile::FromWebUI() every | 99 // probably a little faster that getting it via Profile::FromWebUI() every |
93 // time we need to interact with preferences. | 100 // time we need to interact with preferences. |
94 prefs_ = Profile::FromWebUI(web_ui())->GetPrefs(); | 101 prefs_ = Profile::FromWebUI(web_ui())->GetPrefs(); |
95 DCHECK(prefs_); | 102 DCHECK(prefs_); |
96 // Ignore events from view-source:chrome://signin. | 103 // Ignore events from view-source:chrome://signin. |
97 if (!web_ui()->GetWebContents()->GetController().GetActiveEntry()-> | 104 if (!web_ui()->GetWebContents()->GetController().GetActiveEntry()-> |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // Send an enumeration to our single user flow histogram. | 295 // Send an enumeration to our single user flow histogram. |
289 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, | 296 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, |
290 SYNC_PROMO_BUCKET_BOUNDARY); | 297 SYNC_PROMO_BUCKET_BOUNDARY); |
291 } | 298 } |
292 | 299 |
293 void SyncPromoHandler::CloseUI() { | 300 void SyncPromoHandler::CloseUI() { |
294 // Callers should not ever try to close the promo UI (should only call | 301 // Callers should not ever try to close the promo UI (should only call |
295 // CloseUI() if the user is already logged in). | 302 // CloseUI() if the user is already logged in). |
296 NOTREACHED() << "Cannot close the promo UI"; | 303 NOTREACHED() << "Cannot close the promo UI"; |
297 } | 304 } |
OLD | NEW |