| Index: chrome/browser/resources/local_ntp/local_ntp.js
|
| diff --git a/chrome/browser/resources/local_ntp/local_ntp.js b/chrome/browser/resources/local_ntp/local_ntp.js
|
| index e6747c55eaae760d3be58060a5e23313468d5091..6cdd6c529ecc9395520b344b78abb80fbef67376 100644
|
| --- a/chrome/browser/resources/local_ntp/local_ntp.js
|
| +++ b/chrome/browser/resources/local_ntp/local_ntp.js
|
| @@ -53,12 +53,14 @@ var CLASSES = {
|
| */
|
| var IDS = {
|
| ATTRIBUTION: 'attribution',
|
| + ATTRIBUTION_TEXT: 'attribution-text',
|
| FAKEBOX: 'fakebox',
|
| LOGO: 'logo',
|
| NOTIFICATION: 'mv-notice',
|
| NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x',
|
| NOTIFICATION_MESSAGE: 'mv-msg',
|
| NTP_CONTENTS: 'ntp-contents',
|
| + RECENT_TABS: 'recent-tabs',
|
| RESTORE_ALL_LINK: 'mv-restore',
|
| TILES: 'mv-tiles',
|
| UNDO_LINK: 'mv-undo'
|
| @@ -89,6 +91,24 @@ var NTP_DISPOSE_STATE = {
|
|
|
|
|
| /**
|
| + * The JavaScript button event value for a middle click.
|
| + * @type {number}
|
| + * @const
|
| + */
|
| +var MIDDLE_MOUSE_BUTTON = 1;
|
| +
|
| +
|
| +/**
|
| + * Possible behaviors for navigateContentWindow.
|
| + * @enum {number}
|
| + */
|
| +var WindowOpenDisposition = {
|
| + CURRENT_TAB: 1,
|
| + NEW_BACKGROUND_TAB: 2
|
| +};
|
| +
|
| +
|
| +/**
|
| * The container for the tile elements.
|
| * @type {Element}
|
| */
|
| @@ -863,6 +883,19 @@ function isGooglePage() {
|
|
|
|
|
| /**
|
| + * Extract the desired navigation behavior from a click button.
|
| + * @param {number} button The Event#button property of a click event.
|
| + * @return {WindowOpenDisposition} The desired behavior for
|
| + * navigateContentWindow.
|
| + */
|
| +function getDispositionFromClickButton(button) {
|
| + if (button == MIDDLE_MOUSE_BUTTON)
|
| + return WindowOpenDisposition.NEW_BACKGROUND_TAB;
|
| + return WindowOpenDisposition.CURRENT_TAB;
|
| +}
|
| +
|
| +
|
| +/**
|
| * Prepares the New Tab Page by adding listeners, rendering the current
|
| * theme, the most visited pages section, and Google-specific elements for a
|
| * Google-provided page.
|
| @@ -895,6 +928,19 @@ function init() {
|
| document.body.classList.add(CLASSES.NON_GOOGLE_PAGE);
|
| }
|
|
|
| + var recentTabsText = templateData.recentTabs;
|
| + if (recentTabsText) {
|
| + var recentTabsLink = document.createElement('span');
|
| + recentTabsLink.id = IDS.RECENT_TABS;
|
| + recentTabsLink.addEventListener('click', function(event) {
|
| + ntpApiHandle.navigateContentWindow(
|
| + 'chrome://history', getDispositionFromClickButton(event.button));
|
| + });
|
| + recentTabsLink.textContent = recentTabsText;
|
| + ntpContents.appendChild(recentTabsLink);
|
| + // Move the attribution up to prevent it from overlapping.
|
| + attribution.style.bottom = '28px';
|
| + }
|
|
|
| var notificationMessage = $(IDS.NOTIFICATION_MESSAGE);
|
| notificationMessage.textContent = templateData.thumbnailRemovedNotification;
|
| @@ -906,7 +952,7 @@ function init() {
|
| restoreAllLink.addEventListener('click', onRestoreAll);
|
| registerKeyHandler(restoreAllLink, KEYCODE.ENTER, onUndo);
|
| restoreAllLink.textContent = templateData.restoreThumbnailsShort;
|
| - attribution.textContent = templateData.attributionIntro;
|
| + $(IDS.ATTRIBUTION_TEXT).textContent = templateData.attributionIntro;
|
|
|
| var notificationCloseButton = $(IDS.NOTIFICATION_CLOSE_BUTTON);
|
| notificationCloseButton.addEventListener('click', hideNotification);
|
|
|