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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 | 340 |
341 document.documentElement.classList.remove('starting-up'); | 341 document.documentElement.classList.remove('starting-up'); |
342 } | 342 } |
343 | 343 |
344 /** | 344 /** |
345 * Called by chrome when a new app has been added to chrome. | 345 * Called by chrome when a new app has been added to chrome. |
346 * @param {Object} app A data structure full of relevant information for the | 346 * @param {Object} app A data structure full of relevant information for the |
347 * app. | 347 * app. |
348 */ | 348 */ |
349 function appAdded(app, opt_highlight) { | 349 function appAdded(app, opt_highlight) { |
350 // If the page is already open when a new app is installed, the hash will | 350 if (app.id == highlightAppId) { |
351 // be set once again. | |
352 var appID = getAndClearAppIDHash(); | |
353 if (appID == app.id) | |
354 opt_highlight = true; | 351 opt_highlight = true; |
352 highlightAppId = null; | |
353 } | |
355 | 354 |
356 var pageIndex = app.page_index || 0; | 355 var pageIndex = app.page_index || 0; |
357 | 356 |
358 if (pageIndex >= appsPages.length) { | 357 if (pageIndex >= appsPages.length) { |
359 while (pageIndex >= appsPages.length) { | 358 while (pageIndex >= appsPages.length) { |
360 appendAppsPage(new ntp4.AppsPage(), ''); | 359 appendAppsPage(new ntp4.AppsPage(), ''); |
361 } | 360 } |
362 updateSliderCards(); | 361 updateSliderCards(); |
363 } | 362 } |
364 | 363 |
365 var page = appsPages[pageIndex]; | 364 var page = appsPages[pageIndex]; |
366 if (opt_highlight) | 365 page.appendApp(app, opt_highlight); |
367 cardSlider.selectCardByValue(page); | |
368 page.appendApp(app, true); | |
369 } | 366 } |
370 | 367 |
371 /** | 368 /** |
369 * Sets that an app should be highlighted if it is added. Called right before | |
370 * appAdded for new installs. | |
371 */ | |
372 function setAppToBeHighlighted(appId) { | |
373 highlightAppId = appId; | |
Rick Byers
2011/08/29 16:01:00
Should you perhaps assert that highlightAppId is n
Evan Stade
2011/08/29 18:15:16
yea I assume it's possible if unlikely to have a r
Rick Byers
2011/08/29 19:51:12
Yeah, I guess the race potential and highlight-las
| |
374 } | |
375 | |
376 /** | |
372 * Called by chrome when an existing app has been removed/uninstalled from | 377 * Called by chrome when an existing app has been removed/uninstalled from |
373 * chrome. | 378 * chrome. |
374 * @param {Object} appData A data structure full of relevant information for | 379 * @param {Object} appData A data structure full of relevant information for |
375 * the app. | 380 * the app. |
376 */ | 381 */ |
377 function appRemoved(appData) { | 382 function appRemoved(appData) { |
378 var app = $(appData.id); | 383 var app = $(appData.id); |
379 assert(app, 'trying to remove an app that doesn\'t exist'); | 384 assert(app, 'trying to remove an app that doesn\'t exist'); |
380 | 385 |
381 var tile = findAncestorByClass(app, 'tile'); | 386 var tile = findAncestorByClass(app, 'tile'); |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 appsPrefChangeCallback: appsPrefChangeCallback, | 773 appsPrefChangeCallback: appsPrefChangeCallback, |
769 assert: assert, | 774 assert: assert, |
770 enterRearrangeMode: enterRearrangeMode, | 775 enterRearrangeMode: enterRearrangeMode, |
771 getAppsCallback: getAppsCallback, | 776 getAppsCallback: getAppsCallback, |
772 getAppsPageIndex: getAppsPageIndex, | 777 getAppsPageIndex: getAppsPageIndex, |
773 getCardSlider: getCardSlider, | 778 getCardSlider: getCardSlider, |
774 initialize: initialize, | 779 initialize: initialize, |
775 isRTL: isRTL, | 780 isRTL: isRTL, |
776 leaveRearrangeMode: leaveRearrangeMode, | 781 leaveRearrangeMode: leaveRearrangeMode, |
777 saveAppPageName: saveAppPageName, | 782 saveAppPageName: saveAppPageName, |
783 setAppToBeHighlighted: setAppToBeHighlighted, | |
778 setBookmarksData: setBookmarksData, | 784 setBookmarksData: setBookmarksData, |
779 setMostVisitedPages: setMostVisitedPages, | 785 setMostVisitedPages: setMostVisitedPages, |
780 setRecentlyClosedTabs: setRecentlyClosedTabs, | 786 setRecentlyClosedTabs: setRecentlyClosedTabs, |
781 showNotification: showNotification, | 787 showNotification: showNotification, |
782 themeChanged: themeChanged | 788 themeChanged: themeChanged |
783 }; | 789 }; |
784 }); | 790 }); |
785 | 791 |
786 // publish ntp globals | 792 // publish ntp globals |
787 // TODO(estade): update the content handlers to use ntp namespace instead of | 793 // TODO(estade): update the content handlers to use ntp namespace instead of |
788 // making these global. | 794 // making these global. |
789 var assert = ntp4.assert; | 795 var assert = ntp4.assert; |
790 var getAppsCallback = ntp4.getAppsCallback; | 796 var getAppsCallback = ntp4.getAppsCallback; |
791 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; | 797 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; |
792 var themeChanged = ntp4.themeChanged; | 798 var themeChanged = ntp4.themeChanged; |
793 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; | 799 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; |
794 var setMostVisitedPages = ntp4.setMostVisitedPages; | 800 var setMostVisitedPages = ntp4.setMostVisitedPages; |
795 | 801 |
796 document.addEventListener('DOMContentLoaded', ntp4.initialize); | 802 document.addEventListener('DOMContentLoaded', ntp4.initialize); |
OLD | NEW |