Chromium Code Reviews| Index: chrome/browser/resources/ntp4/new_tab.js |
| diff --git a/chrome/browser/resources/ntp4/new_tab.js b/chrome/browser/resources/ntp4/new_tab.js |
| index df176032abc0cfbf2bcb33893f356f5d0b61b31e..4e0a3ce8155eb87521633e2770d0fecf87deb205 100644 |
| --- a/chrome/browser/resources/ntp4/new_tab.js |
| +++ b/chrome/browser/resources/ntp4/new_tab.js |
| @@ -342,9 +342,10 @@ cr.define('ntp4', function() { |
| } |
| /** |
| - * Called by chrome when a new app has been added to chrome. |
| - * @param {Object} app A data structure full of relevant information for the |
| - * app. |
| + * Called by chrome when a new app has been added to chrome or has been |
| + * enabled if previously disabled. |
| + * @param {Object} appData A data structure full of relevant information for |
| + * the app. |
| */ |
| function appAdded(app, opt_highlight) { |
| // If the page is already open when a new app is installed, the hash will |
| @@ -365,21 +366,30 @@ cr.define('ntp4', function() { |
| var page = appsPages[pageIndex]; |
| if (opt_highlight) |
| cardSlider.selectCardByValue(page); |
| - page.appendApp(app, true); |
| + var app = $(appData.id); |
| + if (app) { |
|
Evan Stade
2011/08/30 03:34:14
no curlies
Yoyo Zhou
2011/08/30 17:37:10
Done.
|
| + app.replaceAppData(appData); |
| + } else { |
| + page.appendApp(appData, true); |
| + } |
| } |
| /** |
| - * Called by chrome when an existing app has been removed/uninstalled from |
| - * chrome. |
| + * Called by chrome when an existing app has been disabled or |
| + * removed/uninstalled from chrome. |
| * @param {Object} appData A data structure full of relevant information for |
| * the app. |
| */ |
| - function appRemoved(appData) { |
| + function appRemoved(appData, is_uninstall) { |
|
Evan Stade
2011/08/30 03:34:14
isUninstall
also, doc the param
Yoyo Zhou
2011/08/30 17:37:10
Done.
|
| var app = $(appData.id); |
| assert(app, 'trying to remove an app that doesn\'t exist'); |
| - var tile = findAncestorByClass(app, 'tile'); |
| - tile.doRemove(); |
| + if (!is_uninstall) { |
| + app.replaceAppData(appData); |
| + } else { |
| + var tile = findAncestorByClass(app, 'tile'); |
| + tile.doRemove(); |
| + } |
| } |
| /** |
| @@ -410,6 +420,17 @@ cr.define('ntp4', function() { |
| } |
| } |
| + /** |
| + * Listener for offline status change events. Updates apps that are |
| + * not offline-enabled to be grayscale if the browser is offline. |
| + */ |
| + function updateOfflineEnabledApps() { |
| + for (var i = 0; i < apps.length; ++i) { |
| + if (apps[i].appData.enabled && !apps[i].appData.offline_enabled) |
| + apps[i].setIcon(); |
| + } |
| + } |
| + |
| function getCardSlider() { |
| return cardSlider; |
| } |
| @@ -779,7 +800,8 @@ cr.define('ntp4', function() { |
| setMostVisitedPages: setMostVisitedPages, |
| setRecentlyClosedTabs: setRecentlyClosedTabs, |
| showNotification: showNotification, |
| - themeChanged: themeChanged |
| + themeChanged: themeChanged, |
| + updateOfflineEnabledApps: updateOfflineEnabledApps |
| }; |
| }); |
| @@ -794,3 +816,5 @@ var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; |
| var setMostVisitedPages = ntp4.setMostVisitedPages; |
| document.addEventListener('DOMContentLoaded', ntp4.initialize); |
| +document.addEventListener('online', ntp4.updateOfflineEnabledApps); |
| +document.addEventListener('offline', ntp4.updateOfflineEnabledApps); |