summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-15 22:58:02 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-15 22:58:02 +0000
commit3216aa820e40c3a99374961546b0030da375a164 (patch)
treeed9d4de68bbd3d0e202e7ec96c3911e48ed4d66a /chrome/installer/util
parentbfbafe26d2d97f378da686f2a64016ac25562c16 (diff)
downloadchromium_src-3216aa820e40c3a99374961546b0030da375a164.zip
chromium_src-3216aa820e40c3a99374961546b0030da375a164.tar.gz
chromium_src-3216aa820e40c3a99374961546b0030da375a164.tar.bz2
While doing system level install on Vista, if installer is not running
as admin already, relaunch it as admin (that will bring up Vista elevation dialog). git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3433 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util')
-rw-r--r--chrome/installer/util/install_util.cc24
-rwxr-xr-x[-rw-r--r--]chrome/installer/util/install_util.h91
-rw-r--r--chrome/installer/util/shell_util.cc19
3 files changed, 76 insertions, 58 deletions
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index 032e5e8..29bc51d 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -7,7 +7,7 @@
#include "install_util.h"
-#include <windows.h>
+#include <shellapi.h>
#include "base/logging.h"
#include "base/registry.h"
@@ -16,6 +16,28 @@
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/google_update_constants.h"
+bool InstallUtil::ExecuteExeAsAdmin(const std::wstring& exe,
+ const std::wstring& params,
+ DWORD* exit_code) {
+ SHELLEXECUTEINFO info = {0};
+ info.cbSize = sizeof(SHELLEXECUTEINFO);
+ info.fMask = SEE_MASK_NOCLOSEPROCESS;
+ info.lpVerb = L"runas";
+ info.lpFile = exe.c_str();
+ info.lpParameters = params.c_str();
+ info.nShow = SW_SHOW;
+ if (::ShellExecuteEx(&info) == FALSE)
+ return false;
+
+ ::WaitForSingleObject(info.hProcess, INFINITE);
+ DWORD ret_val = 0;
+ if (!::GetExitCodeProcess(info.hProcess, &ret_val))
+ return false;
+
+ if (exit_code)
+ *exit_code = ret_val;
+ return true;
+}
std::wstring InstallUtil::GetChromeUninstallCmd(bool system_install) {
HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
diff --git a/chrome/installer/util/install_util.h b/chrome/installer/util/install_util.h
index b8ca5c3..ed63175 100644..100755
--- a/chrome/installer/util/install_util.h
+++ b/chrome/installer/util/install_util.h
@@ -1,43 +1,48 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// This file declares utility functions for the installer. The original reason
-// for putting these functions in installer\util library is so that we can
-// separate out the critical logic and write unit tests for it.
-
-#ifndef CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__
-#define CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "chrome/installer/util/util_constants.h"
-#include "chrome/installer/util/version.h"
-
-// This is a utility class that provides common installation related
-// utility methods that can be used by installer and also unit tested
-// independently.
-class InstallUtil {
- public:
- // Reads the uninstall command for Chromium from registry and returns it.
- // If system_install is true the command is read from HKLM, otherwise
- // from HKCU.
- static std::wstring GetChromeUninstallCmd(bool system_install);
-
- // Find the version of Chrome installed on the system by checking the
- // Google Update registry key. Returns the version or NULL if no version is
- // found.
- // system_install: if true, looks for version number under the HKLM root,
- // otherwise looks under the HKCU.
- static installer::Version* GetChromeVersion(bool system_install);
-
- // This function checks if the current OS is supported for Chromium.
- static bool IsOSSupported();
- private:
- DISALLOW_EVIL_CONSTRUCTORS(InstallUtil);
-};
-
-
-#endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__
-
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// This file declares utility functions for the installer. The original reason
+// for putting these functions in installer\util library is so that we can
+// separate out the critical logic and write unit tests for it.
+
+#ifndef CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__
+#define CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__
+
+#include <string>
+#include <windows.h>
+
+#include "base/basictypes.h"
+#include "chrome/installer/util/util_constants.h"
+#include "chrome/installer/util/version.h"
+
+// This is a utility class that provides common installation related
+// utility methods that can be used by installer and also unit tested
+// independently.
+class InstallUtil {
+ public:
+ // Launches given exe as admin on Vista.
+ static bool ExecuteExeAsAdmin(const std::wstring& exe,
+ const std::wstring& params,
+ DWORD* exit_code);
+
+ // Reads the uninstall command for Chromium from registry and returns it.
+ // If system_install is true the command is read from HKLM, otherwise
+ // from HKCU.
+ static std::wstring GetChromeUninstallCmd(bool system_install);
+ // Find the version of Chrome installed on the system by checking the
+ // Google Update registry key. Returns the version or NULL if no version is
+ // found.
+ // system_install: if true, looks for version number under the HKLM root,
+ // otherwise looks under the HKCU.
+ static installer::Version* GetChromeVersion(bool system_install);
+
+ // This function checks if the current OS is supported for Chromium.
+ static bool IsOSSupported();
+ private:
+ DISALLOW_EVIL_CONSTRUCTORS(InstallUtil);
+};
+
+
+#endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__
+
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index e0ab52f..9e4215f 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -24,6 +24,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/create_reg_key_work_item.h"
+#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/l10n_string_util.h"
#include "chrome/installer/util/set_reg_value_work_item.h"
#include "chrome/installer/util/util_constants.h"
@@ -235,23 +236,13 @@ ShellUtil::RegisterStatus RegisterOnVista(const std::wstring& chrome_exe,
TrimString(exe_path, L" \"", &exe_path);
}
if (file_util::PathExists(exe_path)) {
- SHELLEXECUTEINFO info = {0};
- info.cbSize = sizeof(SHELLEXECUTEINFO);
- info.fMask = SEE_MASK_NOCLOSEPROCESS;
- info.lpVerb = L"runas";
- info.lpFile = exe_path.c_str();
std::wstring params(L"--");
params.append(installer_util::switches::kRegisterChromeBrowser);
params.append(L"=\"" + chrome_exe + L"\"");
- info.lpParameters = params.c_str();
- info.nShow = SW_SHOW;
- if (::ShellExecuteEx(&info)) {
- ::WaitForSingleObject(info.hProcess, INFINITE);
- DWORD ret_val = ShellUtil::SUCCESS;
- if (::GetExitCodeProcess(info.hProcess, &ret_val) &&
- (ret_val == ShellUtil::SUCCESS))
- return ShellUtil::SUCCESS;
- }
+ DWORD ret_val = ShellUtil::SUCCESS;
+ InstallUtil::ExecuteExeAsAdmin(exe_path, params, &ret_val);
+ if (ret_val == ShellUtil::SUCCESS)
+ return ShellUtil::SUCCESS;
}
}
return ShellUtil::FAILURE;