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

Unified Diff: chrome/browser/resources/ntp4/new_tab.js

Issue 7792024: Show app disable and enable on NTP, and desaturate non-offline-enabled apps when offline. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/ntp4/apps_page.js ('k') | chrome/browser/ui/webui/ntp/app_launcher_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 624b32e0a148a2a66137b99a7d5b283367c1b9b2..ecaf355031e950d67d0c9fa44273bce4c6e9ef79 100644
--- a/chrome/browser/resources/ntp4/new_tab.js
+++ b/chrome/browser/resources/ntp4/new_tab.js
@@ -319,17 +319,18 @@ 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 (app.id == highlightAppId) {
+ function appAdded(appData, opt_highlight) {
+ if (appData.id == highlightAppId) {
opt_highlight = true;
highlightAppId = null;
}
- var pageIndex = app.page_index || 0;
+ var pageIndex = appData.page_index || 0;
if (pageIndex >= appsPages.length) {
while (pageIndex >= appsPages.length) {
@@ -339,7 +340,11 @@ cr.define('ntp4', function() {
}
var page = appsPages[pageIndex];
- page.appendApp(app, opt_highlight);
+ var app = $(appData.id);
+ if (app)
+ app.replaceAppData(appData);
+ else
+ page.appendApp(appData, opt_highlight);
}
/**
@@ -351,15 +356,21 @@ cr.define('ntp4', function() {
}
/**
- * 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.
+ * @param {boolean} isUninstall True if the app is being uninstalled;
+ * false if the app is being disabled.
*/
- function appRemoved(appData) {
+ function appRemoved(appData, isUninstall) {
var app = $(appData.id);
assert(app, 'trying to remove an app that doesn\'t exist');
- app.remove();
+
+ if (!isUninstall)
+ app.replaceAppData(appData);
+ else
+ app.remove();
}
/**
@@ -390,6 +401,18 @@ 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() {
+ var apps = document.querySelectorAll('.app');
+ 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;
}
@@ -795,7 +818,8 @@ cr.define('ntp4', function() {
setMostVisitedPages: setMostVisitedPages,
setRecentlyClosedTabs: setRecentlyClosedTabs,
showNotification: showNotification,
- themeChanged: themeChanged
+ themeChanged: themeChanged,
+ updateOfflineEnabledApps: updateOfflineEnabledApps
};
});
@@ -810,3 +834,5 @@ var recentlyClosedTabs = ntp4.setRecentlyClosedTabs;
var setMostVisitedPages = ntp4.setMostVisitedPages;
document.addEventListener('DOMContentLoaded', ntp4.initialize);
+window.addEventListener('online', ntp4.updateOfflineEnabledApps);
+window.addEventListener('offline', ntp4.updateOfflineEnabledApps);
« no previous file with comments | « chrome/browser/resources/ntp4/apps_page.js ('k') | chrome/browser/ui/webui/ntp/app_launcher_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698