summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 23:55:24 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 23:55:24 +0000
commit5ccf810730474363696aec131bea549876ffe2cc (patch)
treefd59f1dfc7d6a8ec77eb3bcb28e29e50e79d8475 /chrome/installer
parent464d2bc5b79f809977a2707060f9540bba38b1d6 (diff)
downloadchromium_src-5ccf810730474363696aec131bea549876ffe2cc.zip
chromium_src-5ccf810730474363696aec131bea549876ffe2cc.tar.gz
chromium_src-5ccf810730474363696aec131bea549876ffe2cc.tar.bz2
Delete empty folders in system level install. Also cleanup uninstall error messages a little bit.
BUG=11553 TEST=Uninstall system level chrome and select "delete profile data", %LOCALAPPDATA%\Chromium folder should get deleted. Review URL: http://codereview.chromium.org/115945 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17265 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/setup/uninstall.cc40
1 files changed, 27 insertions, 13 deletions
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index ef04da4..f050a42 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -93,6 +93,27 @@ void DeleteChromeShortcuts(bool system_uninstall) {
}
}
+// Deletes empty parent & empty grandparent dir of given path.
+bool DeleteEmptyParentDir(const std::wstring& path) {
+ bool ret = true;
+ std::wstring parent_dir = file_util::GetDirectoryFromPath(path);
+ if (!parent_dir.empty() && file_util::IsDirectoryEmpty(parent_dir)) {
+ if (!file_util::Delete(parent_dir, true)) {
+ ret = false;
+ LOG(ERROR) << "Failed to delete folder: " << parent_dir;
+ }
+
+ parent_dir = file_util::GetDirectoryFromPath(parent_dir);
+ if (!parent_dir.empty() && file_util::IsDirectoryEmpty(parent_dir)) {
+ if (!file_util::Delete(parent_dir, true)) {
+ ret = false;
+ LOG(ERROR) << "Failed to delete folder: " << parent_dir;
+ }
+ }
+ }
+ return ret;
+}
+
// Deletes all installed files of Chromium and Folders. Before deleting it
// needs to move setup.exe in a temp folder because the current process
// is using that file. It returns false when it can not get the path to
@@ -142,21 +163,12 @@ bool DeleteFilesAndFolders(const std::wstring& exe_path, bool system_uninstall,
if (!file_util::Delete(user_local_state, true))
LOG(ERROR) << "Failed to delete user profle dir: "
<< user_local_state.value();
+ DeleteEmptyParentDir(user_local_state.value());
}
// Now check and delete if the parent directories are empty
// For example Google\Chrome or Chromium
- std::wstring parent_dir = file_util::GetDirectoryFromPath(install_path);
- if (!parent_dir.empty() && file_util::IsDirectoryEmpty(parent_dir)) {
- if (!file_util::Delete(parent_dir, true))
- LOG(ERROR) << "Failed to delete folder: " << parent_dir;
- parent_dir = file_util::GetDirectoryFromPath(parent_dir);
- if (!parent_dir.empty() &&
- file_util::IsDirectoryEmpty(parent_dir)) {
- if (!file_util::Delete(parent_dir, true))
- LOG(ERROR) << "Failed to delete folder: " << parent_dir;
- }
- }
+ DeleteEmptyParentDir(install_path);
return true;
}
@@ -165,7 +177,8 @@ bool DeleteFilesAndFolders(const std::wstring& exe_path, bool system_uninstall,
// otherwise false.
bool DeleteRegistryKey(RegKey& key, const std::wstring& key_path) {
LOG(INFO) << "Deleting registry key " << key_path;
- if (!key.DeleteKey(key_path.c_str())) {
+ if (!key.DeleteKey(key_path.c_str()) &&
+ ::GetLastError() != ERROR_MOD_NOT_FOUND) {
LOG(ERROR) << "Failed to delete registry key: " << key_path;
return false;
}
@@ -179,7 +192,8 @@ bool DeleteRegistryValue(HKEY reg_root, const std::wstring& key_path,
const std::wstring& value_name) {
RegKey key(reg_root, key_path.c_str(), KEY_ALL_ACCESS);
LOG(INFO) << "Deleting registry value " << value_name;
- if (!key.DeleteValue(value_name.c_str())) {
+ if (key.ValueExists(value_name.c_str()) &&
+ !key.DeleteValue(value_name.c_str())) {
LOG(ERROR) << "Failed to delete registry value: " << value_name;
return false;
}