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

Unified Diff: chrome/browser/resources/ntp/apps.js

Issue 6825052: Update the web store promo to be clearer and configurable at run-time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix URL. Created 9 years, 8 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/ntp/apps.js
diff --git a/chrome/browser/resources/ntp/apps.js b/chrome/browser/resources/ntp/apps.js
index 89f61dcdfd162ced49351099e3353ac0ba7b7df0..f0d55358a88148ffaffe794d69ef45e756a0dcc1 100644
--- a/chrome/browser/resources/ntp/apps.js
+++ b/chrome/browser/resources/ntp/apps.js
@@ -18,6 +18,7 @@ function getAppsCallback(data) {
var appsSectionContent = $('apps-content');
var appsMiniview = appsSection.getElementsByClassName('miniview')[0];
var appsPromo = $('apps-promo');
+ var appsPromoLink = $('apps-promo-link');
var appsPromoPing = APP_LAUNCH_URL.PING_WEBSTORE + '+' + apps.showPromo;
var webStoreEntry, webStoreMiniEntry;
@@ -48,8 +49,6 @@ function getAppsCallback(data) {
markNewApps(data.apps);
apps.data = data.apps;
- if (!apps.detachWebstoreEntry)
- apps.data.push('web-store-entry');
clearClosedMenu(apps.menu);
@@ -62,9 +61,33 @@ function getAppsCallback(data) {
appsSectionContent.appendChild(apps.createElement(app));
});
- webStoreEntry = apps.createWebStoreElement();
- webStoreEntry.querySelector('a').setAttribute('ping', appsPromoPing);
- appsSectionContent.appendChild(webStoreEntry);
+ if (data.showPromo) {
+ // Add the promo content...
+ $('apps-promo-heading').textContent = data.promoHeader;
+ appsPromoLink.href = data.promoLink;
+ appsPromoLink.textContent = data.promoButton;
+ appsPromoLink.setAttribute('ping', appsPromoPing);
arv (Not doing code reviews) 2011/04/13 17:17:59 I added the ping dom binding 2 weeks ago. Can you
jstritar 2011/04/13 19:52:27 Done.
+ $('apps-promo-hide').textContent = data.promoExpire;
+
+ // ... then display the promo.
+ document.documentElement.classList.add('apps-promo-visible');
+ } else {
+ document.documentElement.classList.remove('apps-promo-visible');
+ }
+
+ // Only show the web store entry if there are apps installed, since the promo
+ // is sufficient otherwise.
+ if (data.apps.length > 0) {
+ webStoreEntry = apps.createWebStoreElement();
+ webStoreEntry.querySelector('a').setAttribute('ping', appsPromoPing);
+ appsSectionContent.appendChild(webStoreEntry);
+ if (apps.detachWebstoreEntry) {
+ webStoreEntry.classList.add('loner');
+ } else {
+ webStoreEntry.classList.remove('loner');
+ apps.data.push('web-store-entry');
+ }
+ }
data.apps.slice(0, MAX_MINIVIEW_ITEMS).forEach(function(app) {
appsMiniview.appendChild(apps.createMiniviewElement(app));
@@ -72,7 +95,7 @@ function getAppsCallback(data) {
});
if (data.apps.length < MAX_MINIVIEW_ITEMS) {
webStoreMiniEntry = apps.createWebStoreMiniElement();
- webStoreEntry.querySelector('a').setAttribute('ping', appsPromoPing);
+ webStoreMiniEntry.querySelector('a').setAttribute('ping', appsPromoPing);
appsMiniview.appendChild(webStoreMiniEntry);
addClosedMenuEntryWithLink(apps.menu,
apps.createWebStoreClosedMenuElement());
@@ -86,10 +109,6 @@ function getAppsCallback(data) {
addClosedMenuFooter(apps.menu, 'apps', MENU_APPS, Section.APPS);
apps.loaded = true;
- if (apps.showPromo)
- document.documentElement.classList.add('apps-promo-visible');
- else
- document.documentElement.classList.remove('apps-promo-visible');
var appsPromoLink = $('apps-promo-link');
if (appsPromoLink)
@@ -99,11 +118,6 @@ function getAppsCallback(data) {
// Disable the animations when the app launcher is being (re)initailized.
apps.layout({disableAnimations:true});
- if (apps.detachWebstoreEntry)
- webStoreEntry.classList.add('loner');
- else
- webStoreEntry.classList.remove('loner');
-
if (isDoneLoading()) {
updateMiniviewClipping(appsMiniview);
layoutSections();
@@ -175,6 +189,11 @@ var apps = (function() {
chrome.send('launchApp', args);
}
+ function isAppSectionMaximized() {
+ return (getAppLaunchType() == APP_LAUNCH.NTP_APPS_MAXIMIZED) &&
arv (Not doing code reviews) 2011/04/13 17:17:59 useless parentheses
jstritar 2011/04/13 19:52:27 Done.
+ !$('apps').classList.contains('disabled');
+ }
+
function isAppsMenu(node) {
return node.id == 'apps-menu';
}
@@ -216,6 +235,7 @@ var apps = (function() {
};
var currentApp;
+ var promoHasBeenSeen = false;
function addContextMenu(el, app) {
el.addEventListener('contextmenu', cr.ui.contextMenuHandler);
@@ -347,6 +367,14 @@ var apps = (function() {
this.invalidate_();
},
+ maybePingPromoSeen_: function() {
+ if (promoHasBeenSeen) return;
arv (Not doing code reviews) 2011/04/13 17:17:59 if (...) return;
jstritar 2011/04/13 19:52:27 Done.
+ if (!this.showPromo || !isAppSectionMaximized()) return;
arv (Not doing code reviews) 2011/04/13 17:17:59 merge if statements?
jstritar 2011/04/13 19:52:27 Done.
+
+ promoHasBeenSeen = true;
+ chrome.send('promoSeen', []);
+ },
+
// DragAndDropDelegate
dragContainer: $('apps-content'),
@@ -564,10 +592,14 @@ var apps = (function() {
},
layoutImpl_: function() {
- var apps = this.data;
+ var apps = this.data || [];
var rects = this.getLayoutRects_(apps.length);
var appsContent = this.dragContainer;
+ // Ping the PROMO_SEEN histogram only when the promo is maximized, and
+ // maximum once per NTP load.
+ this.maybePingPromoSeen_();
+
if (!this.visible)
return;

Powered by Google App Engine
This is Rietveld 408576698