diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_launcher.cc | 56 | ||||
-rw-r--r-- | apps/app_launcher.h | 5 | ||||
-rw-r--r-- | apps/apps.gypi | 2 | ||||
-rw-r--r-- | apps/pref_names.cc | 14 | ||||
-rw-r--r-- | apps/pref_names.h | 5 | ||||
-rw-r--r-- | apps/prefs.cc | 1 | ||||
-rw-r--r-- | apps/switches.cc | 14 | ||||
-rw-r--r-- | apps/switches.h | 18 |
8 files changed, 27 insertions, 88 deletions
diff --git a/apps/app_launcher.cc b/apps/app_launcher.cc index b5c5fe9..77a75fc 100644 --- a/apps/app_launcher.cc +++ b/apps/app_launcher.cc @@ -5,7 +5,6 @@ #include "apps/app_launcher.h" #include "apps/pref_names.h" -#include "apps/switches.h" #include "base/command_line.h" #include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_service.h" @@ -35,40 +34,18 @@ AppLauncherState SynchronousAppLauncherChecks() { #elif !defined(OS_WIN) return APP_LAUNCHER_DISABLED; #else - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kShowAppListShortcut)) { - return APP_LAUNCHER_ENABLED; - } - #if defined(USE_ASH) if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) return APP_LAUNCHER_ENABLED; #endif - - if (!BrowserDistribution::GetDistribution()->AppHostIsSupported()) - return APP_LAUNCHER_DISABLED; - - return APP_LAUNCHER_UNKNOWN; -#endif -} - -#if defined(OS_WIN) -void UpdatePrefAndCallCallbackOnUI( - bool result, - const OnAppLauncherEnabledCompleted& completion_callback) { PrefService* prefs = g_browser_process->local_state(); - prefs->SetBoolean(prefs::kAppLauncherIsEnabled, result); - completion_callback.Run(result); -} - -void IsAppLauncherInstalledOnBlockingPool( - const OnAppLauncherEnabledCompleted& completion_callback) { - DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); - bool result = chrome_launcher_support::IsAppLauncherPresent(); - content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, - base::Bind(UpdatePrefAndCallCallbackOnUI, result, completion_callback)); -} + // In some tests, the prefs aren't initialised. + if (!prefs) + return APP_LAUNCHER_UNKNOWN; + return prefs->GetBoolean(prefs::kAppLauncherHasBeenEnabled) ? + APP_LAUNCHER_ENABLED : APP_LAUNCHER_DISABLED; #endif +} } // namespace @@ -83,31 +60,14 @@ void GetIsAppLauncherEnabled( AppLauncherState state = SynchronousAppLauncherChecks(); if (state != APP_LAUNCHER_UNKNOWN) { - bool is_enabled = state == APP_LAUNCHER_ENABLED; - PrefService* prefs = g_browser_process->local_state(); - prefs->SetBoolean(prefs::kAppLauncherIsEnabled, is_enabled); - completion_callback.Run(is_enabled); + completion_callback.Run(state == APP_LAUNCHER_ENABLED); return; } - -#if defined(OS_WIN) - content::BrowserThread::PostBlockingPoolTask( - FROM_HERE, - base::Bind(&IsAppLauncherInstalledOnBlockingPool, - completion_callback)); -#else - // SynchronousAppLauncherChecks() never returns APP_LAUNCHER_UNKNOWN on - // !defined(OS_WIN), so this path is never reached. NOTREACHED(); -#endif } bool WasAppLauncherEnabled() { - PrefService* prefs = g_browser_process->local_state(); - // In some tests, the prefs aren't initialised. - if (!prefs) - return SynchronousAppLauncherChecks() == APP_LAUNCHER_ENABLED; - return prefs->GetBoolean(prefs::kAppLauncherIsEnabled); + return SynchronousAppLauncherChecks() == APP_LAUNCHER_ENABLED; } } // namespace apps diff --git a/apps/app_launcher.h b/apps/app_launcher.h index d3156a1..0ccc1bf 100644 --- a/apps/app_launcher.h +++ b/apps/app_launcher.h @@ -13,6 +13,11 @@ namespace apps { // boolean flag is passed, which is true if the app launcher is enabled. typedef base::Callback<void(bool)> OnAppLauncherEnabledCompleted; +// TODO(calamity): Remove all the "uncertain" apis because windows app launcher +// enabled is now just a single pref that we can check synchronously and with +// confidence. This includes changing GetIsAppLauncherEnabled to a synchronous +// API. + // A synchronous check to determine if the app launcher is enabled. If the // registry needs to be determined to find an accurate answer, this function // will NOT do so; instead if will default to false (the app launcher is not diff --git a/apps/apps.gypi b/apps/apps.gypi index 61f42e9..5553a51 100644 --- a/apps/apps.gypi +++ b/apps/apps.gypi @@ -44,8 +44,6 @@ 'shortcut_manager.h', 'shortcut_manager_factory.cc', 'shortcut_manager_factory.h', - 'switches.cc', - 'switches.h', ], 'conditions': [ ['enable_extensions==0', diff --git a/apps/pref_names.cc b/apps/pref_names.cc index cb1cf93..b4d3176 100644 --- a/apps/pref_names.cc +++ b/apps/pref_names.cc @@ -8,10 +8,6 @@ namespace apps { namespace prefs { -// Local state caching knowledge of whether the app launcher is installed. -const char kAppLauncherIsEnabled[] = - "apps.app_launcher.should_show_apps_page"; - // If set, the user requested to launch the app with this extension id while // in Metro mode, and then relaunched to Desktop mode to start it. const char kAppLaunchForMetroRestart[] = "apps.app_launch_for_metro_restart"; @@ -21,6 +17,16 @@ const char kAppLaunchForMetroRestart[] = "apps.app_launch_for_metro_restart"; const char kAppLaunchForMetroRestartProfile[] = "apps.app_launch_for_metro_restart_profile"; +// A boolean that tracks whether the user has ever enabled the app launcher. +const char kAppLauncherHasBeenEnabled[] = + "apps.app_launcher.has_been_enabled"; + +// TODO(calamity): remove this pref since app launcher will always be +// installed. +// Local state caching knowledge of whether the app launcher is installed. +const char kAppLauncherIsEnabled[] = + "apps.app_launcher.should_show_apps_page"; + // A boolean identifying if we should show the app launcher promo or not. const char kShowAppLauncherPromo[] = "app_launcher.show_promo"; diff --git a/apps/pref_names.h b/apps/pref_names.h index db5d7c2..27eedb4 100644 --- a/apps/pref_names.h +++ b/apps/pref_names.h @@ -10,9 +10,10 @@ namespace prefs { // Alphabetical list of preference names specific to Apps component. // Keep alphabetized and document each one in the source file. -extern const char kAppLauncherIsEnabled[]; -extern const char kAppLaunchForMetroRestart[]; extern const char kAppLaunchForMetroRestartProfile[]; +extern const char kAppLaunchForMetroRestart[]; +extern const char kAppLauncherHasBeenEnabled[]; +extern const char kAppLauncherIsEnabled[]; extern const char kShowAppLauncherPromo[]; } // namespace prefs diff --git a/apps/prefs.cc b/apps/prefs.cc index 2685860..ce6588b 100644 --- a/apps/prefs.cc +++ b/apps/prefs.cc @@ -23,6 +23,7 @@ void RegisterPrefs(PrefRegistrySimple* registry) { #if defined(OS_WIN) registry->RegisterStringPref(prefs::kAppLaunchForMetroRestart, ""); registry->RegisterStringPref(prefs::kAppLaunchForMetroRestartProfile, ""); + registry->RegisterBooleanPref(prefs::kAppLauncherHasBeenEnabled, false); #endif // Identifies whether we should show the app launcher promo or not. diff --git a/apps/switches.cc b/apps/switches.cc deleted file mode 100644 index f5051c9..0000000 --- a/apps/switches.cc +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "apps/switches.h" - -namespace apps { -namespace switches { - -// If true an app list shortcut will be shown in the taskbar. -const char kShowAppListShortcut[] = "show-app-list-shortcut"; - -} // namespace switches -} // namespace apps diff --git a/apps/switches.h b/apps/switches.h deleted file mode 100644 index 6f7671f..0000000 --- a/apps/switches.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef APPS_SWITCHES_H_ -#define APPS_SWITCHES_H_ - -namespace apps { -namespace switches { - -// Alphabetical list of switches specific to Apps component. -// Keep alphabetized and document each one in the source file. -extern const char kShowAppListShortcut[]; - -} // namespace switches -} // namespace apps - -#endif // APPS_SWITCHES_H_ |