summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authorrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-12 23:31:35 +0000
committerrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-12 23:31:35 +0000
commit85f9d0bc7f09e87a72deb4722466023cc777ee27 (patch)
tree41d4eede299bcdc8660934baa955d41c8b724709 /chrome/installer
parent6ebfda42437a3ac3d27949a948f9d643bbcc146f (diff)
downloadchromium_src-85f9d0bc7f09e87a72deb4722466023cc777ee27.zip
chromium_src-85f9d0bc7f09e87a72deb4722466023cc777ee27.tar.gz
chromium_src-85f9d0bc7f09e87a72deb4722466023cc777ee27.tar.bz2
Correctly schedule empty parent directories for deletion when Chrome Frame is uninstalled while in use.
BUG=27483,23999 TEST=Uninstall Chrome Frame while it is in use. Verify that all Chrome Frame folders are removed. Review URL: http://codereview.chromium.org/392013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31853 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/setup/uninstall.cc36
-rw-r--r--chrome/installer/util/delete_after_reboot_helper.cc3
-rw-r--r--chrome/installer/util/delete_after_reboot_helper.h5
3 files changed, 38 insertions, 6 deletions
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 0b9c326..16c07c1 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -117,6 +117,23 @@ void DeleteChromeShortcuts(bool system_uninstall) {
}
}
+bool ScheduleParentAndGrandparentForDeletion(const FilePath& path) {
+ FilePath parent_dir = path.DirName();
+ bool ret = ScheduleFileSystemEntityForDeletion(parent_dir.value().c_str());
+ if (!ret) {
+ LOG(ERROR) << "Failed to schedule parent dir for deletion: "
+ << parent_dir.value();
+ } else {
+ FilePath grandparent_dir(parent_dir.DirName());
+ ret = ScheduleFileSystemEntityForDeletion(grandparent_dir.value().c_str());
+ if (!ret) {
+ LOG(ERROR) << "Failed to schedule grandparent dir for deletion: "
+ << grandparent_dir.value();
+ }
+ }
+ return ret;
+}
+
// Deletes empty parent & empty grandparent dir of given path.
bool DeleteEmptyParentDir(const std::wstring& path) {
bool ret = true;
@@ -233,12 +250,23 @@ DeleteResult DeleteFilesAndFolders(const std::wstring& exe_path,
result = DELETE_FAILED;
}
}
- DeleteEmptyParentDir(user_local_state.value());
+ if (result == DELETE_REQUIRES_REBOOT) {
+ ScheduleParentAndGrandparentForDeletion(user_local_state);
+ } else {
+ DeleteEmptyParentDir(user_local_state.value());
+ }
}
- // Now check and delete if the parent directories are empty
- // For example Google\Chrome or Chromium
- DeleteEmptyParentDir(install_path);
+ if (result == DELETE_REQUIRES_REBOOT) {
+ // If we need a reboot to continue, schedule the parent directories for
+ // deletion unconditionally. If they are not empty, the session manager
+ // will not delete them on reboot.
+ ScheduleParentAndGrandparentForDeletion(FilePath(install_path));
+ } else {
+ // Now check and delete if the parent directories are empty
+ // For example Google\Chrome or Chromium
+ DeleteEmptyParentDir(install_path);
+ }
return result;
}
diff --git a/chrome/installer/util/delete_after_reboot_helper.cc b/chrome/installer/util/delete_after_reboot_helper.cc
index 1bc322c..6806f78 100644
--- a/chrome/installer/util/delete_after_reboot_helper.cc
+++ b/chrome/installer/util/delete_after_reboot_helper.cc
@@ -54,6 +54,8 @@ bool IsSafeDirectoryNameForDeletion(const wchar_t* dir_name) {
return ok;
}
+} // end namespace
+
// Must only be called for regular files or directories that will be empty.
bool ScheduleFileSystemEntityForDeletion(const wchar_t* path) {
// Check if the file exists, return false if not.
@@ -77,7 +79,6 @@ bool ScheduleFileSystemEntityForDeletion(const wchar_t* path) {
LOG(INFO) << "Scheduled for deletion: " << path;
return true;
}
-} // end namespace
bool ScheduleDirectoryForDeletion(const wchar_t* dir_name) {
if (!IsSafeDirectoryNameForDeletion(dir_name)) {
diff --git a/chrome/installer/util/delete_after_reboot_helper.h b/chrome/installer/util/delete_after_reboot_helper.h
index 064a634..a022fb5 100644
--- a/chrome/installer/util/delete_after_reboot_helper.h
+++ b/chrome/installer/util/delete_after_reboot_helper.h
@@ -19,7 +19,10 @@ extern const wchar_t kPendingFileRenameOps[];
typedef std::pair<std::wstring, std::wstring> PendingMove;
-// Attempts to schedule the directory for deletion.
+// Attempts to schedule only the item at path for deletion.
+bool ScheduleFileSystemEntityForDeletion(const wchar_t* path);
+
+// Attempts to recursively schedule the directory for deletion.
bool ScheduleDirectoryForDeletion(const wchar_t* dir_name);
// Removes all pending moves that are registered for |directory| and all