Skip to content

Commit

Permalink
Remove --show-app-list-shortcut flag and implement new app launcher e…
Browse files Browse the repository at this point in the history
…nable logic.

The app launcher now adds itself to the start menu on the first run of chrome
past this patch.

The webstore enable of the app launcher will create shortcuts on the desktop
and pin an icon to the taskbar.

The app launcher should never be disabled after it is enabled.

BUG=233434
TBR=benwells@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195158 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
calamity@chromium.org committed Apr 19, 2013
1 parent 1ce9bfe commit d7a322e
Show file tree
Hide file tree
Showing 14 changed files with 182 additions and 259 deletions.
56 changes: 8 additions & 48 deletions apps/app_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand All @@ -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
5 changes: 5 additions & 0 deletions apps/app_launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions apps/apps.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
'shortcut_manager.h',
'shortcut_manager_factory.cc',
'shortcut_manager_factory.h',
'switches.cc',
'switches.h',
],
'conditions': [
['enable_extensions==0',
Expand Down
14 changes: 10 additions & 4 deletions apps/pref_names.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";

Expand Down
5 changes: 3 additions & 2 deletions apps/pref_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions apps/prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 0 additions & 14 deletions apps/switches.cc

This file was deleted.

18 changes: 0 additions & 18 deletions apps/switches.h

This file was deleted.

8 changes: 0 additions & 8 deletions chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <set>
#include <utility>

#include "apps/switches.h"
#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "base/prefs/pref_service.h"
Expand Down Expand Up @@ -1195,13 +1194,6 @@ const Experiment kExperiments[] = {
kOsDesktop,
SINGLE_VALUE_TYPE(switches::kDisableNativeAutofillUi)
},
{
"show-app-list-shortcut",
IDS_FLAGS_SHOW_APP_LIST_SHORTCUT_NAME,
IDS_FLAGS_SHOW_APP_LIST_SHORTCUT_DESCRIPTION,
kOsWin,
SINGLE_VALUE_TYPE(apps::switches::kShowAppListShortcut)
},
{
"enable-experimental-form-filling",
IDS_FLAGS_ENABLE_EXPERIMENTAL_FORM_FILLING_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h"

#include "apps/app_launcher.h"
#include "apps/switches.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
Expand Down Expand Up @@ -127,18 +126,9 @@ WebstoreInstaller::Delegate* test_webstore_installer_delegate = NULL;

void EnableAppLauncher(base::Callback<void(bool)> callback) {
#if defined(OS_WIN)
if (BrowserDistribution::GetDistribution()->AppHostIsSupported()) {
LOG(INFO) << "Enabling App Launcher via installation";
extensions::AppHostInstaller::SetInstallWithLauncher(true);
extensions::AppHostInstaller::EnsureAppHostInstalled(callback);
} else {
LOG(INFO) << "Enabling App Launcher via flags";
about_flags::SetExperimentEnabled(g_browser_process->local_state(),
apps::switches::kShowAppListShortcut,
true);
AppListService::Get()->EnableAppList();
callback.Run(true);
}
LOG(INFO) << "Enabling App Launcher via internal enable";
AppListService::Get()->EnableAppList();
callback.Run(true);
#else
callback.Run(true);
#endif
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/shell_integration.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class ShellIntegration {

bool on_desktop;
bool in_applications_menu;
string16 applications_menu_subdir;

// For Windows, this refers to quick launch bar prior to Win7. In Win7,
// this means "pin to taskbar". For Mac/Linux, this could be used for
Expand Down
Loading

0 comments on commit d7a322e

Please sign in to comment.