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

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

Issue 7610014: [ntp4] Bookmarks page implementation, first-pass. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 cr.ui.decorate($('recently-closed-menu-button'), ntp4.RecentMenuButton); 183 cr.ui.decorate($('recently-closed-menu-button'), ntp4.RecentMenuButton);
184 chrome.send('getRecentlyClosedTabs'); 184 chrome.send('getRecentlyClosedTabs');
185 185
186 mostVisitedPage = new ntp4.MostVisitedPage(); 186 mostVisitedPage = new ntp4.MostVisitedPage();
187 appendTilePage(mostVisitedPage, localStrings.getString('mostvisited')); 187 appendTilePage(mostVisitedPage, localStrings.getString('mostvisited'));
188 chrome.send('getMostVisited'); 188 chrome.send('getMostVisited');
189 189
190 bookmarksPage = new ntp4.BookmarksPage(); 190 bookmarksPage = new ntp4.BookmarksPage();
191 appendTilePage(bookmarksPage, localStrings.getString('bookmarksPage')); 191 appendTilePage(bookmarksPage, localStrings.getString('bookmarksPage'));
192 chrome.send('getBookmarks'); 192 chrome.send('getBookmarksData');
193 } 193 }
194 194
195 /** 195 /**
196 * Simple common assertion API 196 * Simple common assertion API
197 * @param {*} condition The condition to test. Note that this may be used to 197 * @param {*} condition The condition to test. Note that this may be used to
198 * test whether a value is defined or not, and we don't want to force a 198 * test whether a value is defined or not, and we don't want to force a
199 * cast to Boolean. 199 * cast to Boolean.
200 * @param {string=} opt_message A message to use in any error. 200 * @param {string=} opt_message A message to use in any error.
201 */ 201 */
202 function assert(condition, opt_message) { 202 function assert(condition, opt_message) {
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 } 663 }
664 664
665 function setRecentlyClosedTabs(dataItems) { 665 function setRecentlyClosedTabs(dataItems) {
666 $('recently-closed-menu-button').dataItems = dataItems; 666 $('recently-closed-menu-button').dataItems = dataItems;
667 } 667 }
668 668
669 function setMostVisitedPages(data, hasBlacklistedUrls) { 669 function setMostVisitedPages(data, hasBlacklistedUrls) {
670 mostVisitedPage.data = data; 670 mostVisitedPage.data = data;
671 } 671 }
672 672
673 function setBookmarksData(data) {
674 bookmarksPage.data = data;
675 }
676
673 /** 677 /**
674 * Check the directionality of the page. 678 * Check the directionality of the page.
675 * @return {boolean} True if Chrome is running an RTL UI. 679 * @return {boolean} True if Chrome is running an RTL UI.
676 */ 680 */
677 function isRTL() { 681 function isRTL() {
678 return document.documentElement.dir == 'rtl'; 682 return document.documentElement.dir == 'rtl';
679 } 683 }
680 684
681 /* 685 /*
682 * Save the name of an app page. 686 * Save the name of an app page.
683 * Store the app page name into the preferences store. 687 * Store the app page name into the preferences store.
684 * @param {AppsPage} appPage The app page for which we wish to save. 688 * @param {AppsPage} appPage The app page for which we wish to save.
685 * @param {string} name The name of the page. 689 * @param {string} name The name of the page.
686 */ 690 */
687 function saveAppPageName(appPage, name) { 691 function saveAppPageName(appPage, name) {
688 var index = getAppsPageIndex(appPage); 692 var index = getAppsPageIndex(appPage);
689 assert(index != -1); 693 assert(index != -1);
690 chrome.send('saveAppPageName', [name, index]); 694 chrome.send('saveAppPageName', [name, index]);
691 } 695 }
692 696
693 // Return an object with all the exports 697 // Return an object with all the exports
694 return { 698 return {
695 assert: assert,
696 appAdded: appAdded, 699 appAdded: appAdded,
697 appRemoved: appRemoved, 700 appRemoved: appRemoved,
698 appsPrefChangeCallback: appsPrefChangeCallback, 701 appsPrefChangeCallback: appsPrefChangeCallback,
702 assert: assert,
699 enterRearrangeMode: enterRearrangeMode, 703 enterRearrangeMode: enterRearrangeMode,
700 getAppsCallback: getAppsCallback, 704 getAppsCallback: getAppsCallback,
705 getAppsPageIndex: getAppsPageIndex,
701 getCardSlider: getCardSlider, 706 getCardSlider: getCardSlider,
702 getAppsPageIndex: getAppsPageIndex,
703 initialize: initialize, 707 initialize: initialize,
704 isRTL: isRTL, 708 isRTL: isRTL,
705 leaveRearrangeMode: leaveRearrangeMode, 709 leaveRearrangeMode: leaveRearrangeMode,
706 themeChanged: themeChanged, 710 saveAppPageName: saveAppPageName,
711 setBookmarksData: setBookmarksData,
712 setMostVisitedPages: setMostVisitedPages,
707 setRecentlyClosedTabs: setRecentlyClosedTabs, 713 setRecentlyClosedTabs: setRecentlyClosedTabs,
708 setMostVisitedPages: setMostVisitedPages,
709 showNotification: showNotification, 714 showNotification: showNotification,
710 saveAppPageName: saveAppPageName 715 themeChanged: themeChanged
711 }; 716 };
712 }); 717 });
713 718
714 // publish ntp globals 719 // publish ntp globals
715 // TODO(estade): update the content handlers to use ntp namespace instead of 720 // TODO(estade): update the content handlers to use ntp namespace instead of
716 // making these global. 721 // making these global.
717 var assert = ntp4.assert; 722 var assert = ntp4.assert;
718 var getAppsCallback = ntp4.getAppsCallback; 723 var getAppsCallback = ntp4.getAppsCallback;
719 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; 724 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback;
720 var themeChanged = ntp4.themeChanged; 725 var themeChanged = ntp4.themeChanged;
721 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; 726 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs;
722 var setMostVisitedPages = ntp4.setMostVisitedPages; 727 var setMostVisitedPages = ntp4.setMostVisitedPages;
723 728
724 document.addEventListener('DOMContentLoaded', ntp4.initialize); 729 document.addEventListener('DOMContentLoaded', ntp4.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698