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

Unified Diff: chrome/browser/resources/ntp4/new_tab.js

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.html ('k') | chrome/browser/resources/ntp4/new_tab_theme.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp4/new_tab.js
diff --git a/chrome/browser/resources/ntp4/new_tab.js b/chrome/browser/resources/ntp4/new_tab.js
index 678be69906002c8e89a2f31ec1e0c57d60e3d461..b127c69a3df63f43ef1c19d4ca471c052bc3ec23 100644
--- a/chrome/browser/resources/ntp4/new_tab.js
+++ b/chrome/browser/resources/ntp4/new_tab.js
@@ -7,6 +7,15 @@
* This is the main code for the new tab page used by touch-enabled Chrome
* browsers. For now this is still a prototype.
*/
+
+/**
+ * @typedef {{direction: string,
+ * filler: (boolean|undefined),
+ * title: string,
+ * url: string}}
+ * @see chrome/browser/ui/webui/ntp/most_visited_handler.cc
+ */
+var PageData;
// Use an anonymous function to enable strict mode just for this file (which
// will be concatenated with other files when embedded in Chrome
@@ -111,6 +120,8 @@
*/
function onLoad() {
sectionsToWaitFor = 0;
+ if (loadTimeData.getBoolean('showMostvisited'))
+ sectionsToWaitFor++;
if (loadTimeData.getBoolean('showApps')) {
sectionsToWaitFor++;
if (loadTimeData.getBoolean('showAppLauncherPromo')) {
@@ -130,6 +141,18 @@
notificationContainer = getRequiredElement('notification-container');
notificationContainer.addEventListener(
'webkitTransitionEnd', onNotificationTransitionEnd);
+
+ if (loadTimeData.getBoolean('showMostvisited')) {
+ var mostVisited = new ntp.MostVisitedPage();
+ // Move the footer into the most visited page if we are in "bare minimum"
+ // mode.
+ if (document.body.classList.contains('bare-minimum'))
+ mostVisited.appendFooter(getRequiredElement('footer'));
+ newTabView.appendTilePage(mostVisited,
+ loadTimeData.getString('mostvisited'),
+ false);
+ chrome.send('getMostVisited');
+ }
if (!loadTimeData.getBoolean('showWebStoreIcon')) {
var webStoreIcon = $('chrome-web-store-link');
@@ -303,11 +326,14 @@
* its length may be measured and the nav dots sized accordingly.
*/
function measureNavDots() {
+ var pxWidth = measureNavDot('appDefaultPageName');
+ if (loadTimeData.getBoolean('showMostvisited'))
+ pxWidth = Math.max(measureNavDot('mostvisited'), pxWidth);
+
var styleElement = document.createElement('style');
styleElement.type = 'text/css';
// max-width is used because if we run out of space, the nav dots will be
// shrunk.
- var pxWidth = measureNavDot('appDefaultPageName');
styleElement.textContent = '.dot { max-width: ' + pxWidth + 'px; }';
document.querySelector('head').appendChild(styleElement);
}
@@ -481,6 +507,15 @@
}
/**
+ * @param {Array<PageData>} data
+ * @param {boolean} hasBlacklistedUrls
+ */
+ function setMostVisitedPages(data, hasBlacklistedUrls) {
+ newTabView.mostVisitedPage.data = data;
+ cr.dispatchSimpleEvent(document, 'sectionready', true, true);
+ }
+
+ /**
* Set the dominant color for a node. This will be called in response to
* getFaviconDominantColor. The node represented by |id| better have a setter
* for stripeColor.
@@ -536,6 +571,16 @@
var rect = e.currentTarget.getBoundingClientRect();
chrome.send('showSyncLoginUI',
[rect.left, rect.top, rect.width, rect.height]);
+ }
+
+ /**
+ * Logs the time to click for the specified item.
+ * @param {string} item The item to log the time-to-click.
+ */
+ function logTimeToClick(item) {
+ var timeToClick = Date.now() - startTime;
+ chrome.send('logTimeToClick',
+ ['NewTabPage.TimeToClick' + item, timeToClick]);
}
/**
@@ -661,10 +706,12 @@
getCardSlider: getCardSlider,
onLoad: onLoad,
leaveRearrangeMode: leaveRearrangeMode,
+ logTimeToClick: logTimeToClick,
NtpFollowAction: NtpFollowAction,
saveAppPageName: saveAppPageName,
setAppToBeHighlighted: setAppToBeHighlighted,
setBookmarkBarAttached: setBookmarkBarAttached,
+ setMostVisitedPages: setMostVisitedPages,
setFaviconDominantColor: setFaviconDominantColor,
showNotification: showNotification,
themeChanged: themeChanged,
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.html ('k') | chrome/browser/resources/ntp4/new_tab_theme.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698