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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/installer/util/browser_distribution.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 #include <windows.h> 6 #include <windows.h>
7 #include <msi.h> 7 #include <msi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 10
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/registry.h" 16 #include "base/registry.h"
17 #include "base/scoped_handle_win.h" 17 #include "base/scoped_handle_win.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/win_util.h" 19 #include "base/win_util.h"
20 #include "chrome/common/chrome_switches.h"
20 #include "chrome/installer/setup/install.h" 21 #include "chrome/installer/setup/install.h"
21 #include "chrome/installer/setup/setup_constants.h" 22 #include "chrome/installer/setup/setup_constants.h"
22 #include "chrome/installer/setup/setup_util.h" 23 #include "chrome/installer/setup/setup_util.h"
23 #include "chrome/installer/setup/uninstall.h" 24 #include "chrome/installer/setup/uninstall.h"
24 #include "chrome/installer/util/browser_distribution.h" 25 #include "chrome/installer/util/browser_distribution.h"
25 #include "chrome/installer/util/delete_tree_work_item.h" 26 #include "chrome/installer/util/delete_tree_work_item.h"
26 #include "chrome/installer/util/helper.h" 27 #include "chrome/installer/util/helper.h"
27 #include "chrome/installer/util/html_dialog.h" 28 #include "chrome/installer/util/html_dialog.h"
28 #include "chrome/installer/util/install_util.h" 29 #include "chrome/installer/util/install_util.h"
29 #include "chrome/installer/util/l10n_string_util.h" 30 #include "chrome/installer/util/l10n_string_util.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 install_list->Rollback(); 145 install_list->Rollback();
145 ret = installer_util::RENAME_FAILED; 146 ret = installer_util::RENAME_FAILED;
146 } 147 }
147 file_util::Delete(temp_path, true); 148 file_util::Delete(temp_path, true);
148 return ret; 149 return ret;
149 } 150 }
150 151
151 bool CheckPreInstallConditions(const installer::Version* installed_version, 152 bool CheckPreInstallConditions(const installer::Version* installed_version,
152 bool system_install, 153 bool system_install,
153 installer_util::InstallStatus& status) { 154 installer_util::InstallStatus& status) {
155 bool is_first_install = (NULL == installed_version);
154 // Check to avoid simultaneous per-user and per-machine installs. 156 // Check to avoid simultaneous per-user and per-machine installs.
155 scoped_ptr<installer::Version> 157 scoped_ptr<installer::Version>
156 chrome_version(InstallUtil::GetChromeVersion(!system_install)); 158 chrome_version(InstallUtil::GetChromeVersion(!system_install));
157 if (chrome_version.get()) { 159 if (chrome_version.get()) {
158 LOG(ERROR) << "Already installed version " << chrome_version->GetString() 160 LOG(ERROR) << "Already installed version " << chrome_version->GetString()
159 << " conflicts with the current install mode."; 161 << " conflicts with the current install mode.";
162 if (!system_install && is_first_install) {
163 // This is user-level install and there is a system-level chrome
164 // installation. Instruct omaha to launch the existing one. There
165 // should be no error dialog.
166 std::wstring chrome_exe(installer::GetChromeInstallPath(!system_install));
167 if (chrome_exe.empty()) {
168 // If we failed to construct install path. Give up.
169 status = installer_util::OS_ERROR;
170 InstallUtil::WriteInstallerResult(system_install, status,
171 IDS_INSTALL_OS_ERROR_BASE, NULL);
172 return false;
173 } else {
174 status = installer_util::EXISTING_VERSION_LAUNCHED;
175 file_util::AppendToPath(&chrome_exe, installer_util::kChromeExe);
176 chrome_exe = L"\"" + chrome_exe + L"\" --"
177 + ASCIIToWide(switches::kFirstRun);
178 InstallUtil::WriteInstallerResult(system_install, status,
179 0, &chrome_exe);
180 LOG(INFO) << "Launching existing system-level chrome instead.";
181 return false;
182 }
183 }
184 // This is an update, not an install. Omaha should know the difference
185 // and not show a dialog.
160 status = system_install ? installer_util::USER_LEVEL_INSTALL_EXISTS : 186 status = system_install ? installer_util::USER_LEVEL_INSTALL_EXISTS :
161 installer_util::SYSTEM_LEVEL_INSTALL_EXISTS; 187 installer_util::SYSTEM_LEVEL_INSTALL_EXISTS;
162 int str_id = system_install ? IDS_INSTALL_USER_LEVEL_EXISTS_BASE : 188 int str_id = system_install ? IDS_INSTALL_USER_LEVEL_EXISTS_BASE :
163 IDS_INSTALL_SYSTEM_LEVEL_EXISTS_BASE; 189 IDS_INSTALL_SYSTEM_LEVEL_EXISTS_BASE;
164 InstallUtil::WriteInstallerResult(system_install, status, str_id, NULL); 190 InstallUtil::WriteInstallerResult(system_install, status, str_id, NULL);
165 return false; 191 return false;
166 } 192 }
167
168 // If no previous installation of Chrome, make sure installation directory 193 // If no previous installation of Chrome, make sure installation directory
169 // either does not exist or can be deleted (i.e. is not locked by some other 194 // either does not exist or can be deleted (i.e. is not locked by some other
170 // process). 195 // process).
171 if (!installed_version) { 196 if (is_first_install) {
172 FilePath install_path = FilePath::FromWStringHack( 197 FilePath install_path = FilePath::FromWStringHack(
173 installer::GetChromeInstallPath(system_install)); 198 installer::GetChromeInstallPath(system_install));
174 if (file_util::PathExists(install_path) && 199 if (file_util::PathExists(install_path) &&
175 !file_util::Delete(install_path, true)) { 200 !file_util::Delete(install_path, true)) {
176 LOG(ERROR) << "Installation directory " << install_path.value() 201 LOG(ERROR) << "Installation directory " << install_path.value()
177 << " exists and can not be deleted."; 202 << " exists and can not be deleted.";
178 status = installer_util::INSTALL_DIR_IN_USE; 203 status = installer_util::INSTALL_DIR_IN_USE;
179 int str_id = IDS_INSTALL_DIR_IN_USE_BASE; 204 int str_id = IDS_INSTALL_DIR_IN_USE_BASE;
180 InstallUtil::WriteInstallerResult(system_install, status, str_id, NULL); 205 InstallUtil::WriteInstallerResult(system_install, status, str_id, NULL);
181 return false; 206 return false;
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 dist->GetApplicationName().c_str(), 706 dist->GetApplicationName().c_str(),
682 MB_OK); 707 MB_OK);
683 } 708 }
684 } 709 }
685 710
686 // Note that we allow the status installer_util::UNINSTALL_REQUIRES_REBOOT 711 // Note that we allow the status installer_util::UNINSTALL_REQUIRES_REBOOT
687 // to pass through, since this is only returned on uninstall which is never 712 // to pass through, since this is only returned on uninstall which is never
688 // invoked directly by Google Update. 713 // invoked directly by Google Update.
689 return dist->GetInstallReturnCode(install_status); 714 return dist->GetInstallReturnCode(install_status);
690 } 715 }
OLDNEW
« 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