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

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

Issue 10079023: Move notifications used only in chrome/ out of content/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: six! Created 8 years, 8 months 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) 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/time.h" 10 #include "base/time.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void SyncPromoHandler::RegisterMessages() { 84 void SyncPromoHandler::RegisterMessages() {
85 // Keep a reference to the preferences service for convenience and it's 85 // Keep a reference to the preferences service for convenience and it's
86 // probably a little faster that getting it via Profile::FromWebUI() every 86 // probably a little faster that getting it via Profile::FromWebUI() every
87 // time we need to interact with preferences. 87 // time we need to interact with preferences.
88 prefs_ = Profile::FromWebUI(web_ui())->GetPrefs(); 88 prefs_ = Profile::FromWebUI(web_ui())->GetPrefs();
89 DCHECK(prefs_); 89 DCHECK(prefs_);
90 // Ignore events from view-source:chrome://signin. 90 // Ignore events from view-source:chrome://signin.
91 if (!web_ui()->GetWebContents()->GetController().GetActiveEntry()-> 91 if (!web_ui()->GetWebContents()->GetController().GetActiveEntry()->
92 IsViewSourceMode()) { 92 IsViewSourceMode()) {
93 // Listen to see if the tab we're in gets closed. 93 // Listen to see if the tab we're in gets closed.
94 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING, 94 registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING,
95 content::Source<NavigationController>( 95 content::Source<NavigationController>(
96 &web_ui()->GetWebContents()->GetController())); 96 &web_ui()->GetWebContents()->GetController()));
97 // Listen to see if the window we're in gets closed. 97 // Listen to see if the window we're in gets closed.
98 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, 98 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING,
99 content::NotificationService::AllSources()); 99 content::NotificationService::AllSources());
100 } 100 }
101 101
102 web_ui()->RegisterMessageCallback("SyncPromo:Close", 102 web_ui()->RegisterMessageCallback("SyncPromo:Close",
103 base::Bind(&SyncPromoHandler::HandleCloseSyncPromo, 103 base::Bind(&SyncPromoHandler::HandleCloseSyncPromo,
104 base::Unretained(this))); 104 base::Unretained(this)));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // to Settings where the configure pane is not skipped. 141 // to Settings where the configure pane is not skipped.
142 service->OnUserChoseDatatypes(true, syncable::ModelTypeSet()); 142 service->OnUserChoseDatatypes(true, syncable::ModelTypeSet());
143 ConfigureSyncDone(); 143 ConfigureSyncDone();
144 } 144 }
145 } 145 }
146 146
147 void SyncPromoHandler::Observe(int type, 147 void SyncPromoHandler::Observe(int type,
148 const content::NotificationSource& source, 148 const content::NotificationSource& source,
149 const content::NotificationDetails& details) { 149 const content::NotificationDetails& details) {
150 switch (type) { 150 switch (type) {
151 case content::NOTIFICATION_TAB_CLOSING: { 151 case chrome::NOTIFICATION_TAB_CLOSING: {
152 if (!window_already_closed_) 152 if (!window_already_closed_)
153 RecordUserFlowAction(SYNC_PROMO_CLOSED_TAB); 153 RecordUserFlowAction(SYNC_PROMO_CLOSED_TAB);
154 break; 154 break;
155 } 155 }
156 case chrome::NOTIFICATION_BROWSER_CLOSING: { 156 case chrome::NOTIFICATION_BROWSER_CLOSING: {
157 // Make sure we're in the tab strip of the closing window. 157 // Make sure we're in the tab strip of the closing window.
158 Browser* browser = content::Source<Browser>(source).ptr(); 158 Browser* browser = content::Source<Browser>(source).ptr();
159 if (browser->tabstrip_model()->GetWrapperIndex( 159 if (browser->tabstrip_model()->GetWrapperIndex(
160 web_ui()->GetWebContents()) != TabStripModel::kNoTab) { 160 web_ui()->GetWebContents()) != TabStripModel::kNoTab) {
161 RecordUserFlowAction(SYNC_PROMO_CLOSED_WINDOW); 161 RecordUserFlowAction(SYNC_PROMO_CLOSED_WINDOW);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 int adjusted = GetViewCount() + amount; 261 int adjusted = GetViewCount() + amount;
262 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted); 262 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted);
263 return adjusted; 263 return adjusted;
264 } 264 }
265 265
266 void SyncPromoHandler::RecordUserFlowAction(int action) { 266 void SyncPromoHandler::RecordUserFlowAction(int action) {
267 // Send an enumeration to our single user flow histogram. 267 // Send an enumeration to our single user flow histogram.
268 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, 268 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action,
269 SYNC_PROMO_BUCKET_BOUNDARY); 269 SYNC_PROMO_BUCKET_BOUNDARY);
270 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698