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

Side by Side Diff: chrome/browser/ui/webui/ntp/new_tab_page_handler.cc

Issue 11689004: Move PromoResourceService from Profile to BrowserProcessImpl/local_state(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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/ntp/new_tab_page_handler.h" 5 #include "chrome/browser/ui/webui/ntp/new_tab_page_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/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/sync/profile_sync_service.h" 13 #include "chrome/browser/sync/profile_sync_service.h"
15 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 14 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
16 #include "chrome/browser/web_resource/notification_promo.h" 15 #include "chrome/browser/web_resource/notification_promo.h"
17 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
18 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/web_ui.h" 18 #include "content/public/browser/web_ui.h"
20 #include "grit/chromium_strings.h" 19 #include "grit/chromium_strings.h"
21 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 base::Bind(&NewTabPageHandler::HandlePageSelected, 71 base::Bind(&NewTabPageHandler::HandlePageSelected,
73 base::Unretained(this))); 72 base::Unretained(this)));
74 web_ui()->RegisterMessageCallback("logTimeToClick", 73 web_ui()->RegisterMessageCallback("logTimeToClick",
75 base::Bind(&NewTabPageHandler::HandleLogTimeToClick, 74 base::Bind(&NewTabPageHandler::HandleLogTimeToClick,
76 base::Unretained(this))); 75 base::Unretained(this)));
77 } 76 }
78 77
79 void NewTabPageHandler::HandleNotificationPromoClosed(const ListValue* args) { 78 void NewTabPageHandler::HandleNotificationPromoClosed(const ListValue* args) {
80 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Notification", 79 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Notification",
81 PROMO_CLOSED, PROMO_ACTION_MAX); 80 PROMO_CLOSED, PROMO_ACTION_MAX);
82 NotificationPromo::HandleClosed(Profile::FromWebUI(web_ui()), 81 NotificationPromo::HandleClosed(NotificationPromo::NTP_NOTIFICATION_PROMO);
83 NotificationPromo::NTP_NOTIFICATION_PROMO);
84 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); 82 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
85 } 83 }
86 84
87 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) { 85 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) {
88 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Notification", 86 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Notification",
89 PROMO_VIEWED, PROMO_ACTION_MAX); 87 PROMO_VIEWED, PROMO_ACTION_MAX);
90 if (NotificationPromo::HandleViewed(Profile::FromWebUI(web_ui()), 88 if (NotificationPromo::HandleViewed(
91 NotificationPromo::NTP_NOTIFICATION_PROMO)) { 89 NotificationPromo::NTP_NOTIFICATION_PROMO)) {
92 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); 90 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
93 } 91 }
94 } 92 }
95 93
96 void NewTabPageHandler::HandleNotificationPromoLinkClicked( 94 void NewTabPageHandler::HandleNotificationPromoLinkClicked(
97 const ListValue* args) { 95 const ListValue* args) {
98 DVLOG(1) << "HandleNotificationPromoLinkClicked"; 96 DVLOG(1) << "HandleNotificationPromoLinkClicked";
99 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Notification", 97 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Notification",
100 PROMO_LINK_CLICKED, PROMO_ACTION_MAX); 98 PROMO_LINK_CLICKED, PROMO_ACTION_MAX);
101 } 99 }
102 100
103 void NewTabPageHandler::HandleBubblePromoClosed(const ListValue* args) { 101 void NewTabPageHandler::HandleBubblePromoClosed(const ListValue* args) {
104 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Bubble", 102 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Bubble",
105 PROMO_CLOSED, PROMO_ACTION_MAX); 103 PROMO_CLOSED, PROMO_ACTION_MAX);
106 NotificationPromo::HandleClosed(Profile::FromWebUI(web_ui()), 104 NotificationPromo::HandleClosed(NotificationPromo::NTP_BUBBLE_PROMO);
107 NotificationPromo::NTP_BUBBLE_PROMO);
108 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); 105 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
109 } 106 }
110 107
111 void NewTabPageHandler::HandleBubblePromoViewed(const ListValue* args) { 108 void NewTabPageHandler::HandleBubblePromoViewed(const ListValue* args) {
112 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Bubble", 109 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Bubble",
113 PROMO_VIEWED, PROMO_ACTION_MAX); 110 PROMO_VIEWED, PROMO_ACTION_MAX);
114 if (NotificationPromo::HandleViewed(Profile::FromWebUI(web_ui()), 111 if (NotificationPromo::HandleViewed(NotificationPromo::NTP_BUBBLE_PROMO))
115 NotificationPromo::NTP_BUBBLE_PROMO)) {
116 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); 112 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
117 }
118 } 113 }
119 114
120 void NewTabPageHandler::HandleBubblePromoLinkClicked(const ListValue* args) { 115 void NewTabPageHandler::HandleBubblePromoLinkClicked(const ListValue* args) {
121 DVLOG(1) << "HandleBubblePromoLinkClicked"; 116 DVLOG(1) << "HandleBubblePromoLinkClicked";
122 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Bubble", 117 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Bubble",
123 PROMO_LINK_CLICKED, PROMO_ACTION_MAX); 118 PROMO_LINK_CLICKED, PROMO_ACTION_MAX);
124 } 119 }
125 120
126 void NewTabPageHandler::HandlePageSelected(const ListValue* args) { 121 void NewTabPageHandler::HandlePageSelected(const ListValue* args) {
127 page_switch_count_++; 122 page_switch_count_++;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); 191 values->SetInteger("shown_page_index", shown_page & INDEX_MASK);
197 } 192 }
198 193
199 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { 194 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) {
200 content::NotificationService* service = 195 content::NotificationService* service =
201 content::NotificationService::current(); 196 content::NotificationService::current();
202 service->Notify(notification_type, 197 service->Notify(notification_type,
203 content::Source<NewTabPageHandler>(this), 198 content::Source<NewTabPageHandler>(this),
204 content::NotificationService::NoDetails()); 199 content::NotificationService::NoDetails());
205 } 200 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698