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

Unified Diff: chrome/installer/util/shell_util.cc

Issue 22870004: On uninstall, delete shortcuts first, and then remove directory only if empty. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing comments. Created 7 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..36454478aded239e683fb1fe357521f159c50cbc 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 the directory is non-empty.
+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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698