diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-20 22:26:53 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-20 22:26:53 +0000 |
commit | e4cdc665ff69c7ddff0ce5740592e735a108e0b7 (patch) | |
tree | c91e1db9eb240665a18d1d6c63289638cd677585 /chrome/browser | |
parent | 63357da39cd6d80467cdb90bb46c7933ab8609bc (diff) | |
download | chromium_src-e4cdc665ff69c7ddff0ce5740592e735a108e0b7.zip chromium_src-e4cdc665ff69c7ddff0ce5740592e735a108e0b7.tar.gz chromium_src-e4cdc665ff69c7ddff0ce5740592e735a108e0b7.tar.bz2 |
- If the exe rename command fails try calling Google Update to do the same job. This works when we are logged into XP/Vista as limited rights user.
- Update Google Update idl file that has the recently added COM object.
- Add --system-level to the rename command that gets added to the registry.
- Remove all the code to uninstall Gears MSI. Now most of the user have been upgraded to Chrome installer that includes gears.dll.
BUG=1463346
Review URL: http://codereview.chromium.org/11255
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5791 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rwxr-xr-x | chrome/browser/first_run.cc | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/chrome/browser/first_run.cc b/chrome/browser/first_run.cc index b8967f9..a3ea8bb 100755 --- a/chrome/browser/first_run.cc +++ b/chrome/browser/first_run.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <atlbase.h> +#include <atlcom.h> #include <windows.h> #include <shlobj.h> @@ -38,6 +40,8 @@ #include "chrome/views/accelerator_handler.h" #include "chrome/views/window.h" +#include "google_update_idl.h" + namespace { // The kSentinelFile file absence will tell us it is a first run. @@ -80,6 +84,24 @@ std::wstring GetDefaultPrefFilePath(bool create_profile_dir, return ProfileManager::GetDefaultProfilePath(default_pref_dir); } +bool InvokeGoogleUpdateForRename() { + CComPtr<IProcessLauncher> ipl; + if (!FAILED(ipl.CoCreateInstance(__uuidof(ProcessLauncherClass)))) { + ULONG_PTR phandle = NULL; + DWORD id = GetCurrentProcessId(); + if (!FAILED(ipl->LaunchCmdElevated(google_update::kChromeGuid, + google_update::kRegRenameCmdField, + id, &phandle))) { + HANDLE handle = HANDLE(phandle); + ::GetExitCodeProcess(handle, exit_code); + ::CloseHandle(handle); + if (exit_code == installer_util::RENAME_SUCCESSFUL) + return true; + } + } + return false; +} + } // namespace bool FirstRun::IsChromeFirstRun() { @@ -220,13 +242,15 @@ bool Upgrade::SwapNewChromeExeIfPresent() { return false; if (!file_util::PathExists(new_chrome_exe)) return false; - std::wstring old_chrome_exe; - if (!PathService::Get(base::FILE_EXE, &old_chrome_exe)) + std::wstring curr_chrome_exe; + if (!PathService::Get(base::FILE_EXE, &curr_chrome_exe)) return false; - RegKey key; - HKEY reg_root = InstallUtil::IsPerUserInstall(old_chrome_exe.c_str()) ? - HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; + + // First try to rename exe by launching rename command ourselves. + bool user_install = InstallUtil::IsPerUserInstall(curr_chrome_exe.c_str()); + HKEY reg_root = user_install ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; BrowserDistribution *dist = BrowserDistribution::GetDistribution(); + RegKey key; std::wstring rename_cmd; if (key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_READ) && key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd)) { @@ -239,10 +263,17 @@ bool Upgrade::SwapNewChromeExeIfPresent() { return true; } } + + // Rename didn't work so try to rename by calling Google Update + if (InvokeGoogleUpdateForRename(&exit_code)) + return true; + + // Rename still didn't work so just try to rename exe ourselves (for + // backward compatibility, can be deleted once the new process works). std::wstring backup_exe; if (!GetBackupChromeFile(&backup_exe)) return false; - if (::ReplaceFileW(old_chrome_exe.c_str(), new_chrome_exe.c_str(), + if (::ReplaceFileW(curr_chrome_exe.c_str(), new_chrome_exe.c_str(), backup_exe.c_str(), REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL)) { return true; |