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

Side by Side Diff: chrome/browser/resources/ntp_android/ntp_android.js

Issue 70083009: Record NewTabPage.MostVisited histogram on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/ntp/new_tab_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // File Description: 5 // File Description:
6 // Contains all the necessary functions for rendering the NTP on mobile 6 // Contains all the necessary functions for rendering the NTP on mobile
7 // devices. 7 // devices.
8 8
9 /** 9 /**
10 * The event type used to determine when a touch starts. 10 * The event type used to determine when a touch starts.
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 */ 936 */
937 function setMostVisitedPages(data, hasBlacklistedUrls) { 937 function setMostVisitedPages(data, hasBlacklistedUrls) {
938 setNumberOfMostVisitedPages(data.length); 938 setNumberOfMostVisitedPages(data.length);
939 // limit the number of most visited items to display 939 // limit the number of most visited items to display
940 if (isPhone() && data.length > 6) { 940 if (isPhone() && data.length > 6) {
941 data.splice(6, data.length - 6); 941 data.splice(6, data.length - 6);
942 } else if (isTablet() && data.length > 8) { 942 } else if (isTablet() && data.length > 8) {
943 data.splice(8, data.length - 8); 943 data.splice(8, data.length - 8);
944 } 944 }
945 945
946 data.forEach(function(item, index) {
947 item.mostVisitedIndex = index;
948 });
Dan Beam 2013/11/14 04:44:38 nit: I'd strip off this duplicate/volatile data an
newt (away) 2013/11/14 18:44:02 If it's OK with you, I think I'll leave this as is
Dan Beam 2013/11/14 19:16:03 that's fine.
949
946 if (equals(data, mostVisitedData_)) 950 if (equals(data, mostVisitedData_))
947 return; 951 return;
948 952
949 var clickFunction = function(item) { 953 var clickFunction = function(item) {
950 chrome.send('openedMostVisited'); 954 chrome.send('openedMostVisited');
955 chrome.send('metricsHandler:recordInHistogram',
956 ['NewTabPage.MostVisited', item.mostVisitedIndex, 8]);
951 window.location = item.url; 957 window.location = item.url;
952 }; 958 };
953 populateData(findList('most_visited'), SectionType.MOST_VISITED, data, 959 populateData(findList('most_visited'), SectionType.MOST_VISITED, data,
954 makeMostVisitedItem, clickFunction); 960 makeMostVisitedItem, clickFunction);
955 computeDynamicLayout(); 961 computeDynamicLayout();
956 962
957 mostVisitedData_ = data; 963 mostVisitedData_ = data;
958 } 964 }
959 965
960 /** 966 /**
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 if (contextMenuUrl != null) { 1203 if (contextMenuUrl != null) {
1198 switch (itemId) { 1204 switch (itemId) {
1199 case ContextMenuItemIds.BOOKMARK_OPEN_IN_NEW_TAB: 1205 case ContextMenuItemIds.BOOKMARK_OPEN_IN_NEW_TAB:
1200 case ContextMenuItemIds.BOOKMARK_OPEN_IN_INCOGNITO_TAB: 1206 case ContextMenuItemIds.BOOKMARK_OPEN_IN_INCOGNITO_TAB:
1201 chrome.send('openedBookmark'); 1207 chrome.send('openedBookmark');
1202 break; 1208 break;
1203 1209
1204 case ContextMenuItemIds.MOST_VISITED_OPEN_IN_NEW_TAB: 1210 case ContextMenuItemIds.MOST_VISITED_OPEN_IN_NEW_TAB:
1205 case ContextMenuItemIds.MOST_VISITED_OPEN_IN_INCOGNITO_TAB: 1211 case ContextMenuItemIds.MOST_VISITED_OPEN_IN_INCOGNITO_TAB:
1206 chrome.send('openedMostVisited'); 1212 chrome.send('openedMostVisited');
1213 if (contextMenuItem != null) {
Dan Beam 2013/11/14 04:44:38 nit: if (contextMenuItem) {
newt (away) 2013/11/14 18:44:02 Done.
1214 chrome.send('metricsHandler:recordInHistogram',
1215 ['NewTabPage.MostVisited',
1216 contextMenuItem.mostVisitedIndex,
1217 8]);
1218 }
1207 break; 1219 break;
1208 1220
1209 case ContextMenuItemIds.RECENTLY_CLOSED_OPEN_IN_NEW_TAB: 1221 case ContextMenuItemIds.RECENTLY_CLOSED_OPEN_IN_NEW_TAB:
1210 case ContextMenuItemIds.RECENTLY_CLOSED_OPEN_IN_INCOGNITO_TAB: 1222 case ContextMenuItemIds.RECENTLY_CLOSED_OPEN_IN_INCOGNITO_TAB:
1211 chrome.send('openedRecentlyClosed'); 1223 chrome.send('openedRecentlyClosed');
1212 break; 1224 break;
1213 } 1225 }
1214 } 1226 }
1215 1227
1216 switch (itemId) { 1228 switch (itemId) {
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
2723 // NTP Entry point. 2735 // NTP Entry point.
2724 ///////////////////////////////////////////////////////////////////////////// 2736 /////////////////////////////////////////////////////////////////////////////
2725 2737
2726 /* 2738 /*
2727 * Handles initializing the UI when the page has finished loading. 2739 * Handles initializing the UI when the page has finished loading.
2728 */ 2740 */
2729 window.addEventListener('DOMContentLoaded', function(evt) { 2741 window.addEventListener('DOMContentLoaded', function(evt) {
2730 ntp.init(); 2742 ntp.init();
2731 $('content-area').style.display = 'block'; 2743 $('content-area').style.display = 'block';
2732 }); 2744 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/ntp/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698