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

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

Issue 7215035: ntp4: add app context menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: response to review comments Created 9 years, 6 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
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 b47c4018de46c1ce19e0b1784b9f6c38b4b48c75..98631ac0a8633adc24abf240fb194b43402cf7f0 100644
--- a/chrome/browser/resources/ntp4/new_tab.js
+++ b/chrome/browser/resources/ntp4/new_tab.js
@@ -245,14 +245,21 @@ cr.define('ntp4', function() {
/**
* Callback invoked by chrome whenever an app preference changes.
- * The normal NTP uses this to keep track of the current launch-type of an
- * app, updating the choices in the context menu. We don't have such a menu
- * so don't use this at all (but it still needs to be here for chrome to
- * call).
* @param {Object} data An object with all the data on available
- * applications.
+ * applications.
*/
function appsPrefChangeCallback(data) {
+ var apps = document.querySelectorAll('.app');
+
+ // This is an expensive operation. We minimize how frequently it's called
+ // by only calling it for changes across different instances of the NTP
+ // (i.e. two separate tabs both showing NTP).
+ for (var j = 0; j < data.apps.length; ++j) {
+ for (var i = 0; i < apps.length; ++i) {
+ if (data.apps[j]['id'] == apps[i].appId)
+ apps[i].appData = data.apps[j];
+ }
+ }
}
function getCardSlider() {

Powered by Google App Engine
This is Rietveld 408576698