Chromium Code Reviews| Index: chrome/installer/setup/install.cc |
| diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc |
| index b8ebe94fd372897dac60815ae6fae078910fd018..9296e711e6113b58ef43af1c8cf50fc6b8cd7c07 100644 |
| --- a/chrome/installer/setup/install.cc |
| +++ b/chrome/installer/setup/install.cc |
| @@ -29,6 +29,7 @@ |
| #include "chrome/installer/setup/setup_constants.h" |
| #include "chrome/installer/util/auto_launch_util.h" |
| #include "chrome/installer/util/browser_distribution.h" |
| +#include "chrome/installer/util/chrome_app_host_distribution.h" |
| #include "chrome/installer/util/create_reg_key_work_item.h" |
| #include "chrome/installer/util/delete_after_reboot_helper.h" |
| #include "chrome/installer/util/google_update_constants.h" |
| @@ -247,9 +248,9 @@ installer::InstallStatus InstallNewVersion( |
| // Launch shortcut. Both of these were created prior to Chrome 24; in Chrome 24, |
| // the uninstall shortcut was removed and the Default user Quick Launch shortcut |
| // was replaced by per-user shortcuts created via Active Setup. |
| -void CleanupLegacyShortcuts(const InstallerState& installer_state, |
| - BrowserDistribution* dist, |
| - const base::FilePath& chrome_exe) { |
| +void CleanupLegacyChromeShortcuts(const InstallerState& installer_state, |
| + BrowserDistribution* dist, |
| + const base::FilePath& chrome_exe) { |
| ShellUtil::ShellChange shortcut_level = installer_state.system_install() ? |
| ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; |
| base::FilePath uninstall_shortcut_path; |
| @@ -274,6 +275,11 @@ installer::InstallShortcutOperation GetAppLauncherShortcutOperation( |
| const installer::ProductState* original_app_host_state = |
| original_state.GetProductState(installer_state.system_install(), |
| BrowserDistribution::CHROME_APP_HOST); |
| + if (installer_state.need_to_migrate_legacy_app_launcher() || |
| + installer_state.create_app_launcher_shortcuts()) { |
| + return installer::INSTALL_SHORTCUT_CREATE_ALL; |
| + } |
| + |
| bool app_launcher_exists = original_app_host_state && |
| original_app_host_state->uninstall_command() |
| .HasSwitch(installer::switches::kChromeAppLauncher); |
| @@ -283,6 +289,60 @@ installer::InstallShortcutOperation GetAppLauncherShortcutOperation( |
| return installer::INSTALL_SHORTCUT_REPLACE_EXISTING; |
| } |
| +// As of M29, App Launcher is unified with Chrome. app_host.exe is deleted, and |
| +// all shortcuts that target app_host.exe must now target chrome.exe. |
| +// Shortcuts to the App Launcher also require icons update. |
| +void MigrateLegacyAppLauncherShortcuts(const InstallerState& installer_state) { |
| + LegacyChromeAppHostDistribution legacy_dist; |
| + BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( |
| + BrowserDistribution::CHROME_APP_HOST); |
| + base::FilePath app_host_exe( |
| + installer_state.target_path().Append(installer::kChromeAppHostExe)); |
| + base::FilePath chrome_exe( |
| + installer_state.target_path().Append(installer::kChromeExe)); |
| + |
| + // Remove deprecated start menu folder "Google Chrome App Launcher". |
| + ShellUtil::RemoveShortcuts( |
| + ShellUtil::SHORTCUT_LOCATION_START_MENU, &legacy_dist, |
| + ShellUtil::CURRENT_USER, app_host_exe); |
| + |
| + VLOG(1) << "Migrating legacy App Launcher shortcuts."; |
| + ShellUtil::ShortcutLocation update_location_list[] = { |
| + ShellUtil::SHORTCUT_LOCATION_DESKTOP, |
| + ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, |
| + ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, |
| + ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS |
| + }; |
| + |
| + // Using wild card in case duplicate shortcuts exist. |
| + string16 name_filter_main(dist->GetAppShortCutName() + L"*" + |
| + installer::kLnkExt); |
| + |
| + ShellUtil::ShortcutProperties updated_properties_app_host_exe( |
| + installer_state.system_install() ? ShellUtil::SYSTEM_LEVEL : |
| + ShellUtil::CURRENT_USER); |
| + updated_properties_app_host_exe.set_target(chrome_exe); |
| + updated_properties_app_host_exe.set_icon( |
| + installer_state.target_path().Append(dist->GetIconFilename()), |
| + dist->GetIconIndex()); |
| + |
| + ShellUtil::ShortcutProperties updated_properties_user_generated( |
| + installer_state.system_install() ? ShellUtil::SYSTEM_LEVEL : |
| + ShellUtil::CURRENT_USER); |
| + updated_properties_user_generated.set_target(chrome_exe); |
| + |
| + for (int i = 0; i < arraysize(update_location_list); ++i) { |
| + // Migrate App Launcher shortcuts (executable and icon changes). |
| + ShellUtil::UpdateShortcutsFilteredByName( |
| + update_location_list[i], dist, ShellUtil::CURRENT_USER, |
| + name_filter_main, app_host_exe, updated_properties_app_host_exe); |
| + // Migrate user-generated shortcuts (executable changes only). |
| + ShellUtil::UpdateShortcuts( |
| + update_location_list[i], dist, ShellUtil::CURRENT_USER, |
| + app_host_exe, updated_properties_user_generated); |
| + } |
| +} |
| + |
| } // end namespace |
| namespace installer { |
| @@ -532,20 +592,24 @@ InstallStatus InstallOrUpdateProduct( |
| installer_state.UpdateStage(installer::CREATING_SHORTCUTS); |
| + InstallShortcutLevel install_level = installer_state.system_install() ? |
| + ALL_USERS : CURRENT_USER; |
| + const base::FilePath chrome_exe( |
| + installer_state.target_path().Append(kChromeExe)); |
| + |
| const Product* app_launcher_product = |
| installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST); |
| // Creates shortcuts for App Launcher. |
| if (app_launcher_product) { |
| - // TODO(huangs): Remove this check once we have system-level App Host. |
| - DCHECK(!installer_state.system_install()); |
| - const base::FilePath app_host_exe( |
| - installer_state.target_path().Append(kChromeAppHostExe)); |
| - InstallShortcutOperation app_launcher_shortcut_operation = |
| - GetAppLauncherShortcutOperation(original_state, installer_state); |
| - |
| - // Always install per-user shortcuts for App Launcher. |
| - CreateOrUpdateShortcuts(app_host_exe, *app_launcher_product, prefs, |
| - CURRENT_USER, app_launcher_shortcut_operation); |
| + if (installer_state.need_to_migrate_legacy_app_launcher()) { |
| + MigrateLegacyAppLauncherShortcuts(installer_state); |
|
huangs
2013/06/04 13:50:31
Do this only for user-level installs and updates,
|
| + } |
| + if (installer_state.create_app_launcher_shortcuts()) { |
| + InstallShortcutOperation app_launcher_shortcut_operation = |
| + GetAppLauncherShortcutOperation(original_state, installer_state); |
| + CreateOrUpdateShortcuts(chrome_exe, *app_launcher_product, prefs, |
| + CURRENT_USER, app_launcher_shortcut_operation); |
| + } |
| } |
| const Product* chrome_product = |
| @@ -553,18 +617,13 @@ InstallStatus InstallOrUpdateProduct( |
| // Creates shortcuts for Chrome. |
| if (chrome_product) { |
| BrowserDistribution* chrome_dist = chrome_product->distribution(); |
| - const base::FilePath chrome_exe( |
| - installer_state.target_path().Append(kChromeExe)); |
| - CleanupLegacyShortcuts(installer_state, chrome_dist, chrome_exe); |
| + CleanupLegacyChromeShortcuts(installer_state, chrome_dist, chrome_exe); |
| // Install per-user shortcuts on user-level installs and all-users |
| // shortcuts on system-level installs. Note that Active Setup will take |
| // care of installing missing per-user shortcuts on system-level install |
| // (i.e., quick launch, taskbar pin, and possibly deleted all-users |
| // shortcuts). |
| - InstallShortcutLevel install_level = installer_state.system_install() ? |
| - ALL_USERS : CURRENT_USER; |
| - |
| InstallShortcutOperation install_operation = |
| INSTALL_SHORTCUT_REPLACE_EXISTING; |
| if (result == installer::FIRST_INSTALL_SUCCESS || |
| @@ -685,11 +744,11 @@ void HandleActiveSetupForBrowser(const base::FilePath& installation_root, |
| } |
| bool InstallFromWebstore(const std::string& app_code) { |
| - base::FilePath app_host_path(chrome_launcher_support::GetAnyAppHostPath()); |
| - if (app_host_path.empty()) |
| + base::FilePath chrome_path(chrome_launcher_support::GetAnyChromePath()); |
| + if (chrome_path.empty()) |
| return false; |
| - CommandLine cmd(app_host_path); |
| + CommandLine cmd(chrome_path); |
| cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); |
| VLOG(1) << "App install command: " << cmd.GetCommandLineString(); |
| return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); |