diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-15 21:37:46 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-15 21:37:46 +0000 |
commit | 68c921f8b5d6454307645d4017a3cbf2646904bc (patch) | |
tree | fdd0d0138a4ce706e052de4bab66fa3c4b28b8d4 /chrome/installer | |
parent | 9c6c3065723227dee6bca91df24bb6863ac123f9 (diff) | |
download | chromium_src-68c921f8b5d6454307645d4017a3cbf2646904bc.zip chromium_src-68c921f8b5d6454307645d4017a3cbf2646904bc.tar.gz chromium_src-68c921f8b5d6454307645d4017a3cbf2646904bc.tar.bz2 |
Add a check in Chrome to not run user level mode if machine level Chrome
is already installed.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3423 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r-- | chrome/installer/setup/install.cc | 2 | ||||
-rw-r--r-- | chrome/installer/setup/main.cc | 14 | ||||
-rw-r--r-- | chrome/installer/setup/setup.cc | 2 | ||||
-rw-r--r-- | chrome/installer/setup/uninstall.cc | 23 | ||||
-rw-r--r-- | chrome/installer/setup/uninstall.h | 5 | ||||
-rw-r--r-- | chrome/installer/util/install_util.cc | 9 | ||||
-rw-r--r-- | chrome/installer/util/install_util.h | 7 | ||||
-rw-r--r-- | chrome/installer/util/util_constants.cc | 6 | ||||
-rw-r--r-- | chrome/installer/util/util_constants.h | 3 |
9 files changed, 51 insertions, 20 deletions
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc index 5d65dbf..7a0a2dd 100644 --- a/chrome/installer/setup/install.cc +++ b/chrome/installer/setup/install.cc @@ -52,7 +52,7 @@ void AddUninstallShortcutWorkItems(HKEY reg_root, uninstall_cmd.append(installer_util::switches::kUninstall); if (reg_root == HKEY_LOCAL_MACHINE) { uninstall_cmd.append(L" --"); - uninstall_cmd.append(installer_util::switches::kSystemInstall); + uninstall_cmd.append(installer_util::switches::kSystemLevel); } // Create DisplayName, UninstallString and InstallLocation keys diff --git a/chrome/installer/setup/main.cc b/chrome/installer/setup/main.cc index d9b4bc6..cf08d34 100644 --- a/chrome/installer/setup/main.cc +++ b/chrome/installer/setup/main.cc @@ -253,17 +253,17 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line, installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line, const installer::Version* version, bool system_install) { - bool remove_all = true; - if (cmd_line.HasSwitch(installer_util::switches::kDoNotRemoveSharedItems)) - remove_all = false; LOG(INFO) << "Uninstalling Chome"; if (!version) { LOG(ERROR) << "No Chrome installation found for uninstall."; return installer_util::CHROME_NOT_INSTALLED; - } else { - return installer_setup::UninstallChrome(cmd_line.program(), system_install, - *version, remove_all); } + + bool remove_all = !cmd_line.HasSwitch( + installer_util::switches::kDoNotRemoveSharedItems); + bool force = cmd_line.HasSwitch(installer_util::switches::kForceUninstall); + return installer_setup::UninstallChrome(cmd_line.program(), system_install, + *version, remove_all, force); } } // namespace @@ -290,7 +290,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, } bool system_install = - parsed_command_line.HasSwitch(installer_util::switches::kSystemInstall); + parsed_command_line.HasSwitch(installer_util::switches::kSystemLevel); LOG(INFO) << "system install is " << system_install; // Check to avoid simultaneous per-user and per-machine installs. diff --git a/chrome/installer/setup/setup.cc b/chrome/installer/setup/setup.cc index e3edf19..0f5b629 100644 --- a/chrome/installer/setup/setup.cc +++ b/chrome/installer/setup/setup.cc @@ -132,7 +132,7 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path, arguments.append(installer_util::switches::kUninstall); if (system_install) { arguments.append(L" --"); - arguments.append(installer_util::switches::kSystemInstall); + arguments.append(installer_util::switches::kSystemLevel); } LOG(INFO) << "Creating/updating uninstall link at " << uninstall_link; diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 4988e54..dfaafb0 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -81,8 +81,14 @@ bool DeleteFilesAndFolders(const std::wstring& exe_path, bool system_uninstall, 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; + if (!file_util::Delete(install_path, true)) { + LOG(ERROR) << "Failed to delete folder (1st try): " << install_path; + // This is to let any closing chrome.exe die before trying delete one + // more time. + Sleep(10000); + if (!file_util::Delete(install_path, true)) + LOG(ERROR) << "Failed to delete folder (2nd try): " << install_path; + } // Now check and delete if the parent directories are empty // For example Google\Chrome or Chromium @@ -163,11 +169,14 @@ installer_util::InstallStatus IsChromeActiveOrUserCancelled( installer_util::InstallStatus installer_setup::UninstallChrome( const std::wstring& exe_path, bool system_uninstall, - const installer::Version& installed_version, bool remove_all) { - installer_util::InstallStatus status = - IsChromeActiveOrUserCancelled(system_uninstall); - if (status != installer_util::UNINSTALL_CONFIRMED) - return status; + const installer::Version& installed_version, + bool remove_all, bool force_uninstall) { + if (!force_uninstall) { + installer_util::InstallStatus status = + IsChromeActiveOrUserCancelled(system_uninstall); + if (status != installer_util::UNINSTALL_CONFIRMED) + return status; + } #if defined(GOOGLE_CHROME_BUILD) // TODO(rahulk): This should be done by DoPreUninstallOperations call above diff --git a/chrome/installer/setup/uninstall.h b/chrome/installer/setup/uninstall.h index eda077e..9004636 100644 --- a/chrome/installer/setup/uninstall.h +++ b/chrome/installer/setup/uninstall.h @@ -22,9 +22,12 @@ namespace installer_setup { // current user. // installed_version: currently installed version of Chrome. // remove_all: Remove all shared files, registry entries as well. +// force_uninstall: Uninstall without prompting for user confirmation or +// any checks for Chrome running. installer_util::InstallStatus UninstallChrome( const std::wstring& exe_path, bool system_uninstall, - const installer::Version& installed_version, bool remove_all); + const installer::Version& installed_version, + bool remove_all, bool force_uninstall); } // namespace installer_setup diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index 290a60a..032e5e8 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -17,6 +17,15 @@ #include "chrome/installer/util/google_update_constants.h" +std::wstring InstallUtil::GetChromeUninstallCmd(bool system_install) { + HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + RegKey key(root, dist->GetUninstallRegPath().c_str()); + std::wstring uninstall_cmd; + key.ReadValue(installer_util::kUninstallStringField, &uninstall_cmd); + return uninstall_cmd; +} + installer::Version* InstallUtil::GetChromeVersion(bool system_install) { RegKey key; std::wstring version_str; diff --git a/chrome/installer/util/install_util.h b/chrome/installer/util/install_util.h index 6e6d6da..b8ca5c3 100644 --- a/chrome/installer/util/install_util.h +++ b/chrome/installer/util/install_util.h @@ -20,12 +20,17 @@ // independently. class InstallUtil { public: + // Reads the uninstall command for Chromium from registry and returns it. + // If system_install is true the command is read from HKLM, otherwise + // from HKCU. + static std::wstring GetChromeUninstallCmd(bool system_install); + // Find the version of Chrome installed on the system by checking the // Google Update registry key. Returns the version or NULL if no version is // found. // system_install: if true, looks for version number under the HKLM root, // otherwise looks under the HKCU. - static installer::Version * GetChromeVersion(bool system_install); + static installer::Version* GetChromeVersion(bool system_install); // This function checks if the current OS is supported for Chromium. static bool IsOSSupported(); diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc index b3ac19f..19934f69 100644 --- a/chrome/installer/util/util_constants.cc +++ b/chrome/installer/util/util_constants.cc @@ -31,11 +31,15 @@ const wchar_t kRegisterChromeBrowser[] = L"register-chrome-browser"; const wchar_t kDoNotRemoveSharedItems[] = L"do-not-remove-shared-items"; // Install Chrome to system wise location. The default is per user install. -const wchar_t kSystemInstall[] = L"system-install"; +const wchar_t kSystemLevel[] = L"system-level"; // If present, setup will uninstall chrome. const wchar_t kUninstall[] = L"uninstall"; +// If present, setup will uninstall chrome without asking for any +// confirmation from user. +const wchar_t kForceUninstall[] = L"force-uninstall"; + // Enable verbose logging (info level). const wchar_t kVerboseLogging[] = L"verbose-logging"; diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h index e115787..5994ef0 100644 --- a/chrome/installer/util/util_constants.h +++ b/chrome/installer/util/util_constants.h @@ -40,8 +40,9 @@ extern const wchar_t kInstallArchive[]; extern const wchar_t kLogFile[]; extern const wchar_t kRegisterChromeBrowser[]; extern const wchar_t kDoNotRemoveSharedItems[]; -extern const wchar_t kSystemInstall[]; +extern const wchar_t kSystemLevel[]; extern const wchar_t kUninstall[]; +extern const wchar_t kForceUninstall[]; extern const wchar_t kVerboseLogging[]; } // namespace switches |