Chromium Code Reviews| Index: chrome/installer/setup/uninstall.cc |
| diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc |
| index 7f8e7cebb35ffd0f6f41dd0b02dee13556d2fe3d..8693dfa834d46f353876cf4909977a942142f695 100644 |
| --- a/chrome/installer/setup/uninstall.cc |
| +++ b/chrome/installer/setup/uninstall.cc |
| @@ -328,6 +328,56 @@ void CloseChromeFrameHelperProcess() { |
| } |
| } |
| +// Updates shortcuts to |old_target_exe| to target |new_target_exe| instead. If |
| +// |require_args| is set, then only updates shortcuts with non-empty targets. |
|
gab
2013/09/09 13:00:31
s/non-empty targets/non-empty arguments
?
huangs
2013/09/11 19:02:52
Ah, good catch. Done.
|
| +// This should only be called from user-level. |
| +void RetargetShortcuts(const InstallerState& installer_state, |
| + const Product& product, |
| + const base::FilePath& old_target_exe, |
| + const base::FilePath& new_target_exe, |
| + bool require_args) { |
| + BrowserDistribution* dist = product.distribution(); |
| + DCHECK(!installer_state.system_install()); |
|
gab
2013/09/09 13:00:31
Move DCHECK to top: checking the method's contract
huangs
2013/09/11 19:02:52
Done (should get rid of "!").
|
| + ShellUtil::ShellChange install_level = ShellUtil::CURRENT_USER; |
| + ShellUtil::ShortcutProperties updated_properties(install_level); |
| + updated_properties.set_target(new_target_exe); |
| + |
| + VLOG(1) << "Retargeting Desktop shortcuts."; |
| + if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, |
|
gab
2013/09/09 13:00:31
Please put these in a for loop through all locatio
huangs
2013/09/11 19:02:52
DeleteShortcuts() message string also distinguish
gab
2013/09/11 20:23:06
Ah ok, sgtm :)!
|
| + install_level, old_target_exe, require_args, |
| + updated_properties)) { |
| + LOG(WARNING) << "Failed to retarget Desktop shortcuts."; |
| + } |
| + |
| + VLOG(1) << "Retargeting Quick Launch shortcuts."; |
| + if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, |
| + dist, install_level, old_target_exe, |
| + require_args, updated_properties)) { |
| + LOG(WARNING) << "Failed to retarget Quick Launch shortcuts."; |
| + } |
| + |
| + VLOG(1) << "Retargeting Start Menu shortcuts."; |
| + if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, |
| + install_level, old_target_exe, require_args, |
| + updated_properties)) { |
| + LOG(WARNING) << "Failed to retarget Start Menu shortcuts."; |
| + } |
| + |
| + // Retarget pinned-to-taskbar shortcuts that point to |chrome_exe|. |
| + if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, |
| + dist, ShellUtil::CURRENT_USER, old_target_exe, |
| + require_args, updated_properties)) { |
| + LOG(WARNING) << "Failed to retarget taskbar shortcuts at user-level."; |
| + } |
| + |
| + // Retarget the folder of secondary tiles from the start screen for |dist|. |
| + if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS, |
| + dist, install_level, old_target_exe, |
| + require_args, updated_properties)) { |
| + LOG(WARNING) << "Failed to retarget start-screen shortcuts."; |
| + } |
| +} |
| + |
| // Deletes shortcuts at |install_level| from Start menu, Desktop, |
| // Quick Launch, taskbar, and secondary tiles on the Start Screen (Win8+). |
| // Only shortcuts pointing to |target_exe| will be removed. |
| @@ -1136,6 +1186,26 @@ InstallStatus UninstallProduct(const InstallationState& original_state, |
| auto_launch_util::DisableAllAutoStartFeatures( |
| ASCIIToUTF16(chrome::kInitialProfile)); |
| + // Self-destruct flow: removing user-level Chrome because system-level |
| + // Chrome exists. |
| + if (cmd_line.HasSwitch(installer::switches::kSelfDestruct) && |
| + !installer_state.system_install()) { |
| + const base::FilePath system_chrome_path( |
| + GetChromeInstallPath(true, browser_dist). |
| + Append(installer::kChromeExe)); |
| + VLOG(1) << "Retargeting user-generated Chrome shortcuts."; |
| + if (base::PathExists(system_chrome_path)) { |
| + // Retarget all user-generated shortcuts to user-level chrome.exe to |
| + // system-level chrome.exe. Heuristic: consider only shortcuts that have |
| + // non-empty args. Therefore the main user-level chrome.exe will not get |
| + // retarged, and will get deleted by DeleteShortcuts() below. |
| + RetargetShortcuts(installer_state, product, base::FilePath(chrome_exe), |
| + system_chrome_path, true); |
| + } else { |
| + VLOG(1) << "Retarget failed: system-level Chrome not found."; |
| + } |
| + } |
| + |
| DeleteShortcuts(installer_state, product, base::FilePath(chrome_exe)); |
| } else if (product.is_chrome_app_host()) { |