Chromium Code Reviews| Index: chrome/installer/util/shell_util.cc |
| diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc |
| index 36f0f77dbecf9c1f70c27f0fa3af4d563d2770a2..d8a7bcff56e9906769625723648ee37139ac61f7 100644 |
| --- a/chrome/installer/util/shell_util.cc |
| +++ b/chrome/installer/util/shell_util.cc |
| @@ -1252,10 +1252,12 @@ bool BatchShortcutAction(const FileOperationCallback& shortcut_operation, |
| return success; |
| } |
| -// Removes folder spsecified by {|location|, |dist|, |level|}. |
| -bool RemoveShortcutFolder(ShellUtil::ShortcutLocation location, |
| - BrowserDistribution* dist, |
| - ShellUtil::ShellChange level) { |
| +// If the folder specified by {|location|, |dist|, |level|} is empty, remove it. |
| +// Otherwise do nothing. Returns true on success, including the vacuous case |
| +// where no deletion occurred because directory is non-empty. |
|
gab
2013/08/12 20:09:36
nit: s/because directory/because the directory
huangs
2013/08/12 20:27:16
Done.
|
| +bool RemoveShortcutFolderIfEmpty(ShellUtil::ShortcutLocation location, |
| + BrowserDistribution* dist, |
| + ShellUtil::ShellChange level) { |
| // Explicitly whitelist locations, since accidental calls can be very harmful. |
| if (location != ShellUtil::SHORTCUT_LOCATION_START_MENU && |
| @@ -1269,7 +1271,8 @@ bool RemoveShortcutFolder(ShellUtil::ShortcutLocation location, |
| LOG(WARNING) << "Cannot find path at location " << location; |
| return false; |
| } |
| - if (!base::DeleteFile(shortcut_folder, true)) { |
| + if (file_util::IsDirectoryEmpty(shortcut_folder) && |
| + !base::DeleteFile(shortcut_folder, true)) { |
| LOG(ERROR) << "Cannot remove folder " << shortcut_folder.value(); |
| return false; |
| } |
| @@ -1992,8 +1995,13 @@ bool ShellUtil::RemoveShortcuts(ShellUtil::ShortcutLocation location, |
| switch (location) { |
| case SHORTCUT_LOCATION_START_MENU: // Falls through. |
| - case SHORTCUT_LOCATION_APP_SHORTCUTS: |
| - return RemoveShortcutFolder(location, dist, level); |
| + case SHORTCUT_LOCATION_APP_SHORTCUTS: { |
| + bool delete_success = |
| + 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: |
| return BatchShortcutAction(base::Bind(&ShortcutOpUnpin), location, dist, |