diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 23:31:35 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 23:31:35 +0000 |
commit | 85f9d0bc7f09e87a72deb4722466023cc777ee27 (patch) | |
tree | 41d4eede299bcdc8660934baa955d41c8b724709 /chrome/installer/setup/uninstall.cc | |
parent | 6ebfda42437a3ac3d27949a948f9d643bbcc146f (diff) | |
download | chromium_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/setup/uninstall.cc')
-rw-r--r-- | chrome/installer/setup/uninstall.cc | 36 |
1 files changed, 32 insertions, 4 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; } |