Chromium Code Reviews| Index: chrome/browser/resources/ntp/apps.js |
| diff --git a/chrome/browser/resources/ntp/apps.js b/chrome/browser/resources/ntp/apps.js |
| index 81d7eb0624569050c58f00ba3e3c70a1875cc3ab..3b21f91e9251b1f53dc777f35e5c6a0339ceac1a 100644 |
| --- a/chrome/browser/resources/ntp/apps.js |
| +++ b/chrome/browser/resources/ntp/apps.js |
| @@ -6,19 +6,28 @@ var MAX_APPS_PER_ROW = []; |
| MAX_APPS_PER_ROW[LayoutMode.SMALL] = 4; |
| MAX_APPS_PER_ROW[LayoutMode.NORMAL] = 6; |
| +// The URL prefix used in the app link 'ping' attributes. |
| +var PING_APP_LAUNCH_PREFIX = 'record-app-launch'; |
| + |
| +// The URL prefix used in the webstore link 'ping' attributes. |
| +var PING_WEBSTORE_LAUNCH_PREFIX = 'record-webstore-launch'; |
| + |
| function getAppsCallback(data) { |
| logEvent('received apps'); |
| var appsSection = $('apps'); |
| var appsSectionContent = $('apps-content'); |
| var appsMiniview = appsSection.getElementsByClassName('miniview')[0]; |
| var appsPromo = $('apps-promo'); |
| + var appsPromoPing = PING_WEBSTORE_LAUNCH_PREFIX + '+' + data.showPromo; |
| var webStoreEntry; |
| appsMiniview.textContent = ''; |
| appsSectionContent.textContent = ''; |
| + apps.setPromoActive(data.showPromo); |
| + |
| data.apps.sort(function(a,b) { |
| - return a.app_launch_index - b.app_launch_index |
| + return a.app_launch_index - b.app_launch_index; |
| }); |
| clearClosedMenu(apps.menu); |
| @@ -31,6 +40,7 @@ function getAppsCallback(data) { |
| }); |
| webStoreEntry = apps.createWebStoreElement(); |
| + webStoreEntry.querySelector('a').setAttribute('ping', appsPromoPing); |
| appsSectionContent.appendChild(webStoreEntry); |
| data.apps.slice(0, MAX_MINIVIEW_ITEMS).forEach(function(app) { |
| @@ -49,6 +59,7 @@ function getAppsCallback(data) { |
| document.documentElement.classList.add('apps-promo-visible'); |
| else |
| document.documentElement.classList.remove('apps-promo-visible'); |
| + $('apps-promo-link').setAttribute('ping', appsPromoPing); |
| maybeDoneLoading(); |
| if (data.apps.length > 0 && isDoneLoading()) { |
| @@ -150,6 +161,7 @@ var apps = (function() { |
| }; |
| var currentApp; |
| + var promoActive; |
| function addContextMenu(el, app) { |
| el.addEventListener('contextmenu', cr.ui.contextMenuHandler); |
| @@ -227,11 +239,16 @@ var apps = (function() { |
| menu: $('apps-menu'), |
| + setPromoActive: function(isPromoActive) { |
|
Aaron Boodman
2010/11/12 00:29:20
Nit: I think the setter is overkill here. You can
|
| + promoActive = isPromoActive; |
| + }, |
| + |
| createElement: function(app) { |
| var div = createElement(app); |
| var a = div.firstChild; |
| a.onclick = handleClick; |
| + a.setAttribute('ping', PING_APP_LAUNCH_PREFIX + '+' + promoActive); |
| a.style.backgroundImage = url(app['icon_big']); |
| if (hashParams['app-id'] == app['id']) { |
| div.setAttribute('new', 'new'); |
| @@ -271,6 +288,7 @@ var apps = (function() { |
| a.textContent = app['name']; |
| a.href = app['launch_url']; |
| a.onclick = handleClick; |
| + a.setAttribute('ping', PING_APP_LAUNCH_PREFIX + '+' + promoActive); |
| a.style.backgroundImage = url(app['icon_small']); |
| a.className = 'item'; |
| span.appendChild(a); |
| @@ -286,6 +304,7 @@ var apps = (function() { |
| a.textContent = app['name']; |
| a.href = app['launch_url']; |
| a.onclick = handleClick; |
| + a.setAttribute('ping', PING_APP_LAUNCH_PREFIX + '+' + promoActive); |
| a.style.backgroundImage = url(app['icon_small']); |
| a.className = 'item'; |
| return a; |