summaryrefslogtreecommitdiffstats
path: root/chrome/installer/setup
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-08 17:15:52 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-08 17:15:52 +0000
commit4b636fa73856bc6b58abc850e1d1095d6592581d (patch)
tree9f8c482963ef8bd41814c1e054804e3536ea2c95 /chrome/installer/setup
parentfa08c45a2b823aff04a34f720aff876288e0c9dd (diff)
downloadchromium_src-4b636fa73856bc6b58abc850e1d1095d6592581d.zip
chromium_src-4b636fa73856bc6b58abc850e1d1095d6592581d.tar.gz
chromium_src-4b636fa73856bc6b58abc850e1d1095d6592581d.tar.bz2
Fix some problems with machine level install.
BUG=2380 Review URL: http://codereview.chromium.org/6402 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3015 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/setup')
-rw-r--r--chrome/installer/setup/install.cc4
-rw-r--r--chrome/installer/setup/main.cc2
-rw-r--r--chrome/installer/setup/setup.cc5
-rw-r--r--chrome/installer/setup/uninstall.cc66
4 files changed, 55 insertions, 22 deletions
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index 4f41e04..5d65dbf 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -50,6 +50,10 @@ void AddUninstallShortcutWorkItems(HKEY reg_root,
file_util::GetFilenameFromPath(exe_path));
uninstall_cmd.append(L"\" --");
uninstall_cmd.append(installer_util::switches::kUninstall);
+ if (reg_root == HKEY_LOCAL_MACHINE) {
+ uninstall_cmd.append(L" --");
+ uninstall_cmd.append(installer_util::switches::kSystemInstall);
+ }
// Create DisplayName, UninstallString and InstallLocation keys
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
diff --git a/chrome/installer/setup/main.cc b/chrome/installer/setup/main.cc
index 54e66b8..9714f68 100644
--- a/chrome/installer/setup/main.cc
+++ b/chrome/installer/setup/main.cc
@@ -272,7 +272,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
dist->UpdateDiffInstallStatus(system_install, incremental_install,
- install_status);
+ install_status);
return install_status;
}
diff --git a/chrome/installer/setup/setup.cc b/chrome/installer/setup/setup.cc
index 2ac4dfa..e3edf19 100644
--- a/chrome/installer/setup/setup.cc
+++ b/chrome/installer/setup/setup.cc
@@ -130,6 +130,11 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path,
file_util::GetFilenameFromPath(exe_path));
std::wstring arguments(L" --");
arguments.append(installer_util::switches::kUninstall);
+ if (system_install) {
+ arguments.append(L" --");
+ arguments.append(installer_util::switches::kSystemInstall);
+ }
+
LOG(INFO) << "Creating/updating uninstall link at " << uninstall_link;
std::wstring target_folder = file_util::GetDirectoryFromPath(install_path);
ret2 = file_util::CreateShortcutLink(setup_exe.c_str(),
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index f4cb697..4988e54 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -57,6 +57,49 @@ void DeleteChromeShortcut(bool system_uninstall) {
}
}
+// 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
+// installation folder, in all other cases it returns true even in case
+// of error (only logs the error).
+bool DeleteFilesAndFolders(const std::wstring& exe_path, bool system_uninstall,
+ const installer::Version& installed_version) {
+ std::wstring install_path(installer::GetChromeInstallPath(system_uninstall));
+ if (install_path.empty()) {
+ LOG(ERROR) << "Could not get installation destination path.";
+ return false; // Nothing else we can do for uninstall, so we return.
+ } else {
+ LOG(INFO) << "install destination path: " << install_path;
+ }
+
+ std::wstring setup_exe(installer::GetInstallerPathUnderChrome(
+ install_path, installed_version.GetString()));
+ file_util::AppendToPath(&setup_exe, file_util::GetFilenameFromPath(exe_path));
+
+ std::wstring temp_file;
+ file_util::CreateTemporaryFileName(&temp_file);
+ file_util::Move(setup_exe, temp_file);
+
+ LOG(INFO) << "Deleting install path " << install_path;
+ if (!file_util::Delete(install_path, true))
+ LOG(ERROR) << "Failed to delete folder: " << install_path;
+
+ // 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;
+ }
+ }
+ return true;
+}
+
// This method tries to delete a registry key and logs an error message
// in case of failure. It returns true if deletion is successful,
// otherwise false.
@@ -126,8 +169,6 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
if (status != installer_util::UNINSTALL_CONFIRMED)
return status;
- BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- dist->DoPreUninstallOperations();
#if defined(GOOGLE_CHROME_BUILD)
// TODO(rahulk): This should be done by DoPreUninstallOperations call above
wchar_t product[39]; // GUID + '\0'
@@ -151,6 +192,7 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
// Delete the registry keys (Uninstall key and Version key).
HKEY reg_root = system_uninstall ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
RegKey key(reg_root, L"", KEY_ALL_ACCESS);
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
DeleteRegistryKey(key, dist->GetUninstallRegPath());
DeleteRegistryKey(key, dist->GetVersionKey());
@@ -188,26 +230,8 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
// Finally delete all the files from Chrome folder after moving setup.exe
// to a temp location.
- std::wstring install_path(installer::GetChromeInstallPath(system_uninstall));
- if (install_path.empty()) {
- LOG(ERROR) << "Could not get installation destination path.";
- // Nothing else we could do for uninstall, so we return.
+ if (!DeleteFilesAndFolders(exe_path, system_uninstall, installed_version))
return installer_util::UNINSTALL_FAILED;
- } else {
- LOG(INFO) << "install destination path: " << install_path;
- }
-
- std::wstring setup_exe(installer::GetInstallerPathUnderChrome(
- install_path, installed_version.GetString()));
- file_util::AppendToPath(&setup_exe, file_util::GetFilenameFromPath(exe_path));
-
- std::wstring temp_file;
- file_util::CreateTemporaryFileName(&temp_file);
- file_util::Move(setup_exe, temp_file);
-
- LOG(INFO) << "Deleting install path " << install_path;
- if (!file_util::Delete(install_path, true))
- LOG(ERROR) << "Failed to delete folder: " << install_path;
LOG(INFO) << "Uninstallation complete. Launching Uninstall survey.";
dist->DoPostUninstallOperations(installed_version);