OLD | NEW |
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 infoBubble = new cr.ui.Bubble; | 199 infoBubble = new cr.ui.Bubble; |
200 infoBubble.anchorNode = mostVisitedPage.navigationDot; | 200 infoBubble.anchorNode = mostVisitedPage.navigationDot; |
201 infoBubble.text = localStrings.getString('ntp4_intro_message'); | 201 infoBubble.text = localStrings.getString('ntp4_intro_message'); |
202 infoBubble.show(); | 202 infoBubble.show(); |
203 | 203 |
204 chrome.send('introMessageSeen'); | 204 chrome.send('introMessageSeen'); |
205 } | 205 } |
206 | 206 |
207 bookmarksPage = new ntp4.BookmarksPage(); | 207 bookmarksPage = new ntp4.BookmarksPage(); |
208 appendTilePage(bookmarksPage, localStrings.getString('bookmarksPage')); | 208 appendTilePage(bookmarksPage, localStrings.getString('bookmarksPage')); |
209 chrome.send('getBookmarks'); | 209 chrome.send('getBookmarksData'); |
210 } | 210 } |
211 | 211 |
212 /** | 212 /** |
213 * Simple common assertion API | 213 * Simple common assertion API |
214 * @param {*} condition The condition to test. Note that this may be used to | 214 * @param {*} condition The condition to test. Note that this may be used to |
215 * test whether a value is defined or not, and we don't want to force a | 215 * test whether a value is defined or not, and we don't want to force a |
216 * cast to Boolean. | 216 * cast to Boolean. |
217 * @param {string=} opt_message A message to use in any error. | 217 * @param {string=} opt_message A message to use in any error. |
218 */ | 218 */ |
219 function assert(condition, opt_message) { | 219 function assert(condition, opt_message) { |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 } | 681 } |
682 | 682 |
683 function setRecentlyClosedTabs(dataItems) { | 683 function setRecentlyClosedTabs(dataItems) { |
684 $('recently-closed-menu-button').dataItems = dataItems; | 684 $('recently-closed-menu-button').dataItems = dataItems; |
685 } | 685 } |
686 | 686 |
687 function setMostVisitedPages(data, hasBlacklistedUrls) { | 687 function setMostVisitedPages(data, hasBlacklistedUrls) { |
688 mostVisitedPage.data = data; | 688 mostVisitedPage.data = data; |
689 } | 689 } |
690 | 690 |
| 691 function setBookmarksData(data) { |
| 692 bookmarksPage.data = data; |
| 693 } |
| 694 |
691 /** | 695 /** |
692 * Check the directionality of the page. | 696 * Check the directionality of the page. |
693 * @return {boolean} True if Chrome is running an RTL UI. | 697 * @return {boolean} True if Chrome is running an RTL UI. |
694 */ | 698 */ |
695 function isRTL() { | 699 function isRTL() { |
696 return document.documentElement.dir == 'rtl'; | 700 return document.documentElement.dir == 'rtl'; |
697 } | 701 } |
698 | 702 |
699 /* | 703 /* |
700 * Save the name of an app page. | 704 * Save the name of an app page. |
701 * Store the app page name into the preferences store. | 705 * Store the app page name into the preferences store. |
702 * @param {AppsPage} appPage The app page for which we wish to save. | 706 * @param {AppsPage} appPage The app page for which we wish to save. |
703 * @param {string} name The name of the page. | 707 * @param {string} name The name of the page. |
704 */ | 708 */ |
705 function saveAppPageName(appPage, name) { | 709 function saveAppPageName(appPage, name) { |
706 var index = getAppsPageIndex(appPage); | 710 var index = getAppsPageIndex(appPage); |
707 assert(index != -1); | 711 assert(index != -1); |
708 chrome.send('saveAppPageName', [name, index]); | 712 chrome.send('saveAppPageName', [name, index]); |
709 } | 713 } |
710 | 714 |
711 // Return an object with all the exports | 715 // Return an object with all the exports |
712 return { | 716 return { |
713 assert: assert, | |
714 appAdded: appAdded, | 717 appAdded: appAdded, |
715 appRemoved: appRemoved, | 718 appRemoved: appRemoved, |
716 appsPrefChangeCallback: appsPrefChangeCallback, | 719 appsPrefChangeCallback: appsPrefChangeCallback, |
| 720 assert: assert, |
717 enterRearrangeMode: enterRearrangeMode, | 721 enterRearrangeMode: enterRearrangeMode, |
718 getAppsCallback: getAppsCallback, | 722 getAppsCallback: getAppsCallback, |
| 723 getAppsPageIndex: getAppsPageIndex, |
719 getCardSlider: getCardSlider, | 724 getCardSlider: getCardSlider, |
720 getAppsPageIndex: getAppsPageIndex, | |
721 initialize: initialize, | 725 initialize: initialize, |
722 isRTL: isRTL, | 726 isRTL: isRTL, |
723 leaveRearrangeMode: leaveRearrangeMode, | 727 leaveRearrangeMode: leaveRearrangeMode, |
724 themeChanged: themeChanged, | 728 saveAppPageName: saveAppPageName, |
| 729 setBookmarksData: setBookmarksData, |
| 730 setMostVisitedPages: setMostVisitedPages, |
725 setRecentlyClosedTabs: setRecentlyClosedTabs, | 731 setRecentlyClosedTabs: setRecentlyClosedTabs, |
726 setMostVisitedPages: setMostVisitedPages, | |
727 showNotification: showNotification, | 732 showNotification: showNotification, |
728 saveAppPageName: saveAppPageName | 733 themeChanged: themeChanged |
729 }; | 734 }; |
730 }); | 735 }); |
731 | 736 |
732 // publish ntp globals | 737 // publish ntp globals |
733 // TODO(estade): update the content handlers to use ntp namespace instead of | 738 // TODO(estade): update the content handlers to use ntp namespace instead of |
734 // making these global. | 739 // making these global. |
735 var assert = ntp4.assert; | 740 var assert = ntp4.assert; |
736 var getAppsCallback = ntp4.getAppsCallback; | 741 var getAppsCallback = ntp4.getAppsCallback; |
737 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; | 742 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; |
738 var themeChanged = ntp4.themeChanged; | 743 var themeChanged = ntp4.themeChanged; |
739 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; | 744 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; |
740 var setMostVisitedPages = ntp4.setMostVisitedPages; | 745 var setMostVisitedPages = ntp4.setMostVisitedPages; |
741 | 746 |
742 document.addEventListener('DOMContentLoaded', ntp4.initialize); | 747 document.addEventListener('DOMContentLoaded', ntp4.initialize); |
OLD | NEW |