diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-27 22:24:26 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-27 22:24:26 +0000 |
commit | ef038f229a742a7408ecaec1f56ea61e3bc38409 (patch) | |
tree | d6f638bbcc751c1cdb8eb8957c8d3d8677866e8f /chrome/installer | |
parent | 9aed47ca88d66fd3edd77f6a4ac0c4f4f953cecc (diff) | |
download | chromium_src-ef038f229a742a7408ecaec1f56ea61e3bc38409.zip chromium_src-ef038f229a742a7408ecaec1f56ea61e3bc38409.tar.gz chromium_src-ef038f229a742a7408ecaec1f56ea61e3bc38409.tar.bz2 |
Before installing Chrome check that the installation directory doesn't exist (or can be deleted).
BUG=7176
Review URL: http://codereview.chromium.org/27258
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10640 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r-- | chrome/installer/setup/main.cc | 58 | ||||
-rwxr-xr-x | chrome/installer/util/prebuild/create_string_rc.py | 1 | ||||
-rw-r--r-- | chrome/installer/util/util_constants.h | 3 |
3 files changed, 45 insertions, 17 deletions
diff --git a/chrome/installer/setup/main.cc b/chrome/installer/setup/main.cc index 0fe810e..672b1a1 100644 --- a/chrome/installer/setup/main.cc +++ b/chrome/installer/setup/main.cc @@ -304,8 +304,50 @@ void UpdateChromeOpenCmd(bool system_install) { ReplaceRegistryValue(reg_key[i], old_open_cmd, new_open_cmd); } +bool CheckPreInstallConditions(const installer::Version* installed_version, + int options, + installer_util::InstallStatus& status) { + bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0; + + // Check to avoid simultaneous per-user and per-machine installs. + scoped_ptr<installer::Version> + chrome_version(InstallUtil::GetChromeVersion(!system_install)); + if (chrome_version.get()) { + LOG(ERROR) << "Already installed version " << chrome_version->GetString() + << " conflicts with the current install mode."; + status = system_install ? installer_util::USER_LEVEL_INSTALL_EXISTS : + installer_util::SYSTEM_LEVEL_INSTALL_EXISTS; + int str_id = system_install ? IDS_INSTALL_USER_LEVEL_EXISTS_BASE : + IDS_INSTALL_SYSTEM_LEVEL_EXISTS_BASE; + InstallUtil::WriteInstallerResult(system_install, status, str_id, NULL); + return false; + } + + // If no previous installation of Chrome, make sure installation directory + // either does not exist or can be deleted (i.e. is not locked by some other + // process). + if (installed_version) { + std::wstring install_path(installer::GetChromeInstallPath(system_install)); + if (file_util::PathExists(install_path) && + !file_util::Delete(install_path, true)) { + LOG(ERROR) << "Installation directory " << install_path + << " exists and can not be deleted."; + status = installer_util::INSTALL_DIR_IN_USE; + int str_id = IDS_INSTALL_DIR_IN_USE_BASE; + InstallUtil::WriteInstallerResult(system_install, status, str_id, NULL); + return false; + } + } + + return true; +} + installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line, const installer::Version* installed_version, int options) { + installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS; + if (!CheckPreInstallConditions(installed_version, options, install_status)) + return install_status; + bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0; // For install the default location for chrome.packed.7z is in current // folder, so get that value first. @@ -337,7 +379,6 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line, file_util::AppendToPath(&unpack_path, std::wstring(installer::kInstallSourceDir)); bool incremental_install = false; - installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS; if (UnPackArchive(archive, system_install, installed_version, temp_path, unpack_path, incremental_install)) { install_status = installer_util::UNCOMPRESSION_FAILED; @@ -560,21 +601,6 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, system_install); // If --uninstall option is not specified, we assume it is install case. } else { - // Check to avoid simultaneous per-user and per-machine installs. - scoped_ptr<installer::Version> - chrome_version(InstallUtil::GetChromeVersion(!system_install)); - if (chrome_version.get()) { - LOG(ERROR) << "Already installed version " << chrome_version->GetString() - << " conflicts with the current install mode."; - installer_util::InstallStatus status = system_install ? - installer_util::USER_LEVEL_INSTALL_EXISTS : - installer_util::SYSTEM_LEVEL_INSTALL_EXISTS; - int str_id = system_install ? IDS_INSTALL_USER_LEVEL_EXISTS_BASE : - IDS_INSTALL_SYSTEM_LEVEL_EXISTS_BASE; - InstallUtil::WriteInstallerResult(system_install, status, str_id, NULL); - return status; - } - install_status = InstallChrome(parsed_command_line, installed_version.get(), options); diff --git a/chrome/installer/util/prebuild/create_string_rc.py b/chrome/installer/util/prebuild/create_string_rc.py index 59ef430..bb4e5a0 100755 --- a/chrome/installer/util/prebuild/create_string_rc.py +++ b/chrome/installer/util/prebuild/create_string_rc.py @@ -50,6 +50,7 @@ kStringIds = [ 'IDS_INSTALL_INVALID_ARCHIVE', 'IDS_INSTALL_INSUFFICIENT_RIGHTS', 'IDS_UNINSTALL_FAILED', + 'IDS_INSTALL_DIR_IN_USE', ] # The ID of the first resource string. diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h index aa2b27f..049fdac 100644 --- a/chrome/installer/util/util_constants.h +++ b/chrome/installer/util/util_constants.h @@ -36,7 +36,8 @@ enum InstallStatus { RENAME_FAILED, // Rename of new_chrome.exe failed EULA_REJECTED, // EULA dialog was not accepted by user. EULA_ACCEPTED, // EULA dialog was accepted by user. - EULA_ACCEPTED_OPT_IN // EULA accepted wtih the crash optin selected. + EULA_ACCEPTED_OPT_IN, // EULA accepted wtih the crash optin selected. + INSTALL_DIR_IN_USE // Installation directory is in use by another process }; // These are distibution related install options specified through command |