summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-07 01:27:57 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-07 01:27:57 +0000
commit2414e84fdc99feb8e3a674a1776cddf5d24529fd (patch)
treea7735239d78bdbc37dcaf5a6428b3076d8a5ff33 /chrome/browser
parent0c294877146c3812e0a69a5a6ec0cf3e29803954 (diff)
downloadchromium_src-2414e84fdc99feb8e3a674a1776cddf5d24529fd.zip
chromium_src-2414e84fdc99feb8e3a674a1776cddf5d24529fd.tar.gz
chromium_src-2414e84fdc99feb8e3a674a1776cddf5d24529fd.tar.bz2
Implement the new mechanism we are going to use for handling Chromium updates
while it is in use. This should work for per user as well as system level installs (after some additional changes once Google Update changes are ready). The following scenarios should work now: - If Chromium is using two different profiles at the same time we do not switch chrome executables until all of them are closed. - The old version of Chromium can be run after a restart if the renaming of executables fails. - We will not use environment variable any more but we need to keep it until all the users get this change on their machines. - opv/rename registry keys and new_chrome.exe should always together. If one exist all three should exist because they are created and deleted as one atomic operation (as much as possible given laws of physics). BUG=1463346 Review URL: http://codereview.chromium.org/9436 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4949 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_main.cc4
-rw-r--r--chrome/browser/first_run.cc30
2 files changed, 26 insertions, 8 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index c28edc8..7cf76df9 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -441,10 +441,10 @@ int BrowserMain(CommandLine &parsed_command_line, int show_command,
// Sometimes we end up killing browser process (http://b/1308130) so make
// sure we recreate unique event to indicate running browser process.
message_window.HuntForZombieChromeProcesses();
- CreateUniqueChromeEvent();
+ already_running = (already_running && CreateUniqueChromeEvent());
// Do the tasks if chrome has been upgraded while it was last running.
- if (DoUpgradeTasks(parsed_command_line)) {
+ if (!already_running && DoUpgradeTasks(parsed_command_line)) {
return ResultCodes::NORMAL_EXIT;
}
diff --git a/chrome/browser/first_run.cc b/chrome/browser/first_run.cc
index ece99a5..b9c9884 100644
--- a/chrome/browser/first_run.cc
+++ b/chrome/browser/first_run.cc
@@ -13,7 +13,9 @@
#include "base/logging.h"
#include "base/object_watcher.h"
#include "base/path_service.h"
+#include "base/process.h"
#include "base/process_util.h"
+#include "base/registry.h"
#include "base/string_util.h"
#include "chrome/app/result_codes.h"
#include "chrome/common/chrome_constants.h"
@@ -27,8 +29,12 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_service.h"
+#include "chrome/installer/util/browser_distribution.h"
+#include "chrome/installer/util/google_update_constants.h"
+#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/master_preferences.h"
#include "chrome/installer/util/shell_util.h"
+#include "chrome/installer/util/util_constants.h"
#include "chrome/views/accelerator_handler.h"
#include "chrome/views/window.h"
@@ -37,10 +43,6 @@ namespace {
// The kSentinelFile file absence will tell us it is a first run.
const wchar_t kSentinelFile[] = L"First Run";
-// These two names are used for upgrades in-place of the chrome exe.
-const wchar_t kChromeUpgradeExe[] = L"new_chrome.exe";
-const wchar_t kChromeBackupExe[] = L"old_chrome.exe";
-
// Gives the full path to the sentinel file. The file might not exist.
bool GetFirstRunSentinelFilePath(std::wstring* path) {
std::wstring first_run_sentinel;
@@ -54,14 +56,14 @@ bool GetFirstRunSentinelFilePath(std::wstring* path) {
bool GetNewerChromeFile(std::wstring* path) {
if (!PathService::Get(base::DIR_EXE, path))
return false;
- file_util::AppendToPath(path, kChromeUpgradeExe);
+ file_util::AppendToPath(path, installer_util::kChromeNewExe);
return true;
}
bool GetBackupChromeFile(std::wstring* path) {
if (!PathService::Get(base::DIR_EXE, path))
return false;
- file_util::AppendToPath(path, kChromeBackupExe);
+ file_util::AppendToPath(path, installer_util::kChromeOldExe);
return true;
}
@@ -197,6 +199,22 @@ bool Upgrade::SwapNewChromeExeIfPresent() {
std::wstring old_chrome_exe;
if (!PathService::Get(base::FILE_EXE, &old_chrome_exe))
return false;
+ RegKey key;
+ HKEY reg_root = InstallUtil::IsPerUserInstall(old_chrome_exe.c_str()) ?
+ HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
+ BrowserDistribution *dist = BrowserDistribution::GetDistribution();
+ std::wstring rename_cmd;
+ if (key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_READ) &&
+ key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd)) {
+ ProcessHandle handle;
+ if (process_util::LaunchApp(rename_cmd, true, true, &handle)) {
+ DWORD exit_code;
+ ::GetExitCodeProcess(handle, &exit_code);
+ ::CloseHandle(handle);
+ if (exit_code == installer_util::RENAME_SUCCESSFUL)
+ return true;
+ }
+ }
std::wstring backup_exe;
if (!GetBackupChromeFile(&backup_exe))
return false;