summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-15 04:17:52 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-15 04:17:52 +0000
commite6124ad5561dd4c448c9e76c6ee9a0ceff96412d (patch)
tree82b3138919c255a79ab82a2652219cd3e08e4411 /chrome/installer
parentc623add7ea499ec7ed90985b5adea97f9185354f (diff)
downloadchromium_src-e6124ad5561dd4c448c9e76c6ee9a0ceff96412d.zip
chromium_src-e6124ad5561dd4c448c9e76c6ee9a0ceff96412d.tar.gz
chromium_src-e6124ad5561dd4c448c9e76c6ee9a0ceff96412d.tar.bz2
Attempt to reland http://codereview.chromium.org/4928002/
For some reason the Win bot failed to compile the sandbox unit test. Trybots and my machines don't have these build problems, so I'm going to try again, unchanged. Original description: Changing the installer switches from wchar_t[] to char[]. Because of this I'm also refactoring some code that before was using wstring to build command lines by hand instead of using the CommandLine class. Now we use CommandLine. To get this to work correctly, I also needed to fix CommandLine::AppendArguments so I added a little test for it. TEST=There should be no changes in functionality. Run all installer tests. BUG=61609 TBR=robertshield Review URL: http://codereview.chromium.org/4989001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66096 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/setup/install.cc47
-rw-r--r--chrome/installer/setup/setup_main.cc13
-rw-r--r--chrome/installer/setup/uninstall.cc20
-rw-r--r--chrome/installer/setup/uninstall.h3
-rw-r--r--chrome/installer/util/google_chrome_distribution.cc16
-rw-r--r--chrome/installer/util/install_util.cc23
-rw-r--r--chrome/installer/util/install_util.h5
-rw-r--r--chrome/installer/util/master_preferences.cc4
-rw-r--r--chrome/installer/util/master_preferences_unittest.cc61
-rw-r--r--chrome/installer/util/shell_util.cc27
-rw-r--r--chrome/installer/util/util_constants.cc54
-rw-r--r--chrome/installer/util/util_constants.h52
12 files changed, 154 insertions, 171 deletions
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index c1325f8..8aefcf3 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -82,15 +82,10 @@ void AddInstallerCopyTasks(const std::wstring& exe_path,
}
}
-// A little helper function to save on tons of WideToASCII call sites.
-void AppendWideSwitch(CommandLine* cmd, const wchar_t* switch_name) {
- cmd->AppendSwitch(WideToASCII(switch_name));
-}
-
void AppendUninstallCommandLineFlags(CommandLine* uninstall_cmd,
bool is_system) {
DCHECK(uninstall_cmd);
- AppendWideSwitch(uninstall_cmd, installer_util::switches::kUninstall);
+ uninstall_cmd->AppendSwitch(installer_util::switches::kUninstall);
// TODO(tommi): In case of multiple installations, we need to create multiple
// uninstall entries, and not one magic one for all.
@@ -99,26 +94,26 @@ void AppendUninstallCommandLineFlags(CommandLine* uninstall_cmd,
DCHECK(!prefs.is_multi_install());
if (prefs.install_chrome_frame()) {
- AppendWideSwitch(uninstall_cmd, installer_util::switches::kDeleteProfile);
- AppendWideSwitch(uninstall_cmd, installer_util::switches::kChromeFrame);
+ uninstall_cmd->AppendSwitch(installer_util::switches::kDeleteProfile);
+ uninstall_cmd->AppendSwitch(installer_util::switches::kChromeFrame);
}
if (InstallUtil::IsChromeSxSProcess()) {
- AppendWideSwitch(uninstall_cmd, installer_util::switches::kChromeSxS);
+ uninstall_cmd->AppendSwitch(installer_util::switches::kChromeSxS);
}
if (InstallUtil::IsMSIProcess(is_system)) {
- AppendWideSwitch(uninstall_cmd, installer_util::switches::kMsi);
+ uninstall_cmd->AppendSwitch(installer_util::switches::kMsi);
}
// Propagate the verbose logging switch to uninstalls too.
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(installer_util::switches::kVerboseLogging)) {
- AppendWideSwitch(uninstall_cmd, installer_util::switches::kVerboseLogging);
+ uninstall_cmd->AppendSwitch(installer_util::switches::kVerboseLogging);
}
if (is_system) {
- AppendWideSwitch(uninstall_cmd, installer_util::switches::kSystemLevel);
+ uninstall_cmd->AppendSwitch(installer_util::switches::kSystemLevel);
}
}
@@ -420,30 +415,26 @@ bool DoPostInstallTasks(HKEY reg_root,
google_update::kRegOldVersionField,
current_version.c_str(),
true);
+ FilePath installer_path(installer::GetInstallerPathUnderChrome(install_path,
+ new_version.GetString()));
+ installer_path = installer_path.Append(
+ file_util::GetFilenameFromPath(exe_path));
- std::wstring rename_cmd(installer::GetInstallerPathUnderChrome(
- 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;
+ CommandLine rename_cmd(installer_path);
+ rename_cmd.AppendSwitch(installer_util::switches::kRenameChromeExe);
if (is_system_install)
- rename_cmd = rename_cmd + L" --" + installer_util::switches::kSystemLevel;
+ rename_cmd.AppendSwitch(installer_util::switches::kSystemLevel);
- if (prefs.install_chrome_frame()) {
- rename_cmd += L" --";
- rename_cmd += installer_util::switches::kChromeFrame;
- }
+ if (prefs.install_chrome_frame())
+ rename_cmd.AppendSwitch(installer_util::switches::kChromeFrame);
- if (InstallUtil::IsChromeSxSProcess()) {
- rename_cmd += L" --";
- rename_cmd += installer_util::switches::kChromeSxS;
- }
+ if (InstallUtil::IsChromeSxSProcess())
+ rename_cmd.AppendSwitch(installer_util::switches::kChromeSxS);
inuse_list->AddSetRegValueWorkItem(reg_root,
version_key,
google_update::kRegRenameCmdField,
- rename_cmd.c_str(),
+ rename_cmd.command_line_string(),
true);
if (!inuse_list->Do()) {
LOG(ERROR) << "Couldn't write opv/cmd values to registry.";
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc
index 88b74d1..7d0725c 100644
--- a/chrome/installer/setup/setup_main.cc
+++ b/chrome/installer/setup/setup_main.cc
@@ -401,7 +401,6 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
}
installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line,
- const wchar_t* cmd_params,
const installer::Version* version,
bool system_install) {
VLOG(1) << "Uninstalling Chome";
@@ -420,7 +419,7 @@ installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line,
return installer_setup::UninstallChrome(cmd_line.GetProgram().value(),
system_install,
remove_all, force,
- cmd_line, cmd_params);
+ cmd_line);
}
installer_util::InstallStatus ShowEULADialog(const std::wstring& inner_frame) {
@@ -681,14 +680,13 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
if (system_install && !IsUserAnAdmin()) {
if (base::win::GetVersion() >= base::win::VERSION_VISTA &&
!parsed_command_line.HasSwitch(installer_util::switches::kRunAsAdmin)) {
- std::wstring exe = parsed_command_line.GetProgram().value();
- std::wstring params(command_line);
+ CommandLine new_cmd(CommandLine::NO_PROGRAM);
+ new_cmd.AppendArguments(parsed_command_line, true);
// Append --run-as-admin flag to let the new instance of setup.exe know
// that we already tried to launch ourselves as admin.
- params.append(L" --");
- params.append(installer_util::switches::kRunAsAdmin);
+ new_cmd.AppendSwitch(installer_util::switches::kRunAsAdmin);
DWORD exit_code = installer_util::UNKNOWN_STATUS;
- InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code);
+ InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code);
return exit_code;
} else {
LOG(ERROR) << "Non admin user can not install system level Chrome.";
@@ -710,7 +708,6 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
// If --uninstall option is given, uninstall chrome
if (parsed_command_line.HasSwitch(installer_util::switches::kUninstall)) {
install_status = UninstallChrome(parsed_command_line,
- command_line,
installed_version.get(),
system_install);
// If --uninstall option is not specified, we assume it is install case.
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 7a3ca1d..ba77cd8 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -470,7 +470,7 @@ const wchar_t kChromeExtProgId[] = L"ChromiumExt";
installer_util::InstallStatus installer_setup::UninstallChrome(
const std::wstring& exe_path, bool system_uninstall,
bool remove_all, bool force_uninstall,
- const CommandLine& cmd_line, const wchar_t* cmd_params) {
+ const CommandLine& cmd_line) {
installer_util::InstallStatus status = installer_util::UNINSTALL_CONFIRMED;
std::wstring suffix;
if (!ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix))
@@ -496,23 +496,19 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
!::IsUserAnAdmin() &&
(base::win::GetVersion() >= base::win::VERSION_VISTA) &&
!cmd_line.HasSwitch(installer_util::switches::kRunAsAdmin)) {
- std::wstring exe = cmd_line.GetProgram().value();
- std::wstring params(cmd_params);
+ CommandLine new_cmd(CommandLine::NO_PROGRAM);
+ new_cmd.AppendArguments(cmd_line, true);
// Append --run-as-admin flag to let the new instance of setup.exe know
// that we already tried to launch ourselves as admin.
- params.append(L" --");
- params.append(installer_util::switches::kRunAsAdmin);
+ new_cmd.AppendSwitch(installer_util::switches::kRunAsAdmin);
// Append --remove-chrome-registration to remove registry keys only.
- params.append(L" --");
- params.append(installer_util::switches::kRemoveChromeRegistration);
+ new_cmd.AppendSwitch(installer_util::switches::kRemoveChromeRegistration);
if (!suffix.empty()) {
- params.append(L" --");
- params.append(ASCIIToWide(
- installer_util::switches::kRegisterChromeBrowserSuffix));
- params.append(L"=\"" + suffix + L"\"");
+ new_cmd.AppendSwitchNative(
+ installer_util::switches::kRegisterChromeBrowserSuffix, suffix);
}
DWORD exit_code = installer_util::UNKNOWN_STATUS;
- InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code);
+ InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code);
}
}
diff --git a/chrome/installer/setup/uninstall.h b/chrome/installer/setup/uninstall.h
index 6c6513a4d..d0dc8c3 100644
--- a/chrome/installer/setup/uninstall.h
+++ b/chrome/installer/setup/uninstall.h
@@ -42,11 +42,10 @@ void RemoveLegacyRegistryKeys();
// any checks for Chrome running.
// cmd_line: CommandLine that contains information about the command that
// was used to launch current uninstaller.
-// cmd_params: Command line parameters passed to the uninstaller.
installer_util::InstallStatus UninstallChrome(
const std::wstring& exe_path, bool system_uninstall,
bool remove_all, bool force_uninstall,
- const CommandLine& cmd_line, const wchar_t* cmd_params);
+ const CommandLine& cmd_line);
} // namespace installer_setup
diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc
index 882ddb3..34a6333 100644
--- a/chrome/installer/util/google_chrome_distribution.cc
+++ b/chrome/installer/util/google_chrome_distribution.cc
@@ -139,15 +139,14 @@ bool RelaunchSetup(const std::string& flag, int value,
// Re-add the system level toast flag.
if (system_level_toast) {
- new_cmd_line.AppendSwitch(
- WideToASCII(installer_util::switches::kSystemLevelToast));
+ new_cmd_line.AppendSwitch(installer_util::switches::kSystemLevelToast);
// Re-add the toast result key. We need to do this because Setup running as
// system passes the key to Setup running as user, but that child process
// does not perform the actual toasting, it launches another Setup (as user)
// to do so. That is the process that needs the key.
const CommandLine& current_cmd_line = *CommandLine::ForCurrentProcess();
- std::string key = WideToASCII(installer_util::switches::kToastResultsKey);
+ std::string key(installer_util::switches::kToastResultsKey);
std::string toast_key = current_cmd_line.GetSwitchValueASCII(key);
if (!toast_key.empty()) {
new_cmd_line.AppendSwitchASCII(key, toast_key);
@@ -217,17 +216,16 @@ bool FixDACLsForExecute(const wchar_t* exe) {
// the computer is on but nobody has logged in locally.
// Remote Desktop sessions do not count as interactive sessions; running this
// method as a user logged in via remote desktop will do nothing.
-bool RelaunchSetupAsConsoleUser(const std::wstring& flag) {
+bool RelaunchSetupAsConsoleUser(const std::string& flag) {
FilePath setup_exe = CommandLine::ForCurrentProcess()->GetProgram();
CommandLine cmd_line(setup_exe);
- cmd_line.AppendSwitch(WideToASCII(flag));
+ cmd_line.AppendSwitch(flag);
// Get the Google Update results key, and pass it on the command line to
// the child process.
int key = GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey();
- cmd_line.AppendSwitchASCII(
- WideToASCII(installer_util::switches::kToastResultsKey),
- base::IntToString(key));
+ cmd_line.AppendSwitchASCII(installer_util::switches::kToastResultsKey,
+ base::IntToString(key));
if (base::win::GetVersion() > base::win::VERSION_XP) {
// Make sure that in Vista and Above we have the proper DACLs so
@@ -530,7 +528,7 @@ void SetClient(std::wstring experiment_group, bool last_write) {
if (cmd_line.HasSwitch(installer_util::switches::kToastResultsKey)) {
// Get the handle to the key under HKLM.
base::StringToInt(cmd_line.GetSwitchValueASCII(
- WideToASCII(installer_util::switches::kToastResultsKey)).c_str(),
+ installer_util::switches::kToastResultsKey).c_str(),
&reg_key_handle);
} else {
reg_key_handle = 0;
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index 74b4e9f..6c11f99 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -12,7 +12,6 @@
#include <algorithm>
-#include "base/command_line.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
@@ -37,14 +36,28 @@ const MasterPreferences& InstallUtil::GetMasterPreferencesForCurrentProcess() {
return prefs;
}
-bool InstallUtil::ExecuteExeAsAdmin(const std::wstring& exe,
- const std::wstring& params,
- DWORD* exit_code) {
+bool InstallUtil::ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code) {
+ FilePath::StringType program(cmd.GetProgram().value());
+ DCHECK(!program.empty());
+ DCHECK(program[0] != '\"');
+
+ CommandLine::StringType params(cmd.command_line_string());
+ if (params[0] == '"') {
+ DCHECK_EQ('"', params[program.length() + 1]);
+ DCHECK_EQ(program, params.substr(1, program.length()));
+ params = params.substr(program.length() + 2);
+ } else {
+ DCHECK_EQ(program, params.substr(0, program.length()));
+ params = params.substr(program.length());
+ }
+
+ TrimWhitespace(params, TRIM_ALL, &params);
+
SHELLEXECUTEINFO info = {0};
info.cbSize = sizeof(SHELLEXECUTEINFO);
info.fMask = SEE_MASK_NOCLOSEPROCESS;
info.lpVerb = L"runas";
- info.lpFile = exe.c_str();
+ info.lpFile = program.c_str();
info.lpParameters = params.c_str();
info.nShow = SW_SHOW;
if (::ShellExecuteEx(&info) == FALSE)
diff --git a/chrome/installer/util/install_util.h b/chrome/installer/util/install_util.h
index 1e8fd79..027a8ee 100644
--- a/chrome/installer/util/install_util.h
+++ b/chrome/installer/util/install_util.h
@@ -15,6 +15,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/command_line.h"
#include "chrome/installer/util/master_preferences.h"
#include "chrome/installer/util/util_constants.h"
#include "chrome/installer/util/version.h"
@@ -33,9 +34,7 @@ class RegKey;
class InstallUtil {
public:
// Launches given exe as admin on Vista.
- static bool ExecuteExeAsAdmin(const std::wstring& exe,
- const std::wstring& params,
- DWORD* exit_code);
+ static bool ExecuteExeAsAdmin(const CommandLine& cmd, 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
diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc
index 51b9192..2d77ada 100644
--- a/chrome/installer/util/master_preferences.cc
+++ b/chrome/installer/util/master_preferences.cc
@@ -92,7 +92,7 @@ MasterPreferences::MasterPreferences(const CommandLine& cmd_line)
// distribution dictionary. Currently all switches added will be set to
// 'true'.
static const struct CmdLineSwitchToDistributionSwitch {
- const wchar_t* cmd_line_switch;
+ const char* cmd_line_switch;
const char* distribution_switch;
} translate_switches[] = {
{ installer_util::switches::kCeee,
@@ -136,7 +136,7 @@ MasterPreferences::MasterPreferences(const CommandLine& cmd_line)
// See if the log file path was specified on the command line.
std::wstring str_value(cmd_line.GetSwitchValueNative(
- WideToASCII(installer_util::switches::kLogFile)));
+ installer_util::switches::kLogFile));
if (!str_value.empty()) {
name.resize(arraysize(kDistroDict) - 1);
name.append(".").append(installer_util::master_preferences::kLogFile);
diff --git a/chrome/installer/util/master_preferences_unittest.cc b/chrome/installer/util/master_preferences_unittest.cc
index fe53c29..8490025 100644
--- a/chrome/installer/util/master_preferences_unittest.cc
+++ b/chrome/installer/util/master_preferences_unittest.cc
@@ -303,15 +303,14 @@ TEST_F(MasterPreferencesTest, GetInstallPreferencesTest) {
}
TEST_F(MasterPreferencesTest, TestDefaultInstallConfig) {
- const std::wstring kChromeInstall(L"setup.exe");
- const std::wstring kCfInstall(StringPrintf(L"setup.exe --%ls",
- installer_util::switches::kChromeFrame));
- const std::wstring kCeeeInstall(StringPrintf(L"setup.exe --%ls",
- installer_util::switches::kCeee));
+ std::wstringstream chrome_cmd, cf_cmd, ceee_cmd;
+ chrome_cmd << "setup.exe";
+ cf_cmd << "setup.exe --" << installer_util::switches::kChromeFrame;
+ ceee_cmd << "setup.exe --" << installer_util::switches::kCeee;
- CommandLine chrome_install(CommandLine::FromString(kChromeInstall));
- CommandLine cf_install(CommandLine::FromString(kCfInstall));
- CommandLine ceee_install(CommandLine::FromString(kCeeeInstall));
+ CommandLine chrome_install(CommandLine::FromString(chrome_cmd.str()));
+ CommandLine cf_install(CommandLine::FromString(cf_cmd.str()));
+ CommandLine ceee_install(CommandLine::FromString(ceee_cmd.str()));
installer_util::MasterPreferences pref_chrome(chrome_install);
installer_util::MasterPreferences pref_cf(cf_install);
@@ -334,33 +333,27 @@ TEST_F(MasterPreferencesTest, TestDefaultInstallConfig) {
}
TEST_F(MasterPreferencesTest, TestMultiInstallConfig) {
- const std::wstring kChromeInstall(StringPrintf(L"setup.exe --%ls --%ls",
- installer_util::switches::kMultiInstall,
- installer_util::switches::kChrome));
- const std::wstring kCfInstall(StringPrintf(L"setup.exe --%ls --%ls",
- installer_util::switches::kMultiInstall,
- installer_util::switches::kChromeFrame));
- const std::wstring kCeeeInstall(StringPrintf(L"setup.exe --%ls --%ls",
- installer_util::switches::kMultiInstall,
- installer_util::switches::kCeee));
- const std::wstring kChromeCfInstall(
- StringPrintf(L"setup.exe --%ls --%ls --%ls",
- installer_util::switches::kMultiInstall,
- installer_util::switches::kChrome,
- installer_util::switches::kChromeFrame));
- const std::wstring kChromeCeeeCfInstall(
- StringPrintf(L"setup.exe --%ls --%ls --%ls --%ls",
- installer_util::switches::kMultiInstall,
- installer_util::switches::kChrome,
- installer_util::switches::kChromeFrame,
- installer_util::switches::kCeee));
-
- CommandLine chrome_install(CommandLine::FromString(kChromeInstall));
- CommandLine cf_install(CommandLine::FromString(kCfInstall));
- CommandLine ceee_install(CommandLine::FromString(kCeeeInstall));
- CommandLine chrome_cf_install(CommandLine::FromString(kChromeCfInstall));
+ using installer_util::switches::kMultiInstall;
+ using installer_util::switches::kChrome;
+ using installer_util::switches::kChromeFrame;
+ using installer_util::switches::kCeee;
+
+ std::wstringstream chrome_cmd, cf_cmd, ceee_cmd, chrome_cf_cmd,
+ chrome_ceee_cf_cmd;
+ chrome_cmd << "setup.exe --" << kMultiInstall << " --" << kChrome;
+ cf_cmd << "setup.exe --" << kMultiInstall << " --" << kChromeFrame;
+ ceee_cmd << "setup.exe --" << kMultiInstall << " --" << kCeee;
+ chrome_cf_cmd << "setup.exe --" << kMultiInstall << " --" << kChrome <<
+ " --" << kChromeFrame;
+ chrome_ceee_cf_cmd << "setup.exe --" << kMultiInstall << " --" << kChrome <<
+ " --" << kChromeFrame << " --" << kCeee;
+
+ CommandLine chrome_install(CommandLine::FromString(chrome_cmd.str()));
+ CommandLine cf_install(CommandLine::FromString(cf_cmd.str()));
+ CommandLine ceee_install(CommandLine::FromString(ceee_cmd.str()));
+ CommandLine chrome_cf_install(CommandLine::FromString(chrome_cf_cmd.str()));
CommandLine chrome_cf_ceee_install(
- CommandLine::FromString(kChromeCeeeCfInstall));
+ CommandLine::FromString(chrome_ceee_cf_cmd.str()));
installer_util::MasterPreferences pref_chrome(chrome_install);
installer_util::MasterPreferences pref_cf(cf_install);
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index 947c8a0..b82bbf8 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -295,10 +295,10 @@ bool IsChromeRegistered(const std::wstring& chrome_exe,
return registered;
}
-// This method registers Chrome on Vista by launching eleavated setup.exe.
-// That will show user standard Vista elevation prompt. If user accepts it
-// the new process will make the necessary changes and return SUCCESS that
-// we capture and return.
+// This method registers Chrome on Vista by launching an elevated setup.exe.
+// That will show the user the standard Vista elevation prompt. If the user
+// accepts it the new process will make the necessary changes and return SUCCESS
+// that we capture and return.
bool ElevateAndRegisterChrome(const std::wstring& chrome_exe,
const std::wstring& suffix) {
FilePath exe_path =
@@ -314,26 +314,23 @@ bool ElevateAndRegisterChrome(const std::wstring& chrome_exe,
CommandLine command_line = CommandLine::FromString(uninstall_string);
exe_path = command_line.GetProgram();
}
+
if (file_util::PathExists(exe_path)) {
- std::wstring params(L"--");
- params.append(
- ASCIIToWide(installer_util::switches::kRegisterChromeBrowser));
- params.append(L"=\"" + chrome_exe + L"\"");
+ CommandLine cmd(exe_path);
+ cmd.AppendSwitchNative(installer_util::switches::kRegisterChromeBrowser,
+ chrome_exe);
if (!suffix.empty()) {
- params.append(L" --");
- params.append(ASCIIToWide(
- installer_util::switches::kRegisterChromeBrowserSuffix));
- params.append(L"=\"" + suffix + L"\"");
+ cmd.AppendSwitchNative(
+ installer_util::switches::kRegisterChromeBrowserSuffix, suffix);
}
CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
if (browser_command_line.HasSwitch(switches::kChromeFrame)) {
- params.append(L" --");
- params.append(installer_util::switches::kChromeFrame);
+ cmd.AppendSwitch(installer_util::switches::kChromeFrame);
}
DWORD ret_val = 0;
- InstallUtil::ExecuteExeAsAdmin(exe_path.value(), params, &ret_val);
+ InstallUtil::ExecuteExeAsAdmin(cmd, &ret_val);
if (ret_val == 0)
return true;
}
diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc
index 2cb5ceb..04df035 100644
--- a/chrome/installer/util/util_constants.cc
+++ b/chrome/installer/util/util_constants.cc
@@ -9,50 +9,50 @@ namespace installer_util {
namespace switches {
// Install CEEE.
-const wchar_t kCeee[] = L"ceee";
+const char kCeee[] = "ceee";
// Install Chrome.
// Currently this is only required when used in combination with kMultiInstall.
-const wchar_t kChrome[] = L"chrome";
+const char kChrome[] = "chrome";
// Run the installer in Chrome Frame mode.
-const wchar_t kChromeFrame[] = L"chrome-frame";
+const char kChromeFrame[] = "chrome-frame";
// Run the installer for Chrome SxS.
-const wchar_t kChromeSxS[] = L"chrome-sxs";
+const char kChromeSxS[] = "chrome-sxs";
// Create Desktop and QuickLaunch shortcuts
-const wchar_t kCreateAllShortcuts[] = L"create-all-shortcuts";
+const char kCreateAllShortcuts[] = "create-all-shortcuts";
// Delete user profile data. This param is useful only when specified with
// kUninstall, otherwise it is silently ignored.
-const wchar_t kDeleteProfile[] = L"delete-profile";
+const char kDeleteProfile[] = "delete-profile";
// Disable logging
-const wchar_t kDisableLogging[] = L"disable-logging";
+const char kDisableLogging[] = "disable-logging";
// Prevent installer from creating desktop shortcuts.
-const wchar_t kDoNotCreateShortcuts[] = L"do-not-create-shortcuts";
+const char kDoNotCreateShortcuts[] = "do-not-create-shortcuts";
// Prevent installer from launching Chrome after a successful first install.
-const wchar_t kDoNotLaunchChrome[] = L"do-not-launch-chrome";
+const char kDoNotLaunchChrome[] = "do-not-launch-chrome";
// Prevents installer from writing the Google Update key that causes Google
// Update to launch Chrome after a first install.
-const wchar_t kDoNotRegisterForUpdateLaunch[] =
- L"do-not-register-for-update-launch";
+const char kDoNotRegisterForUpdateLaunch[] =
+ "do-not-register-for-update-launch";
// By default we remove all shared (between users) files, registry entries etc
// during uninstall. If this option is specified together with kUninstall option
// we do not clean up shared entries otherwise this option is ignored.
-const wchar_t kDoNotRemoveSharedItems[] = L"do-not-remove-shared-items";
+const char kDoNotRemoveSharedItems[] = "do-not-remove-shared-items";
// Enable logging at the error level. This is the default behavior.
-const wchar_t kEnableLogging[] = L"enable-logging";
+const char kEnableLogging[] = "enable-logging";
// If present, setup will uninstall chrome without asking for any
// confirmation from user.
-const wchar_t kForceUninstall[] = L"force-uninstall";
+const char kForceUninstall[] = "force-uninstall";
// Specify the file path of Chrome archive for install.
const char kInstallArchive[] = "install-archive";
@@ -61,20 +61,20 @@ const char kInstallArchive[] = "install-archive";
const char kInstallerData[] = "installerdata";
// If present, specify file path to write logging info.
-const wchar_t kLogFile[] = L"log-file";
+const char kLogFile[] = "log-file";
// Register Chrome as default browser on the system. Usually this will require
// that setup is running as admin. If running as admin we try to register
// as default browser at system level, if running as non-admin we try to
// register as default browser only for the current user.
-const wchar_t kMakeChromeDefault[] = L"make-chrome-default";
+const char kMakeChromeDefault[] = "make-chrome-default";
// Tells installer to expect to be run as a subsidiary to an MSI.
-const wchar_t kMsi[] = L"msi";
+const char kMsi[] = "msi";
// Tells installer to install multiple products specified on the command line.
// (e.g. Chrome Frame, CEEE, Chrome)
-const wchar_t kMultiInstall[] = L"multi-install";
+const char kMultiInstall[] = "multi-install";
// Useful only when used with --update-setup-exe, otherwise ignored. It
// specifies the full path where updated setup.exe will be stored.
@@ -90,20 +90,20 @@ const char kRegisterChromeBrowserSuffix[] =
// Renames chrome.exe to old_chrome.exe and renames new_chrome.exe to chrome.exe
// to support in-use updates. Also deletes opv key.
-const wchar_t kRenameChromeExe[] = L"rename-chrome-exe";
+const char kRenameChromeExe[] = "rename-chrome-exe";
// Removes Chrome registration from current machine. Requires admin rights.
-const wchar_t kRemoveChromeRegistration[] = L"remove-chrome-registration";
+const char kRemoveChromeRegistration[] = "remove-chrome-registration";
// When we try to relaunch setup.exe as admin on Vista, we append this command
// line flag so that we try the launch only once.
-const wchar_t kRunAsAdmin[] = L"run-as-admin";
+const char kRunAsAdmin[] = "run-as-admin";
// Install Chrome to system wise location. The default is per user install.
-const wchar_t kSystemLevel[] = L"system-level";
+const char kSystemLevel[] = "system-level";
// If present, setup will uninstall chrome.
-const wchar_t kUninstall[] = L"uninstall";
+const char kUninstall[] = "uninstall";
// Also see --new-setup-exe. This command line option specifies a diff patch
// that setup.exe will apply to itself and store the resulting binary in the
@@ -111,23 +111,23 @@ const wchar_t kUninstall[] = L"uninstall";
const char kUpdateSetupExe[] = "update-setup-exe";
// Enable verbose logging (info level).
-const wchar_t kVerboseLogging[] = L"verbose-logging";
+const char kVerboseLogging[] = "verbose-logging";
// Show the embedded EULA dialog.
const char kShowEula[] = "show-eula";
// Use the alternate desktop shortcut name.
-const wchar_t kAltDesktopShortcut[] = L"alt-desktop-shortcut";
+const char kAltDesktopShortcut[] = "alt-desktop-shortcut";
// Perform the inactive user toast experiment.
const char kInactiveUserToast[] = "inactive-user-toast";
// User toast experiment switch from system context to user context.
-const wchar_t kSystemLevelToast[] = L"system-level-toast";
+const char kSystemLevelToast[] = "system-level-toast";
// A handle value of the key to write the results of the toast experiment
// to. See DuplicateGoogleUpdateSystemClientKey for details.
-const wchar_t kToastResultsKey[] = L"toast-results-key";
+const char kToastResultsKey[] = "toast-results-key";
} // namespace switches
diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h
index eb6342e..db53573 100644
--- a/chrome/installer/util/util_constants.h
+++ b/chrome/installer/util/util_constants.h
@@ -51,40 +51,40 @@ enum InstallStatus {
};
namespace switches {
-extern const wchar_t kCeee[];
-extern const wchar_t kChrome[];
-extern const wchar_t kChromeFrame[];
-extern const wchar_t kChromeSxS[];
-extern const wchar_t kCreateAllShortcuts[];
-extern const wchar_t kDeleteProfile[];
-extern const wchar_t kDisableLogging[];
-extern const wchar_t kDoNotCreateShortcuts[];
-extern const wchar_t kDoNotLaunchChrome[];
-extern const wchar_t kDoNotRegisterForUpdateLaunch[];
-extern const wchar_t kDoNotRemoveSharedItems[];
-extern const wchar_t kEnableLogging[];
-extern const wchar_t kForceUninstall[];
+extern const char kCeee[];
+extern const char kChrome[];
+extern const char kChromeFrame[];
+extern const char kChromeSxS[];
+extern const char kCreateAllShortcuts[];
+extern const char kDeleteProfile[];
+extern const char kDisableLogging[];
+extern const char kDoNotCreateShortcuts[];
+extern const char kDoNotLaunchChrome[];
+extern const char kDoNotRegisterForUpdateLaunch[];
+extern const char kDoNotRemoveSharedItems[];
+extern const char kEnableLogging[];
+extern const char kForceUninstall[];
extern const char kInstallArchive[];
extern const char kInstallerData[];
-extern const wchar_t kLogFile[];
-extern const wchar_t kMakeChromeDefault[];
-extern const wchar_t kMsi[];
-extern const wchar_t kMultiInstall[];
+extern const char kLogFile[];
+extern const char kMakeChromeDefault[];
+extern const char kMsi[];
+extern const char kMultiInstall[];
extern const char kNewSetupExe[];
extern const char kRegisterChromeBrowser[];
extern const char kRegisterChromeBrowserSuffix[];
-extern const wchar_t kRenameChromeExe[];
-extern const wchar_t kRemoveChromeRegistration[];
-extern const wchar_t kRunAsAdmin[];
-extern const wchar_t kSystemLevel[];
-extern const wchar_t kUninstall[];
+extern const char kRenameChromeExe[];
+extern const char kRemoveChromeRegistration[];
+extern const char kRunAsAdmin[];
+extern const char kSystemLevel[];
+extern const char kUninstall[];
extern const char kUpdateSetupExe[];
-extern const wchar_t kVerboseLogging[];
+extern const char kVerboseLogging[];
extern const char kShowEula[];
-extern const wchar_t kAltDesktopShortcut[];
+extern const char kAltDesktopShortcut[];
extern const char kInactiveUserToast[];
-extern const wchar_t kSystemLevelToast[];
-extern const wchar_t kToastResultsKey[];
+extern const char kSystemLevelToast[];
+extern const char kToastResultsKey[];
} // namespace switches
extern const wchar_t kChromeDll[];