Skip to content

Commit

Permalink
Refactoring installer shortcut deletion; adding dedicated shortcut up…
Browse files Browse the repository at this point in the history
…date feature.

In ShellUtil, there were 3 shortcut removal routines. Changes:

RemoveShortcut() => Renamed to RemoveShortcuts(), also ridding |shortcut_name| parameter (removed 1 caller that was redundant to start with).
RemoveTaskbarShortcuts() => Absorbed by RemoveShortcut()
RemoveStartScreenShortcuts() => Absorbed by RemoveShortcut()

We want to also add an "update" feature to enable batch shortcut udpate, e.g., change all shortcuts that point to app_host.exe to point to chrome.exe instead, with the proper icon changes.

To unify both operations, we create a BatchShortcutAction() that takes callbacks to perform specific operations (removal / update). ShellUtil::GetShortcutPath() is also refactored to accept more locations. The added routine in ShellUtil is:

UpdateShortcuts()

BUG=234876
R=gab@chromium.org, grt@chromium.org, sky@chromium.org

Review URL: https://codereview.chromium.org/14287008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198514 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
gab@chromium.org committed May 6, 2013
1 parent ef855c2 commit 4a1925c
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 201 deletions.
5 changes: 2 additions & 3 deletions chrome/browser/chrome_browser_main_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ int DoUninstallTasks(bool chrome_still_running) {
};
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
for (size_t i = 0; i < arraysize(user_shortcut_locations); ++i) {
if (!ShellUtil::RemoveShortcut(user_shortcut_locations[i], dist,
chrome_exe, ShellUtil::CURRENT_USER,
NULL)) {
if (!ShellUtil::RemoveShortcuts(user_shortcut_locations[i], dist,
ShellUtil::CURRENT_USER, chrome_exe)) {
VLOG(1) << "Failed to delete shortcut at location "
<< user_shortcut_locations[i];
}
Expand Down
6 changes: 3 additions & 3 deletions chrome/installer/setup/install.cc
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ void CleanupLegacyShortcuts(const InstallerState& installer_state,
file_util::Delete(uninstall_shortcut_path, false);

if (installer_state.system_install()) {
ShellUtil::RemoveShortcut(
ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist, chrome_exe,
ShellUtil::SYSTEM_LEVEL, NULL);
ShellUtil::RemoveShortcuts(
ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist,
ShellUtil::SYSTEM_LEVEL, chrome_exe);
}
}

Expand Down
46 changes: 20 additions & 26 deletions chrome/installer/setup/uninstall.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,41 +339,35 @@ void DeleteShortcuts(const InstallerState& installer_state,
ShellUtil::ShellChange install_level = installer_state.system_install() ?
ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER;

VLOG(1) << "Deleting Desktop shortcut.";
if (!ShellUtil::RemoveShortcut(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist,
target_exe, install_level, NULL)) {
LOG(WARNING) << "Failed to delete Desktop shortcut.";
}
// Also try to delete the alternate desktop shortcut. It is not sufficient
// to do so upon failure of the above call as ERROR_FILE_NOT_FOUND on
// delete is considered success.
if (!ShellUtil::RemoveShortcut(
ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, target_exe, install_level,
&dist->GetAlternateApplicationName())) {
LOG(WARNING) << "Failed to delete alternate Desktop shortcut.";
VLOG(1) << "Deleting Desktop shortcuts.";
if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist,
install_level, target_exe)) {
LOG(WARNING) << "Failed to delete Desktop shortcuts.";
}

VLOG(1) << "Deleting Quick Launch shortcut.";
if (!ShellUtil::RemoveShortcut(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH,
dist, target_exe, install_level, NULL)) {
LOG(WARNING) << "Failed to delete Quick Launch shortcut.";
VLOG(1) << "Deleting Quick Launch shortcuts.";
if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH,
dist, install_level, target_exe)) {
LOG(WARNING) << "Failed to delete Quick Launch shortcuts.";
}

VLOG(1) << "Deleting Start Menu shortcuts.";
if (!ShellUtil::RemoveShortcut(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist,
target_exe, install_level, NULL)) {
if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist,
install_level, target_exe)) {
LOG(WARNING) << "Failed to delete Start Menu shortcuts.";
}

// Although the shortcut removal calls above will unpin their shortcut if they
// result in a deletion (i.e. shortcut existed and pointed to |target_exe|),
// it is possible for shortcuts to remain pinned while their parent shortcut
// has been deleted or changed to point to another |target_exe|. Make sure all
// pinned-to-taskbar shortcuts that point to |target_exe| are unpinned.
ShellUtil::RemoveTaskbarShortcuts(target_exe.value());
// Unpin all pinned-to-taskbar shortcuts that point to |chrome_exe|.
if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS,
dist, ShellUtil::CURRENT_USER, target_exe)) {
LOG(WARNING) << "Failed to unpin taskbar shortcuts at user-level.";
}

ShellUtil::RemoveStartScreenShortcuts(product.distribution(),
target_exe.value());
// Delete the folder of secondary tiles from the start screen for |dist|.
if (!ShellUtil::RemoveShortcuts(ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS,
dist, install_level, target_exe)) {
LOG(WARNING) << "Failed to delete start-screen shortcuts.";
}
}

bool ScheduleParentAndGrandparentForDeletion(const base::FilePath& path) {
Expand Down
Loading

0 comments on commit 4a1925c

Please sign in to comment.