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

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

Issue 1151563005: Revert of NTP Zombie Code Slayer Part IV: Most Visited (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 base::Unretained(this))); 61 base::Unretained(this)));
62 web_ui()->RegisterMessageCallback("bubblePromoViewed", 62 web_ui()->RegisterMessageCallback("bubblePromoViewed",
63 base::Bind(&NewTabPageHandler::HandleBubblePromoViewed, 63 base::Bind(&NewTabPageHandler::HandleBubblePromoViewed,
64 base::Unretained(this))); 64 base::Unretained(this)));
65 web_ui()->RegisterMessageCallback("bubblePromoLinkClicked", 65 web_ui()->RegisterMessageCallback("bubblePromoLinkClicked",
66 base::Bind(&NewTabPageHandler::HandleBubblePromoLinkClicked, 66 base::Bind(&NewTabPageHandler::HandleBubblePromoLinkClicked,
67 base::Unretained(this))); 67 base::Unretained(this)));
68 web_ui()->RegisterMessageCallback("pageSelected", 68 web_ui()->RegisterMessageCallback("pageSelected",
69 base::Bind(&NewTabPageHandler::HandlePageSelected, 69 base::Bind(&NewTabPageHandler::HandlePageSelected,
70 base::Unretained(this))); 70 base::Unretained(this)));
71 web_ui()->RegisterMessageCallback("logTimeToClick",
72 base::Bind(&NewTabPageHandler::HandleLogTimeToClick,
73 base::Unretained(this)));
71 } 74 }
72 75
73 void NewTabPageHandler::HandleNotificationPromoClosed( 76 void NewTabPageHandler::HandleNotificationPromoClosed(
74 const base::ListValue* args) { 77 const base::ListValue* args) {
75 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Notification", 78 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Notification",
76 PROMO_CLOSED, PROMO_ACTION_MAX); 79 PROMO_CLOSED, PROMO_ACTION_MAX);
77 NotificationPromo::HandleClosed(NotificationPromo::NTP_NOTIFICATION_PROMO); 80 NotificationPromo::HandleClosed(NotificationPromo::NTP_NOTIFICATION_PROMO);
78 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); 81 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
79 } 82 }
80 83
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 UMA_HISTOGRAM_ENUMERATION("NewTabPage.PreviousSelectedPageType", 136 UMA_HISTOGRAM_ENUMERATION("NewTabPage.PreviousSelectedPageType",
134 previous_shown_page, kHistogramEnumerationMax); 137 previous_shown_page, kHistogramEnumerationMax);
135 138
136 prefs->SetInteger(prefs::kNtpShownPage, page_id | index); 139 prefs->SetInteger(prefs::kNtpShownPage, page_id | index);
137 140
138 int shown_page_type = page_id >> kPageIdOffset; 141 int shown_page_type = page_id >> kPageIdOffset;
139 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SelectedPageType", 142 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SelectedPageType",
140 shown_page_type, kHistogramEnumerationMax); 143 shown_page_type, kHistogramEnumerationMax);
141 } 144 }
142 145
146 void NewTabPageHandler::HandleLogTimeToClick(const base::ListValue* args) {
147 std::string histogram_name;
148 double duration;
149 if (!args->GetString(0, &histogram_name) || !args->GetDouble(1, &duration)) {
150 NOTREACHED();
151 return;
152 }
153
154 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(duration);
155
156 if (histogram_name == "NewTabPage.TimeToClickMostVisited") {
157 UMA_HISTOGRAM_LONG_TIMES("NewTabPage.TimeToClickMostVisited", delta);
158 } else if (histogram_name == "ExtendedNewTabPage.TimeToClickMostVisited") {
159 UMA_HISTOGRAM_LONG_TIMES(
160 "ExtendedNewTabPage.TimeToClickMostVisited", delta);
161 } else {
162 NOTREACHED();
163 }
164 }
165
143 // static 166 // static
144 void NewTabPageHandler::RegisterProfilePrefs( 167 void NewTabPageHandler::RegisterProfilePrefs(
145 user_prefs::PrefRegistrySyncable* registry) { 168 user_prefs::PrefRegistrySyncable* registry) {
146 // TODO(estade): should be syncable. 169 // TODO(estade): should be syncable.
147 registry->RegisterIntegerPref(prefs::kNtpShownPage, APPS_PAGE_ID); 170 registry->RegisterIntegerPref(prefs::kNtpShownPage, APPS_PAGE_ID);
148 } 171 }
149 172
150 // static 173 // static
151 void NewTabPageHandler::GetLocalizedValues(Profile* profile, 174 void NewTabPageHandler::GetLocalizedValues(Profile* profile,
152 base::DictionaryValue* values) { 175 base::DictionaryValue* values) {
176 values->SetInteger("most_visited_page_id", MOST_VISITED_PAGE_ID);
153 values->SetInteger("apps_page_id", APPS_PAGE_ID); 177 values->SetInteger("apps_page_id", APPS_PAGE_ID);
154 178
155 PrefService* prefs = profile->GetPrefs(); 179 PrefService* prefs = profile->GetPrefs();
156 int shown_page = prefs->GetInteger(prefs::kNtpShownPage); 180 int shown_page = prefs->GetInteger(prefs::kNtpShownPage);
157 values->SetInteger("shown_page_type", shown_page & ~INDEX_MASK); 181 values->SetInteger("shown_page_type", shown_page & ~INDEX_MASK);
158 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); 182 values->SetInteger("shown_page_index", shown_page & INDEX_MASK);
159 } 183 }
160 184
161 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { 185 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) {
162 content::NotificationService* service = 186 content::NotificationService* service =
163 content::NotificationService::current(); 187 content::NotificationService::current();
164 service->Notify(notification_type, 188 service->Notify(notification_type,
165 content::Source<NewTabPageHandler>(this), 189 content::Source<NewTabPageHandler>(this),
166 content::NotificationService::NoDetails()); 190 content::NotificationService::NoDetails());
167 } 191 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_page_handler.h ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698