Chromium Code Reviews| Index: chrome/browser/shell_integration_win.cc |
| diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc |
| index 5dd80834c0ab7b81ce673f99f255d24c920ac2c2..b52c9dae14e5230f4b7dc3c1399d58600c747f60 100644 |
| --- a/chrome/browser/shell_integration_win.cc |
| +++ b/chrome/browser/shell_integration_win.cc |
| @@ -26,6 +26,7 @@ |
| #include "chrome/common/chrome_constants.h" |
| #include "chrome/common/chrome_paths_internal.h" |
| #include "chrome/common/chrome_switches.h" |
| +#include "chrome/installer/launcher_support/chrome_launcher_support.h" |
| #include "chrome/installer/setup/setup_util.h" |
| #include "chrome/installer/util/browser_distribution.h" |
| #include "chrome/installer/util/create_reg_key_work_item.h" |
| @@ -93,8 +94,17 @@ string16 GetExpectedAppId(const CommandLine& command_line, |
| base::FilePath profile_path; |
| if (command_line.HasSwitch(switches::kUserDataDir)) { |
|
koz (OOO until 15th September)
2013/04/18 02:06:08
I think this reads better if you use some intermed
calamity
2013/04/18 08:24:34
Done.
|
| profile_path = |
| - command_line.GetSwitchValuePath(switches::kUserDataDir).AppendASCII( |
| - chrome::kInitialProfile); |
| + command_line.GetSwitchValuePath(switches::kUserDataDir); |
| + } else { |
| + chrome::GetDefaultUserDataDirectory(&profile_path); |
| + } |
| + |
| + if (command_line.HasSwitch(switches::kProfileDirectory)) { |
| + profile_path = profile_path.Append( |
| + command_line.GetSwitchValuePath(switches::kProfileDirectory)); |
| + } else { |
| + profile_path = profile_path.AppendASCII( |
| + chrome::kInitialProfile); |
| } |
| string16 app_name; |
| @@ -123,12 +133,22 @@ void MigrateChromiumShortcutsCallback() { |
| if (!PathService::Get(base::FILE_EXE, &chrome_exe)) |
| return; |
| + // Get the app_host.exe path. |
| + bool is_per_user_install = |
| + InstallUtil::IsPerUserInstall(chrome_exe.value().c_str()); |
| + base::FilePath app_host_exe = GetAppHostPathForInstallationLevel( |
| + is_per_user_install ? chrome_launcher_support::USER_LEVEL_INSTALLATION |
| + : chrome_launcher_support::SYSTEM_LEVEL_INSTALLATION); |
| + |
| // Locations to check for shortcuts migration. |
| static const struct { |
| int location_id; |
| const wchar_t* sub_dir; |
| } kLocations[] = { |
| { |
| + base::DIR_IMPLICIT_APP_SHORTCUTS, |
| + NULL |
| + }, { |
| base::DIR_TASKBAR_PINS, |
| NULL |
| }, { |
| @@ -154,8 +174,13 @@ void MigrateChromiumShortcutsCallback() { |
| path = path.Append(kLocations[i].sub_dir); |
| bool check_dual_mode = (kLocations[i].location_id == base::DIR_START_MENU); |
| - ShellIntegration::MigrateShortcutsInPathInternal(chrome_exe, path, |
| - check_dual_mode); |
| + bool recursive = |
| + (kLocations[i].location_id == base::DIR_IMPLICIT_APP_SHORTCUTS); |
| + ShellIntegration::MigrateShortcutsInPathInternal(chrome_exe, |
| + app_host_exe, |
| + path, |
| + check_dual_mode, |
| + recursive); |
| } |
| } |
| @@ -376,14 +401,17 @@ void ShellIntegration::MigrateChromiumShortcuts() { |
| int ShellIntegration::MigrateShortcutsInPathInternal( |
| const base::FilePath& chrome_exe, |
| + const base::FilePath& app_host_exe, |
| const base::FilePath& path, |
| - bool check_dual_mode) { |
| + bool check_dual_mode, |
| + bool recursive) { |
| DCHECK(base::win::GetVersion() >= base::win::VERSION_WIN7); |
| + |
| // Enumerate all pinned shortcuts in the given path directly. |
| file_util::FileEnumerator shortcuts_enum( |
| - path, false, // not recursive |
| - file_util::FileEnumerator::FILES, FILE_PATH_LITERAL("*.lnk")); |
| + path, recursive, |
| + file_util::FileEnumerator::FILES); |
| bool is_per_user_install = |
| InstallUtil::IsPerUserInstall(chrome_exe.value().c_str()); |
| @@ -396,8 +424,9 @@ int ShellIntegration::MigrateShortcutsInPathInternal( |
| shortcut = shortcuts_enum.Next()) { |
| // TODO(gab): Use ProgramCompare instead of comparing FilePaths below once |
| // it is fixed to work with FilePaths with spaces. |
| - if (!base::win::ResolveShortcut(shortcut, &target_path, &arguments) || |
| - chrome_exe != target_path) { |
| + if (shortcut.Extension() != installer::kLnkExt || |
| + !base::win::ResolveShortcut(shortcut, &target_path, &arguments) || |
| + (chrome_exe != target_path && app_host_exe != target_path)) { |
| continue; |
| } |
| CommandLine command_line(CommandLine::FromString(base::StringPrintf( |
| @@ -424,6 +453,11 @@ int ShellIntegration::MigrateShortcutsInPathInternal( |
| // |updated_properties|. |
| base::win::ShortcutProperties updated_properties; |
| + // Migrate app_host.exe shortcuts to chrome.exe |
| + if (target_path == app_host_exe) { |
| + updated_properties.set_target(chrome_exe); |
| + } |
| + |
| // Validate the existing app id for the shortcut. |
| base::win::ScopedComPtr<IPropertyStore> property_store; |
| propvariant.Reset(); |