OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * @fileoverview New tab page | 6 * @fileoverview New tab page |
7 * This is the main code for the new tab page used by touch-enabled Chrome | 7 * This is the main code for the new tab page used by touch-enabled Chrome |
8 * browsers. For now this is still a prototype. | 8 * browsers. For now this is still a prototype. |
9 */ | 9 */ |
10 | 10 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 // Load the current theme colors. | 144 // Load the current theme colors. |
145 themeChanged(); | 145 themeChanged(); |
146 | 146 |
147 newTabView = new NewTabView(); | 147 newTabView = new NewTabView(); |
148 | 148 |
149 notificationContainer = getRequiredElement('notification-container'); | 149 notificationContainer = getRequiredElement('notification-container'); |
150 notificationContainer.addEventListener( | 150 notificationContainer.addEventListener( |
151 'webkitTransitionEnd', onNotificationTransitionEnd); | 151 'webkitTransitionEnd', onNotificationTransitionEnd); |
152 | 152 |
153 if (loadTimeData.getBoolean('showRecentlyClosed')) { | |
154 cr.ui.decorate(getRequiredElement('recently-closed-menu-button'), | |
155 ntp.RecentMenuButton); | |
156 chrome.send('getRecentlyClosedTabs'); | |
157 } else { | |
158 $('recently-closed-menu-button').hidden = true; | |
159 } | |
160 | |
161 if (loadTimeData.getBoolean('showOtherSessionsMenu')) { | 153 if (loadTimeData.getBoolean('showOtherSessionsMenu')) { |
162 otherSessionsButton = /** @type {!ntp.OtherSessionsMenuButton} */( | 154 otherSessionsButton = /** @type {!ntp.OtherSessionsMenuButton} */( |
163 getRequiredElement('other-sessions-menu-button')); | 155 getRequiredElement('other-sessions-menu-button')); |
164 cr.ui.decorate(otherSessionsButton, ntp.OtherSessionsMenuButton); | 156 cr.ui.decorate(otherSessionsButton, ntp.OtherSessionsMenuButton); |
165 otherSessionsButton.initialize(loadTimeData.getBoolean('isUserSignedIn')); | 157 otherSessionsButton.initialize(loadTimeData.getBoolean('isUserSignedIn')); |
166 } else { | 158 } else { |
167 getRequiredElement('other-sessions-menu-button').hidden = true; | 159 getRequiredElement('other-sessions-menu-button').hidden = true; |
168 } | 160 } |
169 | 161 |
170 if (loadTimeData.getBoolean('showMostvisited')) { | 162 if (loadTimeData.getBoolean('showMostvisited')) { |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 /** | 531 /** |
540 * When done fading out, set hidden to true so the notification can't be | 532 * When done fading out, set hidden to true so the notification can't be |
541 * tabbed to or clicked. | 533 * tabbed to or clicked. |
542 * @param {Event} e The webkitTransitionEnd event. | 534 * @param {Event} e The webkitTransitionEnd event. |
543 */ | 535 */ |
544 function onNotificationTransitionEnd(e) { | 536 function onNotificationTransitionEnd(e) { |
545 if (notificationContainer.classList.contains('inactive')) | 537 if (notificationContainer.classList.contains('inactive')) |
546 notificationContainer.hidden = true; | 538 notificationContainer.hidden = true; |
547 } | 539 } |
548 | 540 |
549 function setRecentlyClosedTabs(dataItems) { | |
550 $('recently-closed-menu-button').dataItems = dataItems; | |
551 layoutFooter(); | |
552 } | |
553 | |
554 /** | 541 /** |
555 * @param {Array<PageData>} data | 542 * @param {Array<PageData>} data |
556 * @param {boolean} hasBlacklistedUrls | 543 * @param {boolean} hasBlacklistedUrls |
557 */ | 544 */ |
558 function setMostVisitedPages(data, hasBlacklistedUrls) { | 545 function setMostVisitedPages(data, hasBlacklistedUrls) { |
559 newTabView.mostVisitedPage.data = data; | 546 newTabView.mostVisitedPage.data = data; |
560 cr.dispatchSimpleEvent(document, 'sectionready', true, true); | 547 cr.dispatchSimpleEvent(document, 'sectionready', true, true); |
561 } | 548 } |
562 | 549 |
563 function setSuggestionsPages(data, hasBlacklistedUrls) { | 550 function setSuggestionsPages(data, hasBlacklistedUrls) { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 onLoad: onLoad, | 753 onLoad: onLoad, |
767 leaveRearrangeMode: leaveRearrangeMode, | 754 leaveRearrangeMode: leaveRearrangeMode, |
768 logTimeToClick: logTimeToClick, | 755 logTimeToClick: logTimeToClick, |
769 NtpFollowAction: NtpFollowAction, | 756 NtpFollowAction: NtpFollowAction, |
770 saveAppPageName: saveAppPageName, | 757 saveAppPageName: saveAppPageName, |
771 setAppToBeHighlighted: setAppToBeHighlighted, | 758 setAppToBeHighlighted: setAppToBeHighlighted, |
772 setBookmarkBarAttached: setBookmarkBarAttached, | 759 setBookmarkBarAttached: setBookmarkBarAttached, |
773 setForeignSessions: setForeignSessions, | 760 setForeignSessions: setForeignSessions, |
774 setMostVisitedPages: setMostVisitedPages, | 761 setMostVisitedPages: setMostVisitedPages, |
775 setSuggestionsPages: setSuggestionsPages, | 762 setSuggestionsPages: setSuggestionsPages, |
776 setRecentlyClosedTabs: setRecentlyClosedTabs, | |
777 setFaviconDominantColor: setFaviconDominantColor, | 763 setFaviconDominantColor: setFaviconDominantColor, |
778 showNotification: showNotification, | 764 showNotification: showNotification, |
779 themeChanged: themeChanged, | 765 themeChanged: themeChanged, |
780 updateLogin: updateLogin | 766 updateLogin: updateLogin |
781 }; | 767 }; |
782 }); | 768 }); |
783 | 769 |
784 document.addEventListener('DOMContentLoaded', ntp.onLoad); | 770 document.addEventListener('DOMContentLoaded', ntp.onLoad); |
785 | 771 |
786 var toCssPx = cr.ui.toCssPx; | 772 var toCssPx = cr.ui.toCssPx; |
OLD | NEW |