summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 13:18:36 +0000
committercalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 13:18:36 +0000
commitd7a322e473480a23090a6f864f9b0d79e8a7702a (patch)
treefd0f8ca937096991487d0cbbaaba141beace003c
parent1ce9bfec9248026c844218c5e340a608af884ad9 (diff)
downloadchromium_src-d7a322e473480a23090a6f864f9b0d79e8a7702a.zip
chromium_src-d7a322e473480a23090a6f864f9b0d79e8a7702a.tar.gz
chromium_src-d7a322e473480a23090a6f864f9b0d79e8a7702a.tar.bz2
Remove --show-app-list-shortcut flag and implement new app launcher enable 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
-rw-r--r--apps/app_launcher.cc56
-rw-r--r--apps/app_launcher.h5
-rw-r--r--apps/apps.gypi2
-rw-r--r--apps/pref_names.cc14
-rw-r--r--apps/pref_names.h5
-rw-r--r--apps/prefs.cc1
-rw-r--r--apps/switches.cc14
-rw-r--r--apps/switches.h18
-rw-r--r--chrome/browser/about_flags.cc8
-rw-r--r--chrome/browser/extensions/api/webstore_private/webstore_private_api.cc16
-rw-r--r--chrome/browser/shell_integration.h1
-rw-r--r--chrome/browser/ui/views/app_list/app_list_controller_win.cc190
-rw-r--r--chrome/browser/web_applications/web_app.h3
-rw-r--r--chrome/browser/web_applications/web_app_win.cc108
14 files changed, 182 insertions, 259 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_
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index cbd734f..840b56b 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -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"
@@ -1196,13 +1195,6 @@ const Experiment kExperiments[] = {
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,
IDS_FLAGS_ENABLE_EXPERIMENTAL_FORM_FILLING_DESCRIPTION,
diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
index 6665b01..e9474c8 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
@@ -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"
@@ -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
diff --git a/chrome/browser/shell_integration.h b/chrome/browser/shell_integration.h
index 25232f7..1306027 100644
--- a/chrome/browser/shell_integration.h
+++ b/chrome/browser/shell_integration.h
@@ -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
diff --git a/chrome/browser/ui/views/app_list/app_list_controller_win.cc b/chrome/browser/ui/views/app_list/app_list_controller_win.cc
index 8ccb9e0..4c6561a 100644
--- a/chrome/browser/ui/views/app_list/app_list_controller_win.cc
+++ b/chrome/browser/ui/views/app_list/app_list_controller_win.cc
@@ -4,7 +4,7 @@
#include <sstream>
-#include "apps/switches.h"
+#include "apps/pref_names.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/lazy_instance.h"
@@ -35,6 +35,7 @@
#include "chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/views/browser_dialogs.h"
+#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
@@ -130,6 +131,74 @@ void SetDidRunForNDayActiveStats() {
}
}
+// The start menu shortcut is created on first run by users that are
+// upgrading. The desktop and taskbar shortcuts are created the first time the
+// user enables the app list. The taskbar shortcut is created in
+// |user_data_dir| and will use a Windows Application Model Id of
+// |app_model_id|. This runs on the FILE thread and not in the blocking IO
+// thread pool as there are other tasks running (also on the FILE thread)
+// which fiddle with shortcut icons
+// (ShellIntegration::MigrateWin7ShortcutsOnPath). Having different threads
+// fiddle with the same shortcuts could cause race issues.
+void CreateAppListShortcuts(
+ const base::FilePath& user_data_dir,
+ const string16& app_model_id,
+ const ShellIntegration::ShortcutLocations& creation_locations) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
+
+ // Shortcut paths under which to create shortcuts.
+ std::vector<base::FilePath> shortcut_paths =
+ web_app::internals::GetShortcutPaths(creation_locations);
+
+ bool pin_to_taskbar = creation_locations.in_quick_launch_bar &&
+ (base::win::GetVersion() >= base::win::VERSION_WIN7);
+
+ // Create a shortcut in the |user_data_dir| for taskbar pinning.
+ if (pin_to_taskbar)
+ shortcut_paths.push_back(user_data_dir);
+ bool success = true;
+
+ base::FilePath chrome_exe;
+ if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
+ NOTREACHED();
+ return;
+ }
+
+ string16 wide_switches(GetAppListCommandLine().GetArgumentsString());
+
+ base::win::ShortcutProperties shortcut_properties;
+ shortcut_properties.set_target(chrome_exe);
+ shortcut_properties.set_working_dir(chrome_exe.DirName());
+ shortcut_properties.set_arguments(wide_switches);
+ shortcut_properties.set_description(
+ l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME));
+ shortcut_properties.set_icon(chrome_exe, kAppListIconIndex);
+ shortcut_properties.set_app_id(app_model_id);
+
+ const string16 file_name =
+ l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME);
+
+ for (size_t i = 0; i < shortcut_paths.size(); ++i) {
+ base::FilePath shortcut_file = shortcut_paths[i].Append(file_name).
+ AddExtension(installer::kLnkExt);
+ if (!file_util::PathExists(shortcut_file.DirName()) &&
+ !file_util::CreateDirectory(shortcut_file.DirName())) {
+ NOTREACHED();
+ return;
+ }
+ success = success && base::win::CreateOrUpdateShortcutLink(
+ shortcut_file, shortcut_properties,
+ base::win::SHORTCUT_CREATE_ALWAYS);
+ }
+
+ if (success && pin_to_taskbar) {
+ base::FilePath shortcut_to_pin = user_data_dir.Append(file_name).
+ AddExtension(installer::kLnkExt);
+ success = base::win::TaskbarPinShortcutLink(
+ shortcut_to_pin.value().c_str()) && success;
+ }
+}
+
class AppListControllerDelegateWin : public AppListControllerDelegate {
public:
AppListControllerDelegateWin();
@@ -839,78 +908,6 @@ void AppListController::FreeAnyKeepAliveForView() {
keep_alive_.reset(NULL);
}
-base::FilePath GetAppListTaskbarShortcutPath(
- const base::FilePath& user_data_dir) {
- const string16 shortcut_name = l10n_util::GetStringUTF16(
- IDS_APP_LIST_SHORTCUT_NAME);
- return user_data_dir.Append(shortcut_name).AddExtension(installer::kLnkExt);
-}
-
-void CreateAppListTaskbarShortcutOnFileThread(
- const base::FilePath& user_data_dir,
- const string16& app_model_id) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
-
- base::FilePath chrome_exe;
- if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
- NOTREACHED();
- return;
- }
-
- base::win::ShortcutProperties shortcut_properties;
- shortcut_properties.set_target(chrome_exe);
- shortcut_properties.set_working_dir(chrome_exe.DirName());
-
- string16 wide_switches(GetAppListCommandLine().GetArgumentsString());
- shortcut_properties.set_arguments(wide_switches);
- shortcut_properties.set_description(l10n_util::GetStringUTF16(
- IDS_APP_LIST_SHORTCUT_NAME));
-
- shortcut_properties.set_icon(chrome_exe, kAppListIconIndex);
- shortcut_properties.set_app_id(app_model_id);
-
- const base::FilePath shortcut_path(
- GetAppListTaskbarShortcutPath(user_data_dir));
- base::win::CreateOrUpdateShortcutLink(shortcut_path, shortcut_properties,
- base::win::SHORTCUT_CREATE_ALWAYS);
-
- if (!base::win::TaskbarPinShortcutLink(shortcut_path.value().c_str()))
- LOG(WARNING) << "Failed to pin AppList using " << shortcut_path.value();
-}
-
-// Check that a taskbar shortcut exists if it should, or does not exist if
-// it should not. A taskbar shortcut should exist if the switch
-// kShowAppListShortcut is set. The shortcut will be created or deleted in
-// |user_data_dir| and will use a Windows Application Model Id of
-// |app_model_id|.
-// This runs on the FILE thread and not in the blocking IO thread pool as there
-// are other tasks running (also on the FILE thread) which fiddle with shortcut
-// icons (ShellIntegration::MigrateWin7ShortcutsOnPath). Having different
-// threads fiddle with the same shortcuts could cause race issues.
-void CheckAppListTaskbarShortcutOnFileThread(
- const base::FilePath& user_data_dir,
- const string16& app_model_id) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
-
- const base::FilePath shortcut_path(
- GetAppListTaskbarShortcutPath(user_data_dir));
- const bool should_show =
- CommandLine::ForCurrentProcess()->HasSwitch(
- apps::switches::kShowAppListShortcut);
-
- // This will not reshow a shortcut if it has been unpinned manually by the
- // user, as that will not delete the shortcut file.
- if (should_show && !file_util::PathExists(shortcut_path)) {
- CreateAppListTaskbarShortcutOnFileThread(user_data_dir, app_model_id);
- return;
- }
-
- if (!should_show && file_util::PathExists(shortcut_path)) {
- base::win::TaskbarUnpinShortcutLink(shortcut_path.value().c_str());
- file_util::Delete(shortcut_path, false);
- }
-}
-
void InitView(Profile* profile) {
if (!g_browser_process || g_browser_process->IsShuttingDown())
return;
@@ -931,22 +928,6 @@ void AppListController::Init(Profile* initial_profile) {
ShowAppListDuringModeSwitch(initial_profile);
}
- // Check that the app list shortcut matches the flag kShowAppListShortcut.
- // This will either create or delete a shortcut file in the user data
- // directory.
- // TODO(benwells): Remove this and the flag once the app list installation
- // is implemented.
- static bool checked_shortcut = false;
- if (!checked_shortcut) {
- checked_shortcut = true;
- base::FilePath user_data_dir(
- g_browser_process->profile_manager()->user_data_dir());
- content::BrowserThread::PostTask(
- content::BrowserThread::FILE, FROM_HERE,
- base::Bind(&CheckAppListTaskbarShortcutOnFileThread, user_data_dir,
- GetAppModelId()));
- }
-
// Instantiate AppListController so it listens for profile deletions.
AppListController::GetInstance();
@@ -968,12 +949,31 @@ bool AppListController::IsAppListVisible() const {
}
void AppListController::EnableAppList() {
- base::FilePath user_data_dir(
- g_browser_process->profile_manager()->user_data_dir());
- content::BrowserThread::PostTask(
- content::BrowserThread::FILE, FROM_HERE,
- base::Bind(&CreateAppListTaskbarShortcutOnFileThread, user_data_dir,
- GetAppModelId()));
+ // Check if the app launcher shortcuts have ever been created before.
+ // Shortcuts should only be created once. If the user unpins the taskbar
+ // shortcut, they can restore it by pinning the start menu or desktop
+ // shortcut.
+ PrefService* local_state = g_browser_process->local_state();
+ bool has_been_enabled = local_state->GetBoolean(
+ apps::prefs::kAppLauncherHasBeenEnabled);
+ if (!has_been_enabled) {
+ local_state->SetBoolean(apps::prefs::kAppLauncherHasBeenEnabled,
+ true);
+ ShellIntegration::ShortcutLocations shortcut_locations;
+ shortcut_locations.on_desktop = true;
+ shortcut_locations.in_quick_launch_bar = true;
+ shortcut_locations.in_applications_menu = true;
+ shortcut_locations.applications_menu_subdir =
+ l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
+ base::FilePath user_data_dir(
+ g_browser_process->profile_manager()->user_data_dir());
+
+ content::BrowserThread::PostTask(
+ content::BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&CreateAppListShortcuts,
+ user_data_dir, GetAppModelId(), shortcut_locations));
+ }
}
} // namespace
diff --git a/chrome/browser/web_applications/web_app.h b/chrome/browser/web_applications/web_app.h
index 4e5f288..af86986 100644
--- a/chrome/browser/web_applications/web_app.h
+++ b/chrome/browser/web_applications/web_app.h
@@ -96,6 +96,9 @@ namespace internals {
#if defined(OS_WIN)
bool CheckAndSaveIcon(const base::FilePath& icon_file,
const gfx::ImageFamily& image);
+
+std::vector<base::FilePath> GetShortcutPaths(
+ const ShellIntegration::ShortcutLocations& creation_locations);
#endif
// Implemented for each platform, does the platform specific parts of creating
diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc
index 92ef88e..d7bac7f 100644
--- a/chrome/browser/web_applications/web_app_win.cc
+++ b/chrome/browser/web_applications/web_app_win.cc
@@ -18,6 +18,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/launcher_support/chrome_launcher_support.h"
#include "chrome/installer/util/browser_distribution.h"
+#include "chrome/installer/util/util_constants.h"
#include "content/public/browser/browser_thread.h"
#include "ui/gfx/icon_util.h"
#include "ui/gfx/image/image.h"
@@ -80,59 +81,6 @@ bool ShouldUpdateIcon(const base::FilePath& icon_file, const SkBitmap& image) {
sizeof(base::MD5Digest)) != 0;
}
-std::vector<base::FilePath> GetShortcutPaths(
- const ShellIntegration::ShortcutLocations& creation_locations) {
- // Shortcut paths under which to create shortcuts.
- std::vector<base::FilePath> shortcut_paths;
-
- // Locations to add to shortcut_paths.
- struct {
- bool use_this_location;
- int location_id;
- const wchar_t* sub_dir;
- } locations[] = {
- {
- creation_locations.on_desktop,
- base::DIR_USER_DESKTOP,
- NULL
- }, {
- creation_locations.in_applications_menu,
- base::DIR_START_MENU,
- NULL
- }, {
- creation_locations.in_quick_launch_bar,
- // For Win7, create_in_quick_launch_bar means pinning to taskbar. Use
- // base::PATH_START as a flag for this case.
- (base::win::GetVersion() >= base::win::VERSION_WIN7) ?
- base::PATH_START : base::DIR_APP_DATA,
- (base::win::GetVersion() >= base::win::VERSION_WIN7) ?
- NULL : L"Microsoft\\Internet Explorer\\Quick Launch"
- }
- };
-
- // Populate shortcut_paths.
- for (int i = 0; i < arraysize(locations); ++i) {
- if (locations[i].use_this_location) {
- base::FilePath path;
-
- // Skip the Win7 case.
- if (locations[i].location_id == base::PATH_START)
- continue;
-
- if (!PathService::Get(locations[i].location_id, &path)) {
- continue;
- }
-
- if (locations[i].sub_dir != NULL)
- path = path.Append(locations[i].sub_dir);
-
- shortcut_paths.push_back(path);
- }
- }
-
- return shortcut_paths;
-}
-
bool ShortcutIsForProfile(const base::FilePath& shortcut_file_name,
const base::FilePath& profile_path) {
string16 cmd_line_string;
@@ -281,7 +229,7 @@ bool CreatePlatformShortcuts(
bool success = true;
for (size_t i = 0; i < shortcut_paths.size(); ++i) {
base::FilePath shortcut_file = shortcut_paths[i].Append(file_name).
- AddExtension(FILE_PATH_LITERAL(".lnk"));
+ AddExtension(installer::kLnkExt);
if (shortcut_paths[i] != web_app_path) {
int unique_number =
file_util::GetUniquePathNumber(shortcut_file, FILE_PATH_LITERAL(""));
@@ -310,7 +258,7 @@ bool CreatePlatformShortcuts(
// Use the web app path shortcut for pinning to avoid having unique numbers
// in the application name.
base::FilePath shortcut_to_pin = web_app_path.Append(file_name).
- AddExtension(FILE_PATH_LITERAL(".lnk"));
+ AddExtension(installer::kLnkExt);
success = base::win::TaskbarPinShortcutLink(
shortcut_to_pin.value().c_str()) && success;
}
@@ -364,6 +312,56 @@ void DeletePlatformShortcuts(
}
}
+std::vector<base::FilePath> GetShortcutPaths(
+ const ShellIntegration::ShortcutLocations& creation_locations) {
+ // Shortcut paths under which to create shortcuts.
+ std::vector<base::FilePath> shortcut_paths;
+ // Locations to add to shortcut_paths.
+ struct {
+ bool use_this_location;
+ int location_id;
+ const wchar_t* subdir;
+ } locations[] = {
+ {
+ creation_locations.on_desktop,
+ base::DIR_USER_DESKTOP,
+ NULL
+ }, {
+ creation_locations.in_applications_menu,
+ base::DIR_START_MENU,
+ creation_locations.applications_menu_subdir.empty() ? NULL :
+ creation_locations.applications_menu_subdir.c_str()
+ }, {
+ creation_locations.in_quick_launch_bar,
+ // For Win7, in_quick_launch_bar means pinning to taskbar. Use
+ // base::PATH_START as a flag for this case.
+ (base::win::GetVersion() >= base::win::VERSION_WIN7) ?
+ base::PATH_START : base::DIR_APP_DATA,
+ (base::win::GetVersion() >= base::win::VERSION_WIN7) ?
+ NULL : L"Microsoft\\Internet Explorer\\Quick Launch"
+ }
+ };
+ // Populate shortcut_paths.
+ for (int i = 0; i < arraysize(locations); ++i) {
+ if (locations[i].use_this_location) {
+ base::FilePath path;
+
+ // Skip the Win7 case.
+ if (locations[i].location_id == base::PATH_START)
+ continue;
+
+ if (!PathService::Get(locations[i].location_id, &path)) {
+ continue;
+ }
+
+ if (locations[i].subdir != NULL)
+ path = path.Append(locations[i].subdir);
+ shortcut_paths.push_back(path);
+ }
+ }
+ return shortcut_paths;
+}
+
} // namespace internals
} // namespace web_app