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

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

Issue 9358031: Added new adaptive "Suggest" tab on the New Tab Page, behing the flag, for the experiments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix the unit-tests Created 8 years, 9 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 | Annotate | Revision Log
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 cr.ui.decorate($('other-sessions-menu-button'), 112 cr.ui.decorate($('other-sessions-menu-button'),
113 ntp.OtherSessionsMenuButton); 113 ntp.OtherSessionsMenuButton);
114 chrome.send('getForeignSessions'); 114 chrome.send('getForeignSessions');
115 } 115 }
116 116
117 newTabView.appendTilePage(new ntp.MostVisitedPage(), 117 newTabView.appendTilePage(new ntp.MostVisitedPage(),
118 localStrings.getString('mostvisited'), 118 localStrings.getString('mostvisited'),
119 false); 119 false);
120 chrome.send('getMostVisited'); 120 chrome.send('getMostVisited');
121 121
122 if (templateData.isSuggestionsPageEnabled) {
123 var suggestions_script = document.createElement('script');
124 suggestions_script.src = 'suggestions_page.js';
125 suggestions_script.onload = function() {
126 newTabView.appendTilePage(new ntp.SuggestionsPage(),
127 localStrings.getString('suggestions'),
128 false,
129 (newTabView.appsPages.length > 0) ?
130 newTabView.appsPages[0] : null);
131 chrome.send('getSuggestions');
132 };
133 document.querySelector('head').appendChild(suggestions_script);
134 }
135
122 var webstoreLink = localStrings.getString('webStoreLink'); 136 var webstoreLink = localStrings.getString('webStoreLink');
123 if (templateData.isWebStoreExperimentEnabled) { 137 if (templateData.isWebStoreExperimentEnabled) {
124 var url = appendParam(webstoreLink, 'utm_source', 'chrome-ntp-launcher'); 138 var url = appendParam(webstoreLink, 'utm_source', 'chrome-ntp-launcher');
125 $('chrome-web-store-href').href = url; 139 $('chrome-web-store-href').href = url;
126 $('chrome-web-store-href').addEventListener('click', 140 $('chrome-web-store-href').addEventListener('click',
127 onChromeWebStoreButtonClick); 141 onChromeWebStoreButtonClick);
128 142
129 $('footer-content').classList.add('enable-cws-experiment'); 143 $('footer-content').classList.add('enable-cws-experiment');
130 } 144 }
131 145
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 445
432 function setRecentlyClosedTabs(dataItems) { 446 function setRecentlyClosedTabs(dataItems) {
433 $('recently-closed-menu-button').dataItems = dataItems; 447 $('recently-closed-menu-button').dataItems = dataItems;
434 } 448 }
435 449
436 function setMostVisitedPages(data, hasBlacklistedUrls) { 450 function setMostVisitedPages(data, hasBlacklistedUrls) {
437 newTabView.mostVisitedPage.data = data; 451 newTabView.mostVisitedPage.data = data;
438 cr.dispatchSimpleEvent(document, 'sectionready', true, true); 452 cr.dispatchSimpleEvent(document, 'sectionready', true, true);
439 } 453 }
440 454
455 function setSuggestionsPages(data, hasBlacklistedUrls) {
456 newTabView.suggestionsPage.data = data;
457 }
458
441 /** 459 /**
442 * Set the dominant color for a node. This will be called in response to 460 * Set the dominant color for a node. This will be called in response to
443 * getFaviconDominantColor. The node represented by |id| better have a setter 461 * getFaviconDominantColor. The node represented by |id| better have a setter
444 * for stripeColor. 462 * for stripeColor.
445 * @param {string} id The ID of a node. 463 * @param {string} id The ID of a node.
446 * @param {string} color The color represented as a CSS string. 464 * @param {string} color The color represented as a CSS string.
447 */ 465 */
448 function setStripeColor(id, color) { 466 function setStripeColor(id, color) {
449 var node = $(id); 467 var node = $(id);
450 if (node) 468 if (node)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 foreignSessions: foreignSessions, 570 foreignSessions: foreignSessions,
553 getAppsCallback: getAppsCallback, 571 getAppsCallback: getAppsCallback,
554 getAppsPageIndex: getAppsPageIndex, 572 getAppsPageIndex: getAppsPageIndex,
555 getCardSlider: getCardSlider, 573 getCardSlider: getCardSlider,
556 onLoad: onLoad, 574 onLoad: onLoad,
557 leaveRearrangeMode: leaveRearrangeMode, 575 leaveRearrangeMode: leaveRearrangeMode,
558 saveAppPageName: saveAppPageName, 576 saveAppPageName: saveAppPageName,
559 setAppToBeHighlighted: setAppToBeHighlighted, 577 setAppToBeHighlighted: setAppToBeHighlighted,
560 setBookmarkBarAttached: setBookmarkBarAttached, 578 setBookmarkBarAttached: setBookmarkBarAttached,
561 setMostVisitedPages: setMostVisitedPages, 579 setMostVisitedPages: setMostVisitedPages,
580 setSuggestionsPages: setSuggestionsPages,
562 setRecentlyClosedTabs: setRecentlyClosedTabs, 581 setRecentlyClosedTabs: setRecentlyClosedTabs,
563 setStripeColor: setStripeColor, 582 setStripeColor: setStripeColor,
564 showNotification: showNotification, 583 showNotification: showNotification,
565 themeChanged: themeChanged, 584 themeChanged: themeChanged,
566 updateLogin: updateLogin 585 updateLogin: updateLogin
567 }; 586 };
568 }); 587 });
569 588
570 document.addEventListener('DOMContentLoaded', ntp.onLoad); 589 document.addEventListener('DOMContentLoaded', ntp.onLoad);
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