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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 /** | 121 /** |
122 * Invoked at startup once the DOM is available to initialize the app. | 122 * Invoked at startup once the DOM is available to initialize the app. |
123 */ | 123 */ |
124 function onLoad() { | 124 function onLoad() { |
125 // This will end up calling ntp.gotShouldShowApps. | 125 // This will end up calling ntp.gotShouldShowApps. |
126 chrome.send('getShouldShowApps'); | 126 chrome.send('getShouldShowApps'); |
127 sectionsToWaitFor = 0; | 127 sectionsToWaitFor = 0; |
128 if (loadTimeData.getBoolean('showMostvisited')) | 128 if (loadTimeData.getBoolean('showMostvisited')) |
129 sectionsToWaitFor++; | 129 sectionsToWaitFor++; |
130 if (loadTimeData.getBoolean('showApps')) | 130 if (loadTimeData.getBoolean('showApps')) { |
131 sectionsToWaitFor++; | 131 sectionsToWaitFor++; |
| 132 if (loadTimeData.getBoolean('showAppLauncherPromo')) { |
| 133 $('app-launcher-promo-close-button').addEventListener('click', |
| 134 function() { chrome.send('stopShowingAppLauncherPromo'); }); |
| 135 } |
| 136 } |
132 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) | 137 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) |
133 sectionsToWaitFor++; | 138 sectionsToWaitFor++; |
134 measureNavDots(); | 139 measureNavDots(); |
135 | 140 |
136 // Load the current theme colors. | 141 // Load the current theme colors. |
137 themeChanged(); | 142 themeChanged(); |
138 | 143 |
139 newTabView = new NewTabView(); | 144 newTabView = new NewTabView(); |
140 | 145 |
141 notificationContainer = getRequiredElement('notification-container'); | 146 notificationContainer = getRequiredElement('notification-container'); |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 } | 625 } |
621 | 626 |
622 function appRemoved() { | 627 function appRemoved() { |
623 return newTabView.appRemoved.apply(newTabView, arguments); | 628 return newTabView.appRemoved.apply(newTabView, arguments); |
624 } | 629 } |
625 | 630 |
626 function appsPrefChangeCallback() { | 631 function appsPrefChangeCallback() { |
627 return newTabView.appsPrefChangedCallback.apply(newTabView, arguments); | 632 return newTabView.appsPrefChangedCallback.apply(newTabView, arguments); |
628 } | 633 } |
629 | 634 |
| 635 function appLauncherPromoPrefChangeCallback() { |
| 636 return newTabView.appLauncherPromoPrefChangeCallback.apply(newTabView, |
| 637 arguments); |
| 638 } |
| 639 |
630 function appsReordered() { | 640 function appsReordered() { |
631 return newTabView.appsReordered.apply(newTabView, arguments); | 641 return newTabView.appsReordered.apply(newTabView, arguments); |
632 } | 642 } |
633 | 643 |
634 function enterRearrangeMode() { | 644 function enterRearrangeMode() { |
635 return newTabView.enterRearrangeMode.apply(newTabView, arguments); | 645 return newTabView.enterRearrangeMode.apply(newTabView, arguments); |
636 } | 646 } |
637 | 647 |
638 function setForeignSessions(sessionList, isTabSyncEnabled) { | 648 function setForeignSessions(sessionList, isTabSyncEnabled) { |
639 if (otherSessionsButton) | 649 if (otherSessionsButton) |
(...skipping 23 matching lines...) Expand all Loading... |
663 function setAppToBeHighlighted(appId) { | 673 function setAppToBeHighlighted(appId) { |
664 newTabView.highlightAppId = appId; | 674 newTabView.highlightAppId = appId; |
665 } | 675 } |
666 | 676 |
667 // Return an object with all the exports | 677 // Return an object with all the exports |
668 return { | 678 return { |
669 appAdded: appAdded, | 679 appAdded: appAdded, |
670 appMoved: appMoved, | 680 appMoved: appMoved, |
671 appRemoved: appRemoved, | 681 appRemoved: appRemoved, |
672 appsPrefChangeCallback: appsPrefChangeCallback, | 682 appsPrefChangeCallback: appsPrefChangeCallback, |
| 683 appLauncherPromoPrefChangeCallback: appLauncherPromoPrefChangeCallback, |
673 enterRearrangeMode: enterRearrangeMode, | 684 enterRearrangeMode: enterRearrangeMode, |
674 getAppsCallback: getAppsCallback, | 685 getAppsCallback: getAppsCallback, |
675 getAppsPageIndex: getAppsPageIndex, | 686 getAppsPageIndex: getAppsPageIndex, |
676 getCardSlider: getCardSlider, | 687 getCardSlider: getCardSlider, |
677 onLoad: onLoad, | 688 onLoad: onLoad, |
678 gotShouldShowApps: gotShouldShowApps, | 689 gotShouldShowApps: gotShouldShowApps, |
679 leaveRearrangeMode: leaveRearrangeMode, | 690 leaveRearrangeMode: leaveRearrangeMode, |
680 logTimeToClick: logTimeToClick, | 691 logTimeToClick: logTimeToClick, |
681 NtpFollowAction: NtpFollowAction, | 692 NtpFollowAction: NtpFollowAction, |
682 saveAppPageName: saveAppPageName, | 693 saveAppPageName: saveAppPageName, |
683 setAppToBeHighlighted: setAppToBeHighlighted, | 694 setAppToBeHighlighted: setAppToBeHighlighted, |
684 setBookmarkBarAttached: setBookmarkBarAttached, | 695 setBookmarkBarAttached: setBookmarkBarAttached, |
685 setForeignSessions: setForeignSessions, | 696 setForeignSessions: setForeignSessions, |
686 setMostVisitedPages: setMostVisitedPages, | 697 setMostVisitedPages: setMostVisitedPages, |
687 setSuggestionsPages: setSuggestionsPages, | 698 setSuggestionsPages: setSuggestionsPages, |
688 setRecentlyClosedTabs: setRecentlyClosedTabs, | 699 setRecentlyClosedTabs: setRecentlyClosedTabs, |
689 setFaviconDominantColor: setFaviconDominantColor, | 700 setFaviconDominantColor: setFaviconDominantColor, |
690 showNotification: showNotification, | 701 showNotification: showNotification, |
691 themeChanged: themeChanged, | 702 themeChanged: themeChanged, |
692 updateLogin: updateLogin | 703 updateLogin: updateLogin |
693 }; | 704 }; |
694 }); | 705 }); |
695 | 706 |
696 document.addEventListener('DOMContentLoaded', ntp.onLoad); | 707 document.addEventListener('DOMContentLoaded', ntp.onLoad); |
697 | 708 |
698 var toCssPx = cr.ui.toCssPx; | 709 var toCssPx = cr.ui.toCssPx; |
OLD | NEW |