summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-20 22:26:53 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-20 22:26:53 +0000
commite4cdc665ff69c7ddff0ce5740592e735a108e0b7 (patch)
treec91e1db9eb240665a18d1d6c63289638cd677585
parent63357da39cd6d80467cdb90bb46c7933ab8609bc (diff)
downloadchromium_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
-rwxr-xr-xchrome/browser/first_run.cc43
-rw-r--r--chrome/installer/setup/install.cc16
-rwxr-xr-xchrome/installer/setup/main.cc17
-rw-r--r--chrome/installer/setup/setup.vsprops1
-rw-r--r--chrome/installer/setup/uninstall.cc35
-rw-r--r--chrome/installer/util/google_update_constants.cc2
-rwxr-xr-x[-rw-r--r--]google_update/google_update_idl.idl63
7 files changed, 105 insertions, 72 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;
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index 7543212..1c17b81 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -228,7 +228,7 @@ bool installer::InstallNewVersion(const std::wstring& exe_path,
} else {
scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList());
inuse_list->AddSetRegValueWorkItem(reg_root,
- version_key,
+ version_key,
google_update::kRegOldVersionField,
current_version.c_str(),
true);
@@ -236,10 +236,14 @@ bool installer::InstallNewVersion(const std::wstring& exe_path,
install_path, new_version.GetString()));
file_util::AppendToPath(&rename_cmd,
file_util::GetFilenameFromPath(exe_path));
- rename_cmd = L"\"" + rename_cmd + L"\" --" +
- installer_util::switches::kRenameChromeExe;
+ rename_cmd = L"\"" + rename_cmd +
+ L"\" --" + installer_util::switches::kRenameChromeExe;
+ if (reg_root == HKEY_LOCAL_MACHINE) {
+ rename_cmd = rename_cmd + L" --" +
+ installer_util::switches::kSystemLevel;
+ }
inuse_list->AddSetRegValueWorkItem(reg_root,
- version_key,
+ version_key,
google_update::kRegRenameCmdField,
rename_cmd.c_str(),
true);
@@ -251,10 +255,10 @@ bool installer::InstallNewVersion(const std::wstring& exe_path,
}
} else {
scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList());
- inuse_list->AddDeleteRegValueWorkItem(reg_root, version_key,
+ inuse_list->AddDeleteRegValueWorkItem(reg_root, version_key,
google_update::kRegOldVersionField,
true);
- inuse_list->AddDeleteRegValueWorkItem(reg_root, version_key,
+ inuse_list->AddDeleteRegValueWorkItem(reg_root, version_key,
google_update::kRegRenameCmdField,
true);
if (!inuse_list->Do()) {
diff --git a/chrome/installer/setup/main.cc b/chrome/installer/setup/main.cc
index c3e417f..2332c8a 100755
--- a/chrome/installer/setup/main.cc
+++ b/chrome/installer/setup/main.cc
@@ -384,23 +384,6 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
} else if (install_status == installer_util::NEW_VERSION_UPDATED) {
// This is temporary hack and will be deleted after one release.
UpdateChromeOpenCmd(system_install);
-
-#if defined(GOOGLE_CHROME_BUILD)
- // TODO(kuchhal): This is just temporary until all users move to the
- // new Chromium version which ships with gears.dll.
- LOG(INFO) << "Google Chrome updated. Uninstalling gears msi.";
- wchar_t product[39]; // GUID + '\0'
- MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); // Don't show any UI
- for (int i = 0;
- MsiEnumRelatedProducts(google_update::kGearsUpgradeCode, 0,
- i, product) != ERROR_NO_MORE_ITEMS; ++i) {
- LOG(INFO) << "Uninstalling Gears - " << product;
- unsigned int ret = MsiConfigureProduct(product,
- INSTALLLEVEL_MAXIMUM, INSTALLSTATE_ABSENT);
- if (ret != ERROR_SUCCESS)
- LOG(ERROR) << "Failed to uninstall Gears " << product;
- }
-#endif
}
}
}
diff --git a/chrome/installer/setup/setup.vsprops b/chrome/installer/setup/setup.vsprops
index 53258e4..e55085f 100644
--- a/chrome/installer/setup/setup.vsprops
+++ b/chrome/installer/setup/setup.vsprops
@@ -14,7 +14,6 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="msi.lib"
GenerateMapFile="true"
SubSystem="2"
OptimizeForWindows98="1"
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 27e8801..b9ca768 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -6,35 +6,19 @@
#include "chrome/installer/setup/uninstall.h"
-#include <atlbase.h>
-#include <windows.h>
-#include <msi.h>
-
#include "base/file_util.h"
#include "base/path_service.h"
-#include "base/process_util.h"
#include "base/registry.h"
-#include "base/scoped_ptr.h"
#include "base/string_util.h"
-#include "base/win_util.h"
-#include "base/wmi_util.h"
#include "chrome/app/result_codes.h"
-#include "chrome/common/chrome_constants.h"
#include "chrome/installer/setup/setup.h"
#include "chrome/installer/setup/setup_constants.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/helper.h"
-#include "chrome/installer/util/install_util.h"
-#include "chrome/installer/util/l10n_string_util.h"
#include "chrome/installer/util/logging_installer.h"
-#include "chrome/installer/util/google_update_constants.h"
-#include "chrome/installer/util/google_update_settings.h"
#include "chrome/installer/util/shell_util.h"
-#include "chrome/installer/util/util_constants.h"
#include "chrome/installer/util/version.h"
-#include "installer_util_strings.h"
-
namespace {
// This functions checks for any Chrome instances that are
@@ -119,9 +103,8 @@ bool DeleteFilesAndFolders(const std::wstring& exe_path, bool system_uninstall,
LOG(INFO) << "Deleting install path " << 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);
+ // Try closing any running chrome processes and deleting files once again.
+ CloseAllChromeProcesses();
if (!file_util::Delete(install_path, true))
LOG(ERROR) << "Failed to delete folder (2nd try): " << install_path;
}
@@ -218,20 +201,6 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
CloseAllChromeProcesses();
}
-#if defined(GOOGLE_CHROME_BUILD)
- // TODO(rahulk): This should be done by DoPreUninstallOperations call above
- wchar_t product[39]; // GUID + '\0'
- MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); // Don't show any UI to user.
- for (int i = 0; MsiEnumRelatedProducts(google_update::kGearsUpgradeCode, 0, i,
- product) != ERROR_NO_MORE_ITEMS; ++i) {
- LOG(INFO) << "Uninstalling Gears - " << product;
- unsigned int ret = MsiConfigureProduct(product, INSTALLLEVEL_MAXIMUM,
- INSTALLSTATE_ABSENT);
- if (ret != ERROR_SUCCESS)
- LOG(ERROR) << "Failed to uninstall Gears " << product << ": " << ret;
- }
-#endif
-
// Chrome is not in use so lets uninstall Chrome by deleting various files
// and registry entries. Here we will just make best effort and keep going
// in case of errors.
diff --git a/chrome/installer/util/google_update_constants.cc b/chrome/installer/util/google_update_constants.cc
index 4a1be5b..08ccefc 100644
--- a/chrome/installer/util/google_update_constants.cc
+++ b/chrome/installer/util/google_update_constants.cc
@@ -19,7 +19,7 @@ const wchar_t kRegLangField[] = L"lang";
const wchar_t kRegLastCheckedField[] = L"LastChecked";
const wchar_t kRegNameField[] = L"name";
const wchar_t kRegOldVersionField[] = L"opv";
-const wchar_t kRegRenameCmdField[] = L"rename";
+const wchar_t kRegRenameCmdField[] = L"cmd";
const wchar_t kRegRLZBrandField[] = L"brand";
const wchar_t kRegUsageStatsField[] = L"usagestats";
const wchar_t kRegVersionField[] = L"pv";
diff --git a/google_update/google_update_idl.idl b/google_update/google_update_idl.idl
index f92caca..a8889b8 100644..100755
--- a/google_update/google_update_idl.idl
+++ b/google_update/google_update_idl.idl
@@ -1,6 +1,9 @@
// Copyright 2006 Google Inc. All Rights Reserved.
//
// Author: Vivek Rao - vivekrao@google.com
+//
+// The proxy clsid #defined as PROXY_CLSID_IS in mk_common needs to be changed
+// anytime any interface below changes, or if a new interface is added.
import "oaidl.idl";
import "ocidl.idl";
@@ -40,15 +43,27 @@ interface IBrowserHttpRequest2 : IUnknown {
[
object,
oleautomation,
- uuid(738B2CC4-F187-48e2-A7A7-C1F0A464C8BE),
- helpstring("Google Update IBrowserLauncher Interface"),
+ uuid(128C2DA6-2BC0-44c0-B3F6-4EC22E647964),
+ helpstring("Google Update IProcessLauncher Interface"),
pointer_default(unique)
]
-interface IBrowserLauncher : IUnknown {
+interface IProcessLauncher : IUnknown {
+ // @param cmd_line The full command line to execute.
+ HRESULT LaunchCmdLine([in, string] const WCHAR* cmd_line);
+
// @param browser_type The browser to start.
// @param url The url to launch the browser with.
HRESULT LaunchBrowser([in] DWORD browser_type,
[in, string] const WCHAR* url);
+
+ // @param app_id Unique id to identify the calling client application
+ // @param event_id Unique id for the command
+ // @param caller_proc_id The process id of the calling process
+ // @param proc_handle The process handle valid in the caller's context
+ HRESULT LaunchCmdElevated([in, string] const WCHAR* app_guid,
+ [in, string] const WCHAR* cmd_id,
+ [in] DWORD caller_proc_id,
+ [out] ULONG_PTR* proc_handle);
};
typedef enum {
@@ -137,19 +152,41 @@ interface IGoogleUpdate : IUnknown {
[in] IJobObserver* observer);
};
+// IGoogleUpdateCore is an internal Omaha interface.
+[
+ object,
+ oleautomation,
+ uuid(909489C2-85A6-4322-AA56-D25278649D67),
+ helpstring("Google Update Core Interface"),
+ pointer_default(unique)
+]
+interface IGoogleUpdateCore : IUnknown
+{
+ // Runs a command elevated.
+ //
+ // @param app_id Unique id to identify the calling client application
+ // @param event_id Unique id for the command
+ // @param caller_proc_id The process id of the calling process
+ // @param proc_handle The process handle valid in the caller's context
+ HRESULT LaunchCmdElevated([in, string] const WCHAR* app_guid,
+ [in, string] const WCHAR* cmd_id,
+ [in] DWORD caller_proc_id,
+ [out] ULONG_PTR* proc_handle);
+};
+
[
uuid(7E6CD20B-8688-4960-96D9-B979471577B8),
version(1.0),
- helpstring("Google Update Browser Launcher 1.0 Type Library")
+ helpstring("Google Update Type Library")
]
library GoogleUpdateLib {
importlib("stdole2.tlb");
[
- uuid(D21E601A-3017-4d61-9315-F2880EBD196F),
- helpstring("BrowserLauncherClass Class")
+ uuid(ABC01078-F197-4b0b-ADBC-CFE684B39C82),
+ helpstring("ProcessLauncherClass Class")
]
- coclass BrowserLauncherClass {
- [default] interface IBrowserLauncher;
+ coclass ProcessLauncherClass {
+ [default] interface IProcessLauncher;
}
// This coclass declaration exists only for the purpose of forcing
@@ -181,4 +218,14 @@ library GoogleUpdateLib {
coclass OnDemandMachineAppsClass {
[default] interface IGoogleUpdate;
}
+
+ [
+ uuid(E225E692-4B47-4777-9BED-4FD7FE257F0E),
+ helpstring("GoogleUpdateCore Class")
+ ]
+ coclass GoogleUpdateCoreClass
+ {
+ [default] interface IGoogleUpdateCore;
+ }
+
};