summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/dom_ui/app_launcher_handler.cc11
-rw-r--r--chrome/browser/extensions/default_apps.h4
-rw-r--r--chrome/browser/resources/new_new_tab.html16
-rw-r--r--chrome/browser/resources/ntp/apps.js4
4 files changed, 32 insertions, 3 deletions
diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc
index cad0727..64d128a 100644
--- a/chrome/browser/dom_ui/app_launcher_handler.cc
+++ b/chrome/browser/dom_ui/app_launcher_handler.cc
@@ -186,11 +186,22 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
dictionary->SetBoolean("disableAppWindowLaunch", true);
dictionary->SetBoolean("disableCreateAppShortcut", true);
#endif
+
#if defined(OS_CHROMEOS)
// Making shortcut does not make sense on ChromeOS because it does not have
// a desktop.
dictionary->SetBoolean("disableCreateAppShortcut", true);
#endif
+
+ // We always show the launcher on Chrome OS. On Desktop Chrome, only show it
+ // if we've installed our default apps.
+#if defined(OS_CHROMEOS)
+ dictionary->SetBoolean("showLauncher", true);
+#else
+ dictionary->SetBoolean(
+ "showLauncher",
+ extensions_service_->default_apps()->GetDefaultAppsInstalled());
+#endif
}
void AppLauncherHandler::HandleGetApps(const ListValue* args) {
diff --git a/chrome/browser/extensions/default_apps.h b/chrome/browser/extensions/default_apps.h
index a6e899e..b03f6ec 100644
--- a/chrome/browser/extensions/default_apps.h
+++ b/chrome/browser/extensions/default_apps.h
@@ -46,6 +46,9 @@ class DefaultApps {
// Gets the list of default apps.
const ExtensionIdSet* GetDefaultApps() const;
+ // Returns true if the default apps have been installed. False otherwise.
+ bool GetDefaultAppsInstalled() const;
+
// Should be called after each app is installed. Once installed_ids contains
// all the default apps, GetAppsToInstall() will start returning NULL.
void DidInstallApp(const ExtensionIdSet& installed_ids);
@@ -69,7 +72,6 @@ class DefaultApps {
FRIEND_TEST_ALL_PREFIXES(ExtensionDefaultApps,
ManualAppInstalledWhileInstallingDefaultApps);
- bool GetDefaultAppsInstalled() const;
void SetDefaultAppsInstalled(bool val);
int GetPromoCounter() const;
diff --git a/chrome/browser/resources/new_new_tab.html b/chrome/browser/resources/new_new_tab.html
index 3d50ca0..f987bde 100644
--- a/chrome/browser/resources/new_new_tab.html
+++ b/chrome/browser/resources/new_new_tab.html
@@ -151,7 +151,7 @@ if ('mode' in hashParams) {
<div class="maxiview" id="most-visited-maxiview"></div>
<div class="sections">
- <!-- Start disabled. We only enable if we have at least one app. -->
+ <!-- Start disabled. We only enable once we have installed default apps. -->
<div id="apps" class="section disabled" section="APPS">
<h2>
<img class="disclosure" img src="ntp/ntp_disclosure_triangle.png">
@@ -319,6 +319,20 @@ i18nTemplate.process(document, templateData);
setSectionVisible(
'recently-closed', undefined,
recentlyClosedInitiallyVisible, MINIMIZED_RECENT);
+
+ // This is insane, but we use the CSS class 'disabled' for both 'minimized'
+ // sections and sections that are actually disabled, as in not accessible in
+ // any way.
+ //
+ // The above code syncs up the DOM and shownSection wrt minimized. But we
+ // don't know until we receive the apps data whether the apps section will be
+ // disabled or not. So we need to add the 'disabled' class back to the apps
+ // section here. We remove it later, once we know for sure we want it to be
+ // enabled.
+ //
+ // See also: crbug.com/67273.
+ $('apps').classList.add('disabled');
+
layoutSections();
</script>
</html>
diff --git a/chrome/browser/resources/ntp/apps.js b/chrome/browser/resources/ntp/apps.js
index eef4fa2..32b8a4a 100644
--- a/chrome/browser/resources/ntp/apps.js
+++ b/chrome/browser/resources/ntp/apps.js
@@ -66,7 +66,9 @@ function getAppsCallback(data) {
apps.createWebStoreClosedMenuElement());
}
- if (!(shownSections & MINIMIZED_APPS)) {
+ if (!data.showLauncher || (shownSections & MINIMIZED_APPS)) {
+ appsSection.classList.add('disabled');
+ } else {
appsSection.classList.remove('disabled');
}
addClosedMenuFooter(apps.menu, 'apps', MINIMIZED_APPS, Section.APPS);