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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 /** @override */ | 104 /** @override */ |
105 appendTilePage: function(page, title, titleIsEditable, opt_refNode) { | 105 appendTilePage: function(page, title, titleIsEditable, opt_refNode) { |
106 ntp.PageListView.prototype.appendTilePage.apply(this, arguments); | 106 ntp.PageListView.prototype.appendTilePage.apply(this, arguments); |
107 | 107 |
108 if (promoBubble) | 108 if (promoBubble) |
109 window.setTimeout(promoBubble.reposition.bind(promoBubble), 0); | 109 window.setTimeout(promoBubble.reposition.bind(promoBubble), 0); |
110 } | 110 } |
111 }; | 111 }; |
112 | 112 |
113 function gotShouldShowApps(shouldShowApps) { | |
114 if (shouldShowApps != loadTimeData.getBoolean('showApps')) { | |
115 // TODO(jeremya): update the UI in-place instead of reloading. | |
116 window.location.reload(); | |
117 return; | |
118 } | |
119 } | |
120 | |
121 /** | 113 /** |
122 * Invoked at startup once the DOM is available to initialize the app. | 114 * Invoked at startup once the DOM is available to initialize the app. |
123 */ | 115 */ |
124 function onLoad() { | 116 function onLoad() { |
125 // This will end up calling ntp.gotShouldShowApps. | |
126 chrome.send('getShouldShowApps'); | |
127 sectionsToWaitFor = 0; | 117 sectionsToWaitFor = 0; |
128 if (loadTimeData.getBoolean('showMostvisited')) | 118 if (loadTimeData.getBoolean('showMostvisited')) |
129 sectionsToWaitFor++; | 119 sectionsToWaitFor++; |
130 if (loadTimeData.getBoolean('showApps')) { | 120 if (loadTimeData.getBoolean('showApps')) { |
131 sectionsToWaitFor++; | 121 sectionsToWaitFor++; |
132 if (loadTimeData.getBoolean('showAppLauncherPromo')) { | 122 if (loadTimeData.getBoolean('showAppLauncherPromo')) { |
133 $('app-launcher-promo-close-button').addEventListener('click', | 123 $('app-launcher-promo-close-button').addEventListener('click', |
134 function() { chrome.send('stopShowingAppLauncherPromo'); }); | 124 function() { chrome.send('stopShowingAppLauncherPromo'); }); |
135 } | 125 } |
136 } | 126 } |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 appAdded: appAdded, | 674 appAdded: appAdded, |
685 appMoved: appMoved, | 675 appMoved: appMoved, |
686 appRemoved: appRemoved, | 676 appRemoved: appRemoved, |
687 appsPrefChangeCallback: appsPrefChangeCallback, | 677 appsPrefChangeCallback: appsPrefChangeCallback, |
688 appLauncherPromoPrefChangeCallback: appLauncherPromoPrefChangeCallback, | 678 appLauncherPromoPrefChangeCallback: appLauncherPromoPrefChangeCallback, |
689 enterRearrangeMode: enterRearrangeMode, | 679 enterRearrangeMode: enterRearrangeMode, |
690 getAppsCallback: getAppsCallback, | 680 getAppsCallback: getAppsCallback, |
691 getAppsPageIndex: getAppsPageIndex, | 681 getAppsPageIndex: getAppsPageIndex, |
692 getCardSlider: getCardSlider, | 682 getCardSlider: getCardSlider, |
693 onLoad: onLoad, | 683 onLoad: onLoad, |
694 gotShouldShowApps: gotShouldShowApps, | |
695 leaveRearrangeMode: leaveRearrangeMode, | 684 leaveRearrangeMode: leaveRearrangeMode, |
696 logTimeToClick: logTimeToClick, | 685 logTimeToClick: logTimeToClick, |
697 NtpFollowAction: NtpFollowAction, | 686 NtpFollowAction: NtpFollowAction, |
698 saveAppPageName: saveAppPageName, | 687 saveAppPageName: saveAppPageName, |
699 setAppToBeHighlighted: setAppToBeHighlighted, | 688 setAppToBeHighlighted: setAppToBeHighlighted, |
700 setBookmarkBarAttached: setBookmarkBarAttached, | 689 setBookmarkBarAttached: setBookmarkBarAttached, |
701 setForeignSessions: setForeignSessions, | 690 setForeignSessions: setForeignSessions, |
702 setMostVisitedPages: setMostVisitedPages, | 691 setMostVisitedPages: setMostVisitedPages, |
703 setSuggestionsPages: setSuggestionsPages, | 692 setSuggestionsPages: setSuggestionsPages, |
704 setRecentlyClosedTabs: setRecentlyClosedTabs, | 693 setRecentlyClosedTabs: setRecentlyClosedTabs, |
705 setFaviconDominantColor: setFaviconDominantColor, | 694 setFaviconDominantColor: setFaviconDominantColor, |
706 showNotification: showNotification, | 695 showNotification: showNotification, |
707 themeChanged: themeChanged, | 696 themeChanged: themeChanged, |
708 updateLogin: updateLogin | 697 updateLogin: updateLogin |
709 }; | 698 }; |
710 }); | 699 }); |
711 | 700 |
712 document.addEventListener('DOMContentLoaded', ntp.onLoad); | 701 document.addEventListener('DOMContentLoaded', ntp.onLoad); |
713 | 702 |
714 var toCssPx = cr.ui.toCssPx; | 703 var toCssPx = cr.ui.toCssPx; |
OLD | NEW |