Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8752)

Unified Diff: chrome/installer/setup/uninstall.cc

Issue 23581012: Restricting scope of ShellUtil's shortcut update feature for its specific usage in Chrome self-dest… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Using VLOG(ERROR) for one change. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/installer/util/shell_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/setup/uninstall.cc
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 8693dfa834d46f353876cf4909977a942142f695..0ba3187db181db0534288b4412a0fd215693ae85 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -328,52 +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.
-// 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) {
+// Updates shortcuts to |old_target_exe| that have non-empty args, making them
+// target |new_target_exe| instead. The non-empty args requirement is a
+// heuristic to determine whether a shortcut is "user-generated". This routine
+// can only be called for user-level installs.
+void RetargetUserShortcutsWithArgs(const InstallerState& installer_state,
+ const Product& product,
+ const base::FilePath& old_target_exe,
+ const base::FilePath& new_target_exe) {
+ if (installer_state.system_install()) {
+ NOTREACHED();
+ return;
+ }
BrowserDistribution* dist = product.distribution();
- DCHECK(!installer_state.system_install());
ShellUtil::ShellChange install_level = ShellUtil::CURRENT_USER;
ShellUtil::ShortcutProperties updated_properties(install_level);
updated_properties.set_target(new_target_exe);
+ // TODO(huangs): Make this data-driven, along with DeleteShortcuts().
VLOG(1) << "Retargeting Desktop shortcuts.";
- if (!ShellUtil::UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist,
- install_level, old_target_exe, require_args,
- updated_properties)) {
+ if (!ShellUtil::UpdateShortcutsWithArgs(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, install_level,
+ old_target_exe, 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)) {
+ if (!ShellUtil::UpdateShortcutsWithArgs(
+ ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist, install_level,
+ old_target_exe, 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)) {
+ if (!ShellUtil::UpdateShortcutsWithArgs(
+ ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, install_level,
+ old_target_exe, 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)) {
+ if (!ShellUtil::UpdateShortcutsWithArgs(
+ ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, dist,
+ ShellUtil::CURRENT_USER, old_target_exe, 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)) {
+ if (!ShellUtil::UpdateShortcutsWithArgs(
+ ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS, dist, install_level,
+ old_target_exe, updated_properties)) {
LOG(WARNING) << "Failed to retarget start-screen shortcuts.";
}
}
@@ -1186,8 +1190,9 @@ 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 user-level chrome is self-destructing as a result of encountering a
+ // system-level chrome, retarget owned non-default shortcuts (app shortcuts,
+ // profile shortcuts, etc.) to the system-level chrome.
if (cmd_line.HasSwitch(installer::switches::kSelfDestruct) &&
!installer_state.system_install()) {
const base::FilePath system_chrome_path(
@@ -1195,14 +1200,11 @@ InstallStatus UninstallProduct(const InstallationState& original_state,
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);
+ RetargetUserShortcutsWithArgs(installer_state, product,
+ base::FilePath(chrome_exe),
+ system_chrome_path);
} else {
- VLOG(1) << "Retarget failed: system-level Chrome not found.";
+ LOG(ERROR) << "Retarget failed: system-level Chrome not found.";
}
}
« no previous file with comments | « no previous file | chrome/installer/util/shell_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698