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 |
113 /** | 121 /** |
114 * 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. |
115 */ | 123 */ |
116 function onLoad() { | 124 function onLoad() { |
| 125 // This will end up calling ntp.gotShouldShowApps. |
| 126 chrome.send('getShouldShowApps'); |
117 sectionsToWaitFor = loadTimeData.getBoolean('showApps') ? 2 : 1; | 127 sectionsToWaitFor = loadTimeData.getBoolean('showApps') ? 2 : 1; |
118 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) | 128 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) |
119 sectionsToWaitFor++; | 129 sectionsToWaitFor++; |
120 measureNavDots(); | 130 measureNavDots(); |
121 | 131 |
122 // Load the current theme colors. | 132 // Load the current theme colors. |
123 themeChanged(); | 133 themeChanged(); |
124 | 134 |
125 newTabView = new NewTabView(); | 135 newTabView = new NewTabView(); |
126 | 136 |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 return { | 631 return { |
622 appAdded: appAdded, | 632 appAdded: appAdded, |
623 appMoved: appMoved, | 633 appMoved: appMoved, |
624 appRemoved: appRemoved, | 634 appRemoved: appRemoved, |
625 appsPrefChangeCallback: appsPrefChangeCallback, | 635 appsPrefChangeCallback: appsPrefChangeCallback, |
626 enterRearrangeMode: enterRearrangeMode, | 636 enterRearrangeMode: enterRearrangeMode, |
627 getAppsCallback: getAppsCallback, | 637 getAppsCallback: getAppsCallback, |
628 getAppsPageIndex: getAppsPageIndex, | 638 getAppsPageIndex: getAppsPageIndex, |
629 getCardSlider: getCardSlider, | 639 getCardSlider: getCardSlider, |
630 onLoad: onLoad, | 640 onLoad: onLoad, |
| 641 gotShouldShowApps: gotShouldShowApps, |
631 leaveRearrangeMode: leaveRearrangeMode, | 642 leaveRearrangeMode: leaveRearrangeMode, |
632 logTimeToClick: logTimeToClick, | 643 logTimeToClick: logTimeToClick, |
633 NtpFollowAction: NtpFollowAction, | 644 NtpFollowAction: NtpFollowAction, |
634 saveAppPageName: saveAppPageName, | 645 saveAppPageName: saveAppPageName, |
635 setAppToBeHighlighted: setAppToBeHighlighted, | 646 setAppToBeHighlighted: setAppToBeHighlighted, |
636 setBookmarkBarAttached: setBookmarkBarAttached, | 647 setBookmarkBarAttached: setBookmarkBarAttached, |
637 setForeignSessions: setForeignSessions, | 648 setForeignSessions: setForeignSessions, |
638 setMostVisitedPages: setMostVisitedPages, | 649 setMostVisitedPages: setMostVisitedPages, |
639 setSuggestionsPages: setSuggestionsPages, | 650 setSuggestionsPages: setSuggestionsPages, |
640 setRecentlyClosedTabs: setRecentlyClosedTabs, | 651 setRecentlyClosedTabs: setRecentlyClosedTabs, |
641 setFaviconDominantColor: setFaviconDominantColor, | 652 setFaviconDominantColor: setFaviconDominantColor, |
642 showNotification: showNotification, | 653 showNotification: showNotification, |
643 themeChanged: themeChanged, | 654 themeChanged: themeChanged, |
644 updateLogin: updateLogin | 655 updateLogin: updateLogin |
645 }; | 656 }; |
646 }); | 657 }); |
647 | 658 |
648 document.addEventListener('DOMContentLoaded', ntp.onLoad); | 659 document.addEventListener('DOMContentLoaded', ntp.onLoad); |
649 | 660 |
650 var toCssPx = cr.ui.toCssPx; | 661 var toCssPx = cr.ui.toCssPx; |
OLD | NEW |