From fc8edf5c2a5af722cbfe4c1605b5c0de4c17ae9b Mon Sep 17 00:00:00 2001 From: "evan@chromium.org" Date: Thu, 14 Oct 2010 20:30:45 +0000 Subject: CommandLine: remove wstring-based program() accessor This was already removed on non-Windows, so this change modifies the remaining Windows-specific usage. In a few places I converted use of wstring paths into FilePath, but in general for Windows-specific code I don't think it's too important to use FilePath everywhere, because it is equivalent on Windows and the current code already works. BUG=23581 Review URL: http://codereview.chromium.org/3817001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62637 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/installer/util/shell_util.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'chrome/installer/util/shell_util.cc') diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index f8c3b27..b3cf02b 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -298,18 +298,20 @@ bool IsChromeRegistered(const std::wstring& chrome_exe, // we capture and return. bool ElevateAndRegisterChrome(const std::wstring& chrome_exe, const std::wstring& suffix) { - std::wstring exe_path(file_util::GetDirectoryFromPath(chrome_exe)); - file_util::AppendToPath(&exe_path, installer_util::kSetupExe); - if (!file_util::PathExists(FilePath::FromWStringHack(exe_path))) { + FilePath exe_path = + FilePath::FromWStringHack(chrome_exe).DirName() + .Append(installer_util::kSetupExe); + if (!file_util::PathExists(exe_path)) { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); HKEY reg_root = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; RegKey key(reg_root, dist->GetUninstallRegPath().c_str(), KEY_READ); - key.ReadValue(installer_util::kUninstallStringField, &exe_path); - CommandLine command_line = CommandLine::FromString(exe_path); - exe_path = command_line.program(); + std::wstring uninstall_string; + key.ReadValue(installer_util::kUninstallStringField, &uninstall_string); + CommandLine command_line = CommandLine::FromString(uninstall_string); + exe_path = command_line.GetProgram(); } - if (file_util::PathExists(FilePath::FromWStringHack(exe_path))) { + if (file_util::PathExists(exe_path)) { std::wstring params(L"--"); params.append( ASCIIToWide(installer_util::switches::kRegisterChromeBrowser)); @@ -328,7 +330,7 @@ bool ElevateAndRegisterChrome(const std::wstring& chrome_exe, } DWORD ret_val = 0; - InstallUtil::ExecuteExeAsAdmin(exe_path, params, &ret_val); + InstallUtil::ExecuteExeAsAdmin(exe_path.value(), params, &ret_val); if (ret_val == 0) return true; } -- cgit v1.1