Commit ec11b009 authored by calamity@chromium.org's avatar calamity@chromium.org

Always show the NTP apps page

Previously the NTP apps page would not show if the app launcher was installed.
Now it will show regardless.

This patch also restores apps to chrome://apps when the app launcher is
installed.


BUG=225371

Review URL: https://chromiumcodereview.appspot.com/13926002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194768 0039d316-1c4b-4281-b951-d872f2087c98
parent 32290f62
...@@ -110,20 +110,10 @@ cr.define('ntp', function() { ...@@ -110,20 +110,10 @@ cr.define('ntp', function() {
} }
}; };
function gotShouldShowApps(shouldShowApps) {
if (shouldShowApps != loadTimeData.getBoolean('showApps')) {
// TODO(jeremya): update the UI in-place instead of reloading.
window.location.reload();
return;
}
}
/** /**
* Invoked at startup once the DOM is available to initialize the app. * Invoked at startup once the DOM is available to initialize the app.
*/ */
function onLoad() { function onLoad() {
// This will end up calling ntp.gotShouldShowApps.
chrome.send('getShouldShowApps');
sectionsToWaitFor = 0; sectionsToWaitFor = 0;
if (loadTimeData.getBoolean('showMostvisited')) if (loadTimeData.getBoolean('showMostvisited'))
sectionsToWaitFor++; sectionsToWaitFor++;
...@@ -691,7 +681,6 @@ cr.define('ntp', function() { ...@@ -691,7 +681,6 @@ cr.define('ntp', function() {
getAppsPageIndex: getAppsPageIndex, getAppsPageIndex: getAppsPageIndex,
getCardSlider: getCardSlider, getCardSlider: getCardSlider,
onLoad: onLoad, onLoad: onLoad,
gotShouldShowApps: gotShouldShowApps,
leaveRearrangeMode: leaveRearrangeMode, leaveRearrangeMode: leaveRearrangeMode,
logTimeToClick: logTimeToClick, logTimeToClick: logTimeToClick,
NtpFollowAction: NtpFollowAction, NtpFollowAction: NtpFollowAction,
......
...@@ -75,9 +75,6 @@ void NewTabPageHandler::RegisterMessages() { ...@@ -75,9 +75,6 @@ void NewTabPageHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("logTimeToClick", web_ui()->RegisterMessageCallback("logTimeToClick",
base::Bind(&NewTabPageHandler::HandleLogTimeToClick, base::Bind(&NewTabPageHandler::HandleLogTimeToClick,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback("getShouldShowApps",
base::Bind(&NewTabPageHandler::HandleGetShouldShowApps,
base::Unretained(this)));
} }
void NewTabPageHandler::HandleNotificationPromoClosed(const ListValue* args) { void NewTabPageHandler::HandleNotificationPromoClosed(const ListValue* args) {
...@@ -172,17 +169,6 @@ void NewTabPageHandler::HandleLogTimeToClick(const ListValue* args) { ...@@ -172,17 +169,6 @@ void NewTabPageHandler::HandleLogTimeToClick(const ListValue* args) {
} }
} }
void NewTabPageHandler::HandleGetShouldShowApps(const ListValue* args) {
apps::GetIsAppLauncherEnabled(
base::Bind(&NewTabPageHandler::GotIsAppLauncherEnabled,
AsWeakPtr()));
}
void NewTabPageHandler::GotIsAppLauncherEnabled(bool is_enabled) {
base::FundamentalValue should_show_apps(!is_enabled);
web_ui()->CallJavascriptFunction("ntp.gotShouldShowApps", should_show_apps);
}
// static // static
void NewTabPageHandler::RegisterUserPrefs(PrefRegistrySyncable* registry) { void NewTabPageHandler::RegisterUserPrefs(PrefRegistrySyncable* registry) {
// TODO(estade): should be syncable. // TODO(estade): should be syncable.
......
...@@ -57,12 +57,6 @@ class NewTabPageHandler : public content::WebUIMessageHandler, ...@@ -57,12 +57,6 @@ class NewTabPageHandler : public content::WebUIMessageHandler,
// Callback for "logTimeToClick". // Callback for "logTimeToClick".
void HandleLogTimeToClick(const base::ListValue* args); void HandleLogTimeToClick(const base::ListValue* args);
// Callback for the "getShouldShowApps" message.
void HandleGetShouldShowApps(const base::ListValue* args);
// Callback from extensions::UpdateIsAppLauncherEnabled().
void GotIsAppLauncherEnabled(bool is_enabled);
// Tracks the number of times the user has switches pages (for UMA). // Tracks the number of times the user has switches pages (for UMA).
size_t page_switch_count_; size_t page_switch_count_;
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <set> #include <set>
#include "apps/app_launcher.h"
#include "base/i18n/rtl.h" #include "base/i18n/rtl.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -52,6 +51,10 @@ ...@@ -52,6 +51,10 @@
#include "chrome/browser/ui/webui/theme_handler.h" #include "chrome/browser/ui/webui/theme_handler.h"
#endif #endif
#if defined(USE_ASH)
#include "chrome/browser/ui/host_desktop.h"
#endif
using content::BrowserThread; using content::BrowserThread;
using content::RenderViewHost; using content::RenderViewHost;
using content::WebUIController; using content::WebUIController;
...@@ -237,14 +240,14 @@ void NewTabUI::RegisterUserPrefs(PrefRegistrySyncable* registry) { ...@@ -237,14 +240,14 @@ void NewTabUI::RegisterUserPrefs(PrefRegistrySyncable* registry) {
// static // static
bool NewTabUI::ShouldShowApps() { bool NewTabUI::ShouldShowApps() {
// Ash shows apps in app list thus should not show apps page in NTP4.
// Android does not have apps.
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Ash shows apps in app list thus should not show apps page in NTP4.
// Android does not have apps.
return false; return false;
#elif defined(USE_ASH)
return chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH;
#else #else
// This needs to be synchronous, so we use the value the last time it return true;
// was checked.
return !apps::WasAppLauncherEnabled();
#endif #endif
} }
......
...@@ -214,7 +214,7 @@ bool NTPResourceCache::NewTabCacheNeedsRefresh() { ...@@ -214,7 +214,7 @@ bool NTPResourceCache::NewTabCacheNeedsRefresh() {
return true; return true;
} }
#endif #endif
bool should_show_apps_page = !apps::WasAppLauncherEnabled(); bool should_show_apps_page = NewTabUI::ShouldShowApps();
if (should_show_apps_page != should_show_apps_page_) { if (should_show_apps_page != should_show_apps_page_) {
should_show_apps_page_ = should_show_apps_page; should_show_apps_page_ = should_show_apps_page;
return true; return true;
......
...@@ -31,6 +31,9 @@ class NTPResourceCache : public content::NotificationObserver, ...@@ -31,6 +31,9 @@ class NTPResourceCache : public content::NotificationObserver,
base::RefCountedMemory* GetNewTabHTML(bool is_incognito); base::RefCountedMemory* GetNewTabHTML(bool is_incognito);
base::RefCountedMemory* GetNewTabCSS(bool is_incognito); base::RefCountedMemory* GetNewTabCSS(bool is_incognito);
void set_should_show_apps_page(bool should_show_apps_page) {
should_show_apps_page_ = should_show_apps_page;
}
void set_should_show_most_visited_page(bool should_show_most_visited_page) { void set_should_show_most_visited_page(bool should_show_most_visited_page) {
should_show_most_visited_page_ = should_show_most_visited_page; should_show_most_visited_page_ = should_show_most_visited_page;
} }
...@@ -81,7 +84,7 @@ class NTPResourceCache : public content::NotificationObserver, ...@@ -81,7 +84,7 @@ class NTPResourceCache : public content::NotificationObserver,
// Set based on platform_util::IsSwipeTrackingFromScrollEventsEnabled. // Set based on platform_util::IsSwipeTrackingFromScrollEventsEnabled.
bool is_swipe_tracking_from_scroll_events_enabled_; bool is_swipe_tracking_from_scroll_events_enabled_;
// Set based on extensions::IsAppLauncherEnabled. // Set based on NewTabUI::ShouldShowApps.
bool should_show_apps_page_; bool should_show_apps_page_;
// The next three all default to true and can be manually set, e.g., by the // The next three all default to true and can be manually set, e.g., by the
// chrome://apps page. // chrome://apps page.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment