Commit e921690b authored by nick@chromium.org's avatar nick@chromium.org

Revert 217130 "On uninstall, delete shortcuts first, and then re..."

[Reason for revert: compile failure on Win Aura (maybe due to merge conflict)]

> On uninstall, delete shortcuts first, and then remove directory only if empty.
> 
> Previously, ShellUtil::RemoveShortcuts() simply wipes out the entire directory if |location| is SHORTCUT_LOCATION_START_MENU or SHORTCUT_LOCATION_APP_SHORTCUTS, for efficiency. But we're now writing code to migrate shortcuts on the self-destruct flow. In this case, wiping out the directory would destroy our results. Therefore the new logic for deletion of these directories are:
> - Use same code to remove Chrome-specific shortcuts (this is what's done for other diretories, e.g., Start Menu).
> - If the directory becomes empty, then remove it; otherwise do nothing.
> 
> The side effect is that if user creates any non-Chrome shortcuts in these directories, then these shortcuts (and the containing directory) will persist after Chrome uninstall. I think this is a pretty normal behavior.
> 
> BUG=235857
> 
> Review URL: https://chromiumcodereview.appspot.com/22870004

TBR=huangs@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217134 0039d316-1c4b-4281-b951-d872f2087c98
parent ebccd7ec
...@@ -1289,12 +1289,10 @@ bool BatchShortcutAction(const ShortcutFilterCallback& shortcut_filter, ...@@ -1289,12 +1289,10 @@ bool BatchShortcutAction(const ShortcutFilterCallback& shortcut_filter,
return success; return success;
} }
// If the folder specified by {|location|, |dist|, |level|} is empty, remove it. // Removes folder spsecified by {|location|, |dist|, |level|}.
// Otherwise do nothing. Returns true on success, including the vacuous case bool RemoveShortcutFolder(ShellUtil::ShortcutLocation location,
// where no deletion occurred because the directory is non-empty. BrowserDistribution* dist,
bool RemoveShortcutFolderIfEmpty(ShellUtil::ShortcutLocation location, ShellUtil::ShellChange level) {
BrowserDistribution* dist,
ShellUtil::ShellChange level) {
// Explicitly whitelist locations, since accidental calls can be very harmful. // Explicitly whitelist locations, since accidental calls can be very harmful.
if (location != ShellUtil::SHORTCUT_LOCATION_START_MENU && if (location != ShellUtil::SHORTCUT_LOCATION_START_MENU &&
...@@ -1308,8 +1306,7 @@ bool RemoveShortcutFolderIfEmpty(ShellUtil::ShortcutLocation location, ...@@ -1308,8 +1306,7 @@ bool RemoveShortcutFolderIfEmpty(ShellUtil::ShortcutLocation location,
LOG(WARNING) << "Cannot find path at location " << location; LOG(WARNING) << "Cannot find path at location " << location;
return false; return false;
} }
if (file_util::IsDirectoryEmpty(shortcut_folder) && if (!base::DeleteFile(shortcut_folder, true)) {
!base::DeleteFile(shortcut_folder, true)) {
LOG(ERROR) << "Cannot remove folder " << shortcut_folder.value(); LOG(ERROR) << "Cannot remove folder " << shortcut_folder.value();
return false; return false;
} }
...@@ -2032,13 +2029,8 @@ bool ShellUtil::RemoveShortcuts(ShellUtil::ShortcutLocation location, ...@@ -2032,13 +2029,8 @@ bool ShellUtil::RemoveShortcuts(ShellUtil::ShortcutLocation location,
switch (location) { switch (location) {
case SHORTCUT_LOCATION_START_MENU: // Falls through. case SHORTCUT_LOCATION_START_MENU: // Falls through.
case SHORTCUT_LOCATION_APP_SHORTCUTS: { case SHORTCUT_LOCATION_APP_SHORTCUTS:
bool delete_success = return RemoveShortcutFolder(location, dist, level);
BatchShortcutAction(base::Bind(&ShortcutOpDelete), location,
dist, level, target_exe);
bool rmdir_success = RemoveShortcutFolderIfEmpty(location, dist, level);
return delete_success && rmdir_success;
}
case SHORTCUT_LOCATION_TASKBAR_PINS: case SHORTCUT_LOCATION_TASKBAR_PINS:
return BatchShortcutAction(FilterTargetEq(target_exe). return BatchShortcutAction(FilterTargetEq(target_exe).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment