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

Side by Side Diff: chrome/browser/resources/ntp4/new_tab.js

Issue 1141843004: NTP Zombie Code Slayer II: Suggestions Page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: and remove urls Created 5 years, 7 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 (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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 sectionsToWaitFor++; 130 sectionsToWaitFor++;
131 if (loadTimeData.getBoolean('showApps')) { 131 if (loadTimeData.getBoolean('showApps')) {
132 sectionsToWaitFor++; 132 sectionsToWaitFor++;
133 if (loadTimeData.getBoolean('showAppLauncherPromo')) { 133 if (loadTimeData.getBoolean('showAppLauncherPromo')) {
134 $('app-launcher-promo-close-button').addEventListener('click', 134 $('app-launcher-promo-close-button').addEventListener('click',
135 function() { chrome.send('stopShowingAppLauncherPromo'); }); 135 function() { chrome.send('stopShowingAppLauncherPromo'); });
136 $('apps-promo-learn-more').addEventListener('click', 136 $('apps-promo-learn-more').addEventListener('click',
137 function() { chrome.send('onLearnMore'); }); 137 function() { chrome.send('onLearnMore'); });
138 } 138 }
139 } 139 }
140 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled'))
141 sectionsToWaitFor++;
142 measureNavDots(); 140 measureNavDots();
143 141
144 // Load the current theme colors. 142 // Load the current theme colors.
145 themeChanged(); 143 themeChanged();
146 144
147 newTabView = new NewTabView(); 145 newTabView = new NewTabView();
148 146
149 notificationContainer = getRequiredElement('notification-container'); 147 notificationContainer = getRequiredElement('notification-container');
150 notificationContainer.addEventListener( 148 notificationContainer.addEventListener(
151 'webkitTransitionEnd', onNotificationTransitionEnd); 149 'webkitTransitionEnd', onNotificationTransitionEnd);
(...skipping 12 matching lines...) Expand all
164 // Move the footer into the most visited page if we are in "bare minimum" 162 // Move the footer into the most visited page if we are in "bare minimum"
165 // mode. 163 // mode.
166 if (document.body.classList.contains('bare-minimum')) 164 if (document.body.classList.contains('bare-minimum'))
167 mostVisited.appendFooter(getRequiredElement('footer')); 165 mostVisited.appendFooter(getRequiredElement('footer'));
168 newTabView.appendTilePage(mostVisited, 166 newTabView.appendTilePage(mostVisited,
169 loadTimeData.getString('mostvisited'), 167 loadTimeData.getString('mostvisited'),
170 false); 168 false);
171 chrome.send('getMostVisited'); 169 chrome.send('getMostVisited');
172 } 170 }
173 171
174 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) {
175 var suggestionsScript = document.createElement('script');
176 suggestionsScript.src = 'suggestions_page.js';
177 suggestionsScript.onload = function() {
178 newTabView.appendTilePage(new ntp.SuggestionsPage(),
179 loadTimeData.getString('suggestions'),
180 false,
181 (newTabView.appsPages.length > 0) ?
182 newTabView.appsPages[0] : null);
183 chrome.send('getSuggestions');
184 cr.dispatchSimpleEvent(document, 'sectionready', true, true);
185 };
186 document.querySelector('head').appendChild(suggestionsScript);
187 }
188
189 if (!loadTimeData.getBoolean('showWebStoreIcon')) { 172 if (!loadTimeData.getBoolean('showWebStoreIcon')) {
190 var webStoreIcon = $('chrome-web-store-link'); 173 var webStoreIcon = $('chrome-web-store-link');
191 // Not all versions of the NTP have a footer, so this may not exist. 174 // Not all versions of the NTP have a footer, so this may not exist.
192 if (webStoreIcon) 175 if (webStoreIcon)
193 webStoreIcon.hidden = true; 176 webStoreIcon.hidden = true;
194 } else { 177 } else {
195 var webStoreLink = loadTimeData.getString('webStoreLink'); 178 var webStoreLink = loadTimeData.getString('webStoreLink');
196 var url = appendParam(webStoreLink, 'utm_source', 'chrome-ntp-launcher'); 179 var url = appendParam(webStoreLink, 'utm_source', 'chrome-ntp-launcher');
197 $('chrome-web-store-link').href = url; 180 $('chrome-web-store-link').href = url;
198 $('chrome-web-store-link').addEventListener('click', 181 $('chrome-web-store-link').addEventListener('click',
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 523
541 /** 524 /**
542 * @param {Array<PageData>} data 525 * @param {Array<PageData>} data
543 * @param {boolean} hasBlacklistedUrls 526 * @param {boolean} hasBlacklistedUrls
544 */ 527 */
545 function setMostVisitedPages(data, hasBlacklistedUrls) { 528 function setMostVisitedPages(data, hasBlacklistedUrls) {
546 newTabView.mostVisitedPage.data = data; 529 newTabView.mostVisitedPage.data = data;
547 cr.dispatchSimpleEvent(document, 'sectionready', true, true); 530 cr.dispatchSimpleEvent(document, 'sectionready', true, true);
548 } 531 }
549 532
550 function setSuggestionsPages(data, hasBlacklistedUrls) {
551 newTabView.suggestionsPage.data = data;
552 }
553
554 /** 533 /**
555 * Set the dominant color for a node. This will be called in response to 534 * Set the dominant color for a node. This will be called in response to
556 * getFaviconDominantColor. The node represented by |id| better have a setter 535 * getFaviconDominantColor. The node represented by |id| better have a setter
557 * for stripeColor. 536 * for stripeColor.
558 * @param {string} id The ID of a node. 537 * @param {string} id The ID of a node.
559 * @param {string} color The color represented as a CSS string. 538 * @param {string} color The color represented as a CSS string.
560 */ 539 */
561 function setFaviconDominantColor(id, color) { 540 function setFaviconDominantColor(id, color) {
562 var node = $(id); 541 var node = $(id);
563 if (node) 542 if (node)
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 getCardSlider: getCardSlider, 731 getCardSlider: getCardSlider,
753 onLoad: onLoad, 732 onLoad: onLoad,
754 leaveRearrangeMode: leaveRearrangeMode, 733 leaveRearrangeMode: leaveRearrangeMode,
755 logTimeToClick: logTimeToClick, 734 logTimeToClick: logTimeToClick,
756 NtpFollowAction: NtpFollowAction, 735 NtpFollowAction: NtpFollowAction,
757 saveAppPageName: saveAppPageName, 736 saveAppPageName: saveAppPageName,
758 setAppToBeHighlighted: setAppToBeHighlighted, 737 setAppToBeHighlighted: setAppToBeHighlighted,
759 setBookmarkBarAttached: setBookmarkBarAttached, 738 setBookmarkBarAttached: setBookmarkBarAttached,
760 setForeignSessions: setForeignSessions, 739 setForeignSessions: setForeignSessions,
761 setMostVisitedPages: setMostVisitedPages, 740 setMostVisitedPages: setMostVisitedPages,
762 setSuggestionsPages: setSuggestionsPages,
763 setFaviconDominantColor: setFaviconDominantColor, 741 setFaviconDominantColor: setFaviconDominantColor,
764 showNotification: showNotification, 742 showNotification: showNotification,
765 themeChanged: themeChanged, 743 themeChanged: themeChanged,
766 updateLogin: updateLogin 744 updateLogin: updateLogin
767 }; 745 };
768 }); 746 });
769 747
770 document.addEventListener('DOMContentLoaded', ntp.onLoad); 748 document.addEventListener('DOMContentLoaded', ntp.onLoad);
771 749
772 var toCssPx = cr.ui.toCssPx; 750 var toCssPx = cr.ui.toCssPx;
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.html ('k') | chrome/browser/resources/ntp4/page_list_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698