summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/command_line.cc6
-rw-r--r--base/command_line.h1
-rw-r--r--base/command_line_unittest.cc2
-rw-r--r--chrome/browser/shell_integration_win.cc2
-rw-r--r--chrome/common/sandbox_policy.cc2
-rw-r--r--chrome/installer/setup/setup_main.cc37
-rw-r--r--chrome/installer/setup/setup_util.cc32
-rw-r--r--chrome/installer/setup/setup_util.h10
-rw-r--r--chrome/installer/setup/setup_util_unittest.cc13
-rw-r--r--chrome/installer/setup/uninstall.cc2
-rw-r--r--chrome/installer/util/shell_util.cc18
-rw-r--r--chrome/test/mini_installer_test/run_all_unittests.cc2
12 files changed, 65 insertions, 62 deletions
diff --git a/base/command_line.cc b/base/command_line.cc
index 1c39066..2fdc176 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -340,12 +340,6 @@ FilePath CommandLine::GetProgram() const {
#endif
}
-#if defined(OS_WIN)
-std::wstring CommandLine::program() const {
- return program_;
-}
-#endif
-
#if defined(OS_POSIX)
std::string CommandLine::command_line_string() const {
return JoinString(argv_, ' ');
diff --git a/base/command_line.h b/base/command_line.h
index 31c0f5f..ec8714f 100644
--- a/base/command_line.h
+++ b/base/command_line.h
@@ -164,7 +164,6 @@ class CommandLine {
// TODO(evanm): remove all of these.
#if defined(OS_WIN)
// Deprecated on non-Windows.
- std::wstring program() const;
bool HasSwitch(const std::wstring& switch_string) const;
#endif
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc
index cd26fc5..9184aa3 100644
--- a/base/command_line_unittest.cc
+++ b/base/command_line_unittest.cc
@@ -106,7 +106,7 @@ TEST(CommandLineTest, EmptyString) {
#if defined(OS_WIN)
CommandLine cl = CommandLine::FromString(L"");
EXPECT_TRUE(cl.command_line_string().empty());
- EXPECT_TRUE(cl.program().empty());
+ EXPECT_TRUE(cl.GetProgram().empty());
#elif defined(OS_POSIX)
CommandLine cl(0, NULL);
EXPECT_TRUE(cl.argv().size() == 0);
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc
index 06b28c1..9b1c7d3 100644
--- a/chrome/browser/shell_integration_win.cc
+++ b/chrome/browser/shell_integration_win.cc
@@ -346,7 +346,7 @@ ShellIntegration::DefaultBrowserState ShellIntegration::IsDefaultBrowser() {
// Need to normalize path in case it's been munged.
CommandLine command_line = CommandLine::FromString(value);
std::wstring short_path;
- GetShortPathName(command_line.program().c_str(),
+ GetShortPathName(command_line.GetProgram().value().c_str(),
WriteInto(&short_path, MAX_PATH), MAX_PATH);
if (!FilePath::CompareEqualIgnoreCase(short_path, short_app_path))
return NOT_DEFAULT_BROWSER;
diff --git a/chrome/common/sandbox_policy.cc b/chrome/common/sandbox_policy.cc
index 7398734..894778e 100644
--- a/chrome/common/sandbox_policy.cc
+++ b/chrome/common/sandbox_policy.cc
@@ -562,7 +562,7 @@ base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line,
TRACE_EVENT_BEGIN("StartProcessWithAccess::LAUNCHPROCESS", 0, 0);
result = g_broker_services->SpawnTarget(
- cmd_line->program().c_str(),
+ cmd_line->GetProgram().value().c_str(),
cmd_line->command_line_string().c_str(),
policy, &target);
policy->Release();
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc
index 114bdd4..9329215 100644
--- a/chrome/installer/setup/setup_main.cc
+++ b/chrome/installer/setup/setup_main.cc
@@ -87,8 +87,9 @@ DWORD UnPackArchive(const std::wstring& archive, bool system_install,
installed_version->GetString());
file_util::AppendToPath(&existing_archive, installer_util::kInstallerDir);
file_util::AppendToPath(&existing_archive, installer::kChromeArchive);
- if (int i = setup_util::ApplyDiffPatch(existing_archive, unpacked_file,
- uncompressed_archive)) {
+ if (int i = setup_util::ApplyDiffPatch(FilePath(existing_archive),
+ FilePath(unpacked_file),
+ FilePath(uncompressed_archive))) {
LOG(ERROR) << "Binary patching failed with error " << i;
return i;
}
@@ -227,16 +228,16 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
// For install the default location for chrome.packed.7z is in current
// folder, so get that value first.
- std::wstring archive = file_util::GetDirectoryFromPath(cmd_line.program());
- file_util::AppendToPath(&archive,
- std::wstring(installer::kChromeCompressedArchive));
+ FilePath archive =
+ cmd_line.GetProgram().DirName().Append(
+ installer::kChromeCompressedArchive);
// If --install-archive is given, get the user specified value
if (cmd_line.HasSwitch(installer_util::switches::kInstallArchive)) {
- archive = cmd_line.GetSwitchValueNative(
+ archive = cmd_line.GetSwitchValuePath(
installer_util::switches::kInstallArchive);
}
- LOG(INFO) << "Archive found to install Chrome " << archive;
+ LOG(INFO) << "Archive found to install Chrome " << archive.value();
// Create a temp folder where we will unpack Chrome archive. If it fails,
// then we are doomed, so return immediately and no cleanup is required.
@@ -256,7 +257,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
file_util::AppendToPath(&unpack_path,
std::wstring(installer::kInstallSourceDir));
bool incremental_install = false;
- if (UnPackArchive(archive, system_level, installed_version,
+ if (UnPackArchive(archive.value(), system_level, installed_version,
temp_path.ToWStringHack(), unpack_path,
incremental_install)) {
install_status = installer_util::UNCOMPRESSION_FAILED;
@@ -269,7 +270,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
file_util::AppendToPath(&src_path,
std::wstring(installer::kInstallSourceChromeDir));
scoped_ptr<installer::Version>
- installer_version(setup_util::GetVersionFromDir(src_path));
+ installer_version(setup_util::GetVersionFromDir(FilePath(src_path)));
if (!installer_version.get()) {
LOG(ERROR) << "Did not find any valid version in installer.";
install_status = installer_util::INVALID_ARCHIVE;
@@ -287,12 +288,12 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
} else {
// We want to keep uncompressed archive (chrome.7z) that we get after
// uncompressing and binary patching. Get the location for this file.
- std::wstring archive_to_copy(temp_path.ToWStringHack());
- file_util::AppendToPath(&archive_to_copy, installer::kChromeArchive);
+ FilePath archive_to_copy = temp_path.Append(installer::kChromeArchive);
std::wstring prefs_source_path = cmd_line.GetSwitchValueNative(
installer_util::switches::kInstallerData);
install_status = installer::InstallOrUpdateChrome(
- cmd_line.program(), archive_to_copy, temp_path.ToWStringHack(),
+ cmd_line.GetProgram().value(), archive_to_copy.value(),
+ temp_path.ToWStringHack(),
prefs_source_path, prefs, *installer_version, installed_version);
int install_msg_base = IDS_INSTALL_FAILED_BASE;
@@ -398,7 +399,8 @@ installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line,
bool remove_all = !cmd_line.HasSwitch(
installer_util::switches::kDoNotRemoveSharedItems);
- return installer_setup::UninstallChrome(cmd_line.program(), system_install,
+ return installer_setup::UninstallChrome(cmd_line.GetProgram().value(),
+ system_install,
remove_all, force,
cmd_line, cmd_params);
}
@@ -454,10 +456,11 @@ bool HandleNonInstallCmdLineOptions(const CommandLine& cmd_line,
std::wstring uncompressed_patch;
if (LzmaUtil::UnPackArchive(setup_patch, temp_path.ToWStringHack(),
&uncompressed_patch) == NO_ERROR) {
- std::wstring old_setup_exe = cmd_line.program();
- std::wstring new_setup_exe = cmd_line.GetSwitchValueNative(
+ FilePath old_setup_exe = cmd_line.GetProgram();
+ FilePath new_setup_exe = cmd_line.GetSwitchValuePath(
installer_util::switches::kNewSetupExe);
- if (!setup_util::ApplyDiffPatch(old_setup_exe, uncompressed_patch,
+ if (!setup_util::ApplyDiffPatch(old_setup_exe,
+ FilePath(uncompressed_patch),
new_setup_exe))
status = installer_util::NEW_VERSION_UPDATED;
}
@@ -676,7 +679,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
if (system_install && !IsUserAnAdmin()) {
if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA &&
!parsed_command_line.HasSwitch(installer_util::switches::kRunAsAdmin)) {
- std::wstring exe = parsed_command_line.program();
+ std::wstring exe = parsed_command_line.GetProgram().value();
std::wstring params(command_line);
// Append --run-as-admin flag to let the new instance of setup.exe know
// that we already tried to launch ourselves as admin.
diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc
index 2136616..84f6c2b 100644
--- a/chrome/installer/setup/setup_util.cc
+++ b/chrome/installer/setup/setup_util.cc
@@ -13,34 +13,38 @@
#include "courgette/courgette.h"
#include "third_party/bspatch/mbspatch.h"
-int setup_util::ApplyDiffPatch(const std::wstring& src,
- const std::wstring& patch,
- const std::wstring& dest) {
- LOG(INFO) << "Applying patch " << patch
- << " to file " << src
- << " and generating file " << dest;
+int setup_util::ApplyDiffPatch(const FilePath& src,
+ const FilePath& patch,
+ const FilePath& dest) {
+ LOG(INFO) << "Applying patch " << patch.value()
+ << " to file " << src.value()
+ << " and generating file " << dest.value();
// Try Courgette first. Courgette checks the patch file first and fails
// quickly if the patch file does not have a valid Courgette header.
courgette::Status patch_status =
- courgette::ApplyEnsemblePatch(src.c_str(), patch.c_str(), dest.c_str());
+ courgette::ApplyEnsemblePatch(src.value().c_str(),
+ patch.value().c_str(),
+ dest.value().c_str());
if (patch_status == courgette::C_OK) {
return 0;
} else {
- LOG(INFO) << "Failed to apply patch " << patch << " using courgette.";
+ LOG(INFO) << "Failed to apply patch " << patch.value()
+ << " using courgette.";
}
- return ApplyBinaryPatch(src.c_str(), patch.c_str(), dest.c_str());
+ return ApplyBinaryPatch(src.value().c_str(), patch.value().c_str(),
+ dest.value().c_str());
}
installer::Version* setup_util::GetVersionFromDir(
- const std::wstring& chrome_path) {
- LOG(INFO) << "Looking for Chrome version folder under " << chrome_path;
- std::wstring root_path(chrome_path);
- file_util::AppendToPath(&root_path, L"*");
+ const FilePath& chrome_path) {
+ LOG(INFO) << "Looking for Chrome version folder under "
+ << chrome_path.value();
+ FilePath root_path = chrome_path.Append(L"*");
WIN32_FIND_DATA find_data;
- HANDLE file_handle = FindFirstFile(root_path.c_str(), &find_data);
+ HANDLE file_handle = FindFirstFile(root_path.value().c_str(), &find_data);
BOOL ret = TRUE;
installer::Version *version = NULL;
// Here we are assuming that the installer we have is really valid so there
diff --git a/chrome/installer/setup/setup_util.h b/chrome/installer/setup/setup_util.h
index 39118cc..61aed71 100644
--- a/chrome/installer/setup/setup_util.h
+++ b/chrome/installer/setup/setup_util.h
@@ -10,18 +10,20 @@
#include "chrome/installer/util/version.h"
+class FilePath;
+
namespace setup_util {
// Apply a diff patch to source file. First tries to apply it using courgette
// since it checks for courgette header and fails quickly. If that fails
// tries to apply the patch using regular bsdiff. Returns status code.
- int ApplyDiffPatch(const std::wstring& src,
- const std::wstring& patch,
- const std::wstring& dest);
+ int ApplyDiffPatch(const FilePath& src,
+ const FilePath& patch,
+ const FilePath& dest);
// Find the version of Chrome from an install source directory.
// Chrome_path should contain a version folder.
// Returns the first version found or NULL if no version is found.
- installer::Version* GetVersionFromDir(const std::wstring& chrome_path);
+ installer::Version* GetVersionFromDir(const FilePath& chrome_path);
} // namespace setup_util
#endif // CHROME_INSTALLER_SETUP_SETUP_UTIL_H_
diff --git a/chrome/installer/setup/setup_util_unittest.cc b/chrome/installer/setup/setup_util_unittest.cc
index fc0ac9e..2543d01 100644
--- a/chrome/installer/setup/setup_util_unittest.cc
+++ b/chrome/installer/setup/setup_util_unittest.cc
@@ -55,12 +55,11 @@ TEST_F(SetupUtilTest, ApplyDiffPatchTest) {
FilePath src = data_dir_.AppendASCII("archive1.7z");
FilePath patch = data_dir_.AppendASCII("archive.diff");
FilePath dest = work_dir.AppendASCII("archive2.7z");
- EXPECT_EQ(setup_util::ApplyDiffPatch(src.value(), patch.value(),
- dest.value()), 0);
+ EXPECT_EQ(setup_util::ApplyDiffPatch(src, patch, dest), 0);
FilePath base = data_dir_.AppendASCII("archive2.7z");
EXPECT_TRUE(file_util::ContentsEqual(dest, base));
- EXPECT_EQ(setup_util::ApplyDiffPatch(L"", L"", L""), 6);
+ EXPECT_EQ(setup_util::ApplyDiffPatch(FilePath(), FilePath(), FilePath()), 6);
}
// Test that we are parsing Chrome version correctly.
@@ -70,21 +69,21 @@ TEST_F(SetupUtilTest, GetVersionFromDirTest) {
file_util::CreateDirectory(chrome_dir);
ASSERT_TRUE(file_util::PathExists(chrome_dir));
scoped_ptr<installer::Version> version(
- setup_util::GetVersionFromDir(test_dir_.value()));
+ setup_util::GetVersionFromDir(test_dir_));
ASSERT_TRUE(version->GetString() == L"1.0.0.0");
file_util::Delete(chrome_dir, true);
ASSERT_FALSE(file_util::PathExists(chrome_dir));
- ASSERT_TRUE(setup_util::GetVersionFromDir(test_dir_.value()) == NULL);
+ ASSERT_TRUE(setup_util::GetVersionFromDir(test_dir_) == NULL);
chrome_dir = test_dir_.AppendASCII("ABC");
file_util::CreateDirectory(chrome_dir);
ASSERT_TRUE(file_util::PathExists(chrome_dir));
- ASSERT_TRUE(setup_util::GetVersionFromDir(test_dir_.value()) == NULL);
+ ASSERT_TRUE(setup_util::GetVersionFromDir(test_dir_) == NULL);
chrome_dir = test_dir_.AppendASCII("2.3.4.5");
file_util::CreateDirectory(chrome_dir);
ASSERT_TRUE(file_util::PathExists(chrome_dir));
- version.reset(setup_util::GetVersionFromDir(test_dir_.value()));
+ version.reset(setup_util::GetVersionFromDir(test_dir_));
ASSERT_TRUE(version->GetString() == L"2.3.4.5");
}
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index f4fe556..4822aa1 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -470,7 +470,7 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
!::IsUserAnAdmin() &&
(win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) &&
!cmd_line.HasSwitch(installer_util::switches::kRunAsAdmin)) {
- std::wstring exe = cmd_line.program();
+ std::wstring exe = cmd_line.GetProgram().value();
std::wstring params(cmd_params);
// Append --run-as-admin flag to let the new instance of setup.exe know
// that we already tried to launch ourselves as admin.
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;
}
diff --git a/chrome/test/mini_installer_test/run_all_unittests.cc b/chrome/test/mini_installer_test/run_all_unittests.cc
index f8f1d42..bde121e 100644
--- a/chrome/test/mini_installer_test/run_all_unittests.cc
+++ b/chrome/test/mini_installer_test/run_all_unittests.cc
@@ -56,7 +56,7 @@ int main(int argc, char** argv) {
} else {
printf("This test needs command line arguments.\n");
printf("Usage: %ls -{clean|backup} [-build <version>] [-force] \n",
- command_line.program().c_str());
+ command_line.GetProgram().value().c_str());
printf("-clean arg will uninstall your chrome at all levels"
" and also delete profile.\n"
"-backup arg will make a copy of User Data before uninstalling"