Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Unified Diff: chrome/installer/setup/setup_main.cc

Issue 668114: Overinstall mismatch, Launch the existing chrome instead... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/installer/util/browser_distribution.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/setup/setup_main.cc
===================================================================
--- chrome/installer/setup/setup_main.cc (revision 40641)
+++ chrome/installer/setup/setup_main.cc (working copy)
@@ -17,6 +17,7 @@
#include "base/scoped_handle_win.h"
#include "base/string_util.h"
#include "base/win_util.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/installer/setup/install.h"
#include "chrome/installer/setup/setup_constants.h"
#include "chrome/installer/setup/setup_util.h"
@@ -151,12 +152,37 @@
bool CheckPreInstallConditions(const installer::Version* installed_version,
bool system_install,
installer_util::InstallStatus& status) {
+ bool is_first_install = (NULL == installed_version);
// 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.";
+ if (!system_install && is_first_install) {
+ // This is user-level install and there is a system-level chrome
+ // installation. Instruct omaha to launch the existing one. There
+ // should be no error dialog.
+ std::wstring chrome_exe(installer::GetChromeInstallPath(!system_install));
+ if (chrome_exe.empty()) {
+ // If we failed to construct install path. Give up.
+ status = installer_util::OS_ERROR;
+ InstallUtil::WriteInstallerResult(system_install, status,
+ IDS_INSTALL_OS_ERROR_BASE, NULL);
+ return false;
+ } else {
+ status = installer_util::EXISTING_VERSION_LAUNCHED;
+ file_util::AppendToPath(&chrome_exe, installer_util::kChromeExe);
+ chrome_exe = L"\"" + chrome_exe + L"\" --"
+ + ASCIIToWide(switches::kFirstRun);
+ InstallUtil::WriteInstallerResult(system_install, status,
+ 0, &chrome_exe);
+ LOG(INFO) << "Launching existing system-level chrome instead.";
+ return false;
+ }
+ }
+ // This is an update, not an install. Omaha should know the difference
+ // and not show a dialog.
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 :
@@ -164,11 +190,10 @@
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) {
+ if (is_first_install) {
FilePath install_path = FilePath::FromWStringHack(
installer::GetChromeInstallPath(system_install));
if (file_util::PathExists(install_path) &&
« no previous file with comments | « no previous file | chrome/installer/util/browser_distribution.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698