summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-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
6 files changed, 155 insertions, 171 deletions
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