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

Unified Diff: chrome/browser/resources/local_ntp/local_ntp.js

Issue 14685004: Add finch flag for rendering a recently closed link on the local ntp. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Rebase. Created 7 years, 6 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/local_ntp/local_ntp.html ('k') | chrome/browser/search/local_ntp_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « chrome/browser/resources/local_ntp/local_ntp.html ('k') | chrome/browser/search/local_ntp_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698