summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/ntp/apps.js
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-14 21:12:10 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-14 21:12:10 +0000
commite5b5f958a41d75c9e183fd122eb530d747e29e4a (patch)
treeca68e6ee47d07a86ab51d1ee4cd5c0590360d87d /chrome/browser/resources/ntp/apps.js
parentc40151ab07cfb8fc7893c295726a5ad176d10ff3 (diff)
downloadchromium_src-e5b5f958a41d75c9e183fd122eb530d747e29e4a.zip
chromium_src-e5b5f958a41d75c9e183fd122eb530d747e29e4a.tar.gz
chromium_src-e5b5f958a41d75c9e183fd122eb530d747e29e4a.tar.bz2
Enable default apps by default.
Also, always show the apps section. We were only hiding it when there was zero elements when we were in our transitionary phase. To make this look less weird when there are actually zero elements, add the webstore element to the miniview and closed menus. BUG=64737 TEST=In a fresh profile, go to chrome://extensions/ -> developer mode, and click 'update now'. Go to NTP. Should see default apps. Remove all default apps. Apps section should remain. Collapse apps section by clicking heading. Should see webstore item in minimized view. Hide apps section by clicking 'x'. Should see webstore item in closed section menu on bottom of page. Review URL: http://codereview.chromium.org/5804005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69180 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/ntp/apps.js')
-rw-r--r--chrome/browser/resources/ntp/apps.js53
1 files changed, 35 insertions, 18 deletions
diff --git a/chrome/browser/resources/ntp/apps.js b/chrome/browser/resources/ntp/apps.js
index 41a5ebf..2be85fa 100644
--- a/chrome/browser/resources/ntp/apps.js
+++ b/chrome/browser/resources/ntp/apps.js
@@ -25,7 +25,7 @@ function getAppsCallback(data) {
var appsMiniview = appsSection.getElementsByClassName('miniview')[0];
var appsPromo = $('apps-promo');
var appsPromoPing = PING_WEBSTORE_LAUNCH_PREFIX + '+' + apps.showPromo;
- var webStoreEntry;
+ var webStoreEntry, webStoreMiniEntry;
// Hide menu options that are not supported on the OS or windowing system.
@@ -45,26 +45,28 @@ function getAppsCallback(data) {
});
clearClosedMenu(apps.menu);
- if (data.apps.length == 0 && !data.showLauncher) {
- appsSection.classList.add('disabled');
- layoutSections();
- } else {
- data.apps.forEach(function(app) {
- appsSectionContent.appendChild(apps.createElement(app));
- });
+ data.apps.forEach(function(app) {
+ appsSectionContent.appendChild(apps.createElement(app));
+ });
- webStoreEntry = apps.createWebStoreElement();
- webStoreEntry.querySelector('a').setAttribute('ping', appsPromoPing);
- appsSectionContent.appendChild(webStoreEntry);
+ webStoreEntry = apps.createWebStoreElement();
+ webStoreEntry.querySelector('a').setAttribute('ping', appsPromoPing);
+ appsSectionContent.appendChild(webStoreEntry);
- data.apps.slice(0, MAX_MINIVIEW_ITEMS).forEach(function(app) {
- appsMiniview.appendChild(apps.createMiniviewElement(app));
- addClosedMenuEntryWithLink(apps.menu, apps.createClosedMenuElement(app));
- });
+ data.apps.slice(0, MAX_MINIVIEW_ITEMS).forEach(function(app) {
+ appsMiniview.appendChild(apps.createMiniviewElement(app));
+ addClosedMenuEntryWithLink(apps.menu, apps.createClosedMenuElement(app));
+ });
+ if (data.apps.length < MAX_MINIVIEW_ITEMS) {
+ webStoreMiniEntry = apps.createWebStoreMiniElement();
+ webStoreEntry.querySelector('a').setAttribute('ping', appsPromoPing);
+ appsMiniview.appendChild(webStoreMiniEntry);
+ addClosedMenuEntryWithLink(apps.menu,
+ apps.createWebStoreClosedMenuElement());
+ }
- if (!(shownSections & MINIMIZED_APPS)) {
- appsSection.classList.remove('disabled');
- }
+ if (!(shownSections & MINIMIZED_APPS)) {
+ appsSection.classList.remove('disabled');
}
addClosedMenuFooter(apps.menu, 'apps', MINIMIZED_APPS, Section.APPS);
@@ -338,6 +340,21 @@ var apps = (function() {
});
elm.setAttribute('app-id', 'web-store-entry');
return elm;
+ },
+
+ createWebStoreMiniElement: function() {
+ var span = document.createElement('span');
+ span.appendChild(this.createWebStoreClosedMenuElement());
+ return span;
+ },
+
+ createWebStoreClosedMenuElement: function() {
+ var a = document.createElement('a');
+ a.textContent = localStrings.getString('web_store_title');
+ a.href = localStrings.getString('web_store_url');
+ a.style.backgroundImage = url('chrome://theme/IDR_PRODUCT_LOGO_16');
+ a.className = 'item';
+ return a;
}
};
})();