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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 5
6 /** 6 /**
7 * @fileoverview The local InstantExtended NTP. 7 * @fileoverview The local InstantExtended NTP.
8 */ 8 */
9 9
10 /** 10 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 }; 46 };
47 47
48 48
49 /** 49 /**
50 * Enum for HTML element ids. 50 * Enum for HTML element ids.
51 * @enum {string} 51 * @enum {string}
52 * @const 52 * @const
53 */ 53 */
54 var IDS = { 54 var IDS = {
55 ATTRIBUTION: 'attribution', 55 ATTRIBUTION: 'attribution',
56 ATTRIBUTION_TEXT: 'attribution-text',
56 FAKEBOX: 'fakebox', 57 FAKEBOX: 'fakebox',
57 LOGO: 'logo', 58 LOGO: 'logo',
58 NOTIFICATION: 'mv-notice', 59 NOTIFICATION: 'mv-notice',
59 NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x', 60 NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x',
60 NOTIFICATION_MESSAGE: 'mv-msg', 61 NOTIFICATION_MESSAGE: 'mv-msg',
61 NTP_CONTENTS: 'ntp-contents', 62 NTP_CONTENTS: 'ntp-contents',
63 RECENT_TABS: 'recent-tabs',
62 RESTORE_ALL_LINK: 'mv-restore', 64 RESTORE_ALL_LINK: 'mv-restore',
63 TILES: 'mv-tiles', 65 TILES: 'mv-tiles',
64 UNDO_LINK: 'mv-undo' 66 UNDO_LINK: 'mv-undo'
65 }; 67 };
66 68
67 69
68 /** 70 /**
69 * Enum for keycodes. 71 * Enum for keycodes.
70 * @enum {number} 72 * @enum {number}
71 * @const 73 * @const
(...skipping 10 matching lines...) Expand all
82 * @const 84 * @const
83 */ 85 */
84 var NTP_DISPOSE_STATE = { 86 var NTP_DISPOSE_STATE = {
85 NONE: 0, // Preserve the NTP appearance and functionality 87 NONE: 0, // Preserve the NTP appearance and functionality
86 DISABLE_FAKEBOX: 1, 88 DISABLE_FAKEBOX: 1,
87 HIDE_FAKEBOX_AND_LOGO: 2 89 HIDE_FAKEBOX_AND_LOGO: 2
88 }; 90 };
89 91
90 92
91 /** 93 /**
94 * The JavaScript button event value for a middle click.
95 * @type {number}
96 * @const
97 */
98 var MIDDLE_MOUSE_BUTTON = 1;
99
100
101 /**
102 * Possible behaviors for navigateContentWindow.
103 * @enum {number}
104 */
105 var WindowOpenDisposition = {
106 CURRENT_TAB: 1,
107 NEW_BACKGROUND_TAB: 2
108 };
109
110
111 /**
92 * The container for the tile elements. 112 * The container for the tile elements.
93 * @type {Element} 113 * @type {Element}
94 */ 114 */
95 var tilesContainer; 115 var tilesContainer;
96 116
97 117
98 /** 118 /**
99 * The notification displayed when a page is blacklisted. 119 * The notification displayed when a page is blacklisted.
100 * @type {Element} 120 * @type {Element}
101 */ 121 */
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 /** 876 /**
857 * @return {boolean} True if this is a Google page and not some other search 877 * @return {boolean} True if this is a Google page and not some other search
858 * provider. Used to determine whether to show the logo and fakebox. 878 * provider. Used to determine whether to show the logo and fakebox.
859 */ 879 */
860 function isGooglePage() { 880 function isGooglePage() {
861 return location.href.indexOf('isGoogle') != -1; 881 return location.href.indexOf('isGoogle') != -1;
862 } 882 }
863 883
864 884
865 /** 885 /**
886 * Extract the desired navigation behavior from a click button.
887 * @param {number} button The Event#button property of a click event.
888 * @return {WindowOpenDisposition} The desired behavior for
889 * navigateContentWindow.
890 */
891 function getDispositionFromClickButton(button) {
892 if (button == MIDDLE_MOUSE_BUTTON)
893 return WindowOpenDisposition.NEW_BACKGROUND_TAB;
894 return WindowOpenDisposition.CURRENT_TAB;
895 }
896
897
898 /**
866 * Prepares the New Tab Page by adding listeners, rendering the current 899 * Prepares the New Tab Page by adding listeners, rendering the current
867 * theme, the most visited pages section, and Google-specific elements for a 900 * theme, the most visited pages section, and Google-specific elements for a
868 * Google-provided page. 901 * Google-provided page.
869 */ 902 */
870 function init() { 903 function init() {
871 tilesContainer = $(IDS.TILES); 904 tilesContainer = $(IDS.TILES);
872 notification = $(IDS.NOTIFICATION); 905 notification = $(IDS.NOTIFICATION);
873 attribution = $(IDS.ATTRIBUTION); 906 attribution = $(IDS.ATTRIBUTION);
874 ntpContents = $(IDS.NTP_CONTENTS); 907 ntpContents = $(IDS.NTP_CONTENTS);
875 908
(...skipping 12 matching lines...) Expand all
888 fakebox.innerHTML = 921 fakebox.innerHTML =
889 '<input autocomplete="off" tabindex="-1" aria-hidden="true">' + 922 '<input autocomplete="off" tabindex="-1" aria-hidden="true">' +
890 '<div id=cursor></div>'; 923 '<div id=cursor></div>';
891 924
892 ntpContents.insertBefore(fakebox, ntpContents.firstChild); 925 ntpContents.insertBefore(fakebox, ntpContents.firstChild);
893 ntpContents.insertBefore(logo, ntpContents.firstChild); 926 ntpContents.insertBefore(logo, ntpContents.firstChild);
894 } else { 927 } else {
895 document.body.classList.add(CLASSES.NON_GOOGLE_PAGE); 928 document.body.classList.add(CLASSES.NON_GOOGLE_PAGE);
896 } 929 }
897 930
931 var recentTabsText = templateData.recentTabs;
932 if (recentTabsText) {
933 var recentTabsLink = document.createElement('span');
934 recentTabsLink.id = IDS.RECENT_TABS;
935 recentTabsLink.addEventListener('click', function(event) {
936 ntpApiHandle.navigateContentWindow(
937 'chrome://history', getDispositionFromClickButton(event.button));
938 });
939 recentTabsLink.textContent = recentTabsText;
940 ntpContents.appendChild(recentTabsLink);
941 // Move the attribution up to prevent it from overlapping.
942 attribution.style.bottom = '28px';
943 }
898 944
899 var notificationMessage = $(IDS.NOTIFICATION_MESSAGE); 945 var notificationMessage = $(IDS.NOTIFICATION_MESSAGE);
900 notificationMessage.textContent = templateData.thumbnailRemovedNotification; 946 notificationMessage.textContent = templateData.thumbnailRemovedNotification;
901 var undoLink = $(IDS.UNDO_LINK); 947 var undoLink = $(IDS.UNDO_LINK);
902 undoLink.addEventListener('click', onUndo); 948 undoLink.addEventListener('click', onUndo);
903 registerKeyHandler(undoLink, KEYCODE.ENTER, onUndo); 949 registerKeyHandler(undoLink, KEYCODE.ENTER, onUndo);
904 undoLink.textContent = templateData.undoThumbnailRemove; 950 undoLink.textContent = templateData.undoThumbnailRemove;
905 var restoreAllLink = $(IDS.RESTORE_ALL_LINK); 951 var restoreAllLink = $(IDS.RESTORE_ALL_LINK);
906 restoreAllLink.addEventListener('click', onRestoreAll); 952 restoreAllLink.addEventListener('click', onRestoreAll);
907 registerKeyHandler(restoreAllLink, KEYCODE.ENTER, onUndo); 953 registerKeyHandler(restoreAllLink, KEYCODE.ENTER, onUndo);
908 restoreAllLink.textContent = templateData.restoreThumbnailsShort; 954 restoreAllLink.textContent = templateData.restoreThumbnailsShort;
909 attribution.textContent = templateData.attributionIntro; 955 $(IDS.ATTRIBUTION_TEXT).textContent = templateData.attributionIntro;
910 956
911 var notificationCloseButton = $(IDS.NOTIFICATION_CLOSE_BUTTON); 957 var notificationCloseButton = $(IDS.NOTIFICATION_CLOSE_BUTTON);
912 notificationCloseButton.addEventListener('click', hideNotification); 958 notificationCloseButton.addEventListener('click', hideNotification);
913 959
914 userInitiatedMostVisitedChange = false; 960 userInitiatedMostVisitedChange = false;
915 window.addEventListener('resize', onResize); 961 window.addEventListener('resize', onResize);
916 onResize(); 962 onResize();
917 963
918 var topLevelHandle = getEmbeddedSearchApiHandle(); 964 var topLevelHandle = getEmbeddedSearchApiHandle();
919 965
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 1009
964 return { 1010 return {
965 init: init, 1011 init: init,
966 listen: listen 1012 listen: listen
967 }; 1013 };
968 } 1014 }
969 1015
970 if (!window.localNTPUnitTest) { 1016 if (!window.localNTPUnitTest) {
971 LocalNTP(location).listen(); 1017 LocalNTP(location).listen();
972 } 1018 }
OLDNEW
« 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