diff options
45 files changed, 101 insertions, 112 deletions
diff --git a/base/command_line.cc b/base/command_line.cc index 8121aca..b028226 100644 --- a/base/command_line.cc +++ b/base/command_line.cc @@ -220,7 +220,7 @@ void CommandLine::InitFromArgv(const StringVector& argv) { AppendSwitchesAndArguments(*this, argv); } -CommandLine::StringType CommandLine::command_line_string() const { +CommandLine::StringType CommandLine::GetCommandLineString() const { StringType string(argv_[0]); #if defined(OS_WIN) string = QuoteForCommandLineToArgvW(string); diff --git a/base/command_line.h b/base/command_line.h index 802fa0f..3b15e93 100644 --- a/base/command_line.h +++ b/base/command_line.h @@ -79,8 +79,7 @@ class BASE_API CommandLine { // Constructs and returns the represented command line string. // CAUTION! This should be avoided because quoting behavior is unclear. - // TODO(msw): Rename GetCommandLineString. - StringType command_line_string() const; + StringType GetCommandLineString() const; // Returns the original command line string as a vector of strings. const StringVector& argv() const { return argv_; } diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc index 3f949e5..80874ac 100644 --- a/base/command_line_unittest.cc +++ b/base/command_line_unittest.cc @@ -42,7 +42,7 @@ TEST(CommandLineTest, CommandLineConstructor) { FILE_PATH_LITERAL("unquoted arg-with-space")}; CommandLine cl(arraysize(argv), argv); - EXPECT_FALSE(cl.command_line_string().empty()); + EXPECT_FALSE(cl.GetCommandLineString().empty()); EXPECT_FALSE(cl.HasSwitch("cruller")); EXPECT_FALSE(cl.HasSwitch("flim")); EXPECT_FALSE(cl.HasSwitch("program")); @@ -103,7 +103,7 @@ TEST(CommandLineTest, CommandLineFromString) { L"-- -- --not-a-switch " L"\"in the time of submarines...\""); - EXPECT_FALSE(cl.command_line_string().empty()); + EXPECT_FALSE(cl.GetCommandLineString().empty()); EXPECT_FALSE(cl.HasSwitch("cruller")); EXPECT_FALSE(cl.HasSwitch("flim")); EXPECT_FALSE(cl.HasSwitch("program")); @@ -151,8 +151,8 @@ TEST(CommandLineTest, CommandLineFromString) { EXPECT_TRUE(iter == args.end()); // Check that a generated string produces an equivalent command line. - CommandLine cl_duplicate = CommandLine::FromString(cl.command_line_string()); - EXPECT_EQ(cl.command_line_string(), cl_duplicate.command_line_string()); + CommandLine cl_duplicate = CommandLine::FromString(cl.GetCommandLineString()); + EXPECT_EQ(cl.GetCommandLineString(), cl_duplicate.GetCommandLineString()); #endif } @@ -160,13 +160,13 @@ TEST(CommandLineTest, CommandLineFromString) { TEST(CommandLineTest, EmptyString) { #if defined(OS_WIN) CommandLine cl_from_string = CommandLine::FromString(L""); - EXPECT_TRUE(cl_from_string.command_line_string().empty()); + EXPECT_TRUE(cl_from_string.GetCommandLineString().empty()); EXPECT_TRUE(cl_from_string.GetProgram().empty()); EXPECT_EQ(1U, cl_from_string.argv().size()); EXPECT_TRUE(cl_from_string.GetArgs().empty()); #endif CommandLine cl_from_argv(0, NULL); - EXPECT_TRUE(cl_from_argv.command_line_string().empty()); + EXPECT_TRUE(cl_from_argv.GetCommandLineString().empty()); EXPECT_TRUE(cl_from_argv.GetProgram().empty()); EXPECT_EQ(1U, cl_from_argv.argv().size()); EXPECT_TRUE(cl_from_argv.GetArgs().empty()); @@ -209,7 +209,7 @@ TEST(CommandLineTest, AppendSwitches) { L"--switch3=\"a value with spaces\" " L"--switch4=\"\\\"a value with quotes\\\"\" " L"--quotes=\"" + kTrickyQuoted + L"\"", - cl.command_line_string()); + cl.GetCommandLineString()); #endif } @@ -225,7 +225,7 @@ TEST(CommandLineTest, AppendSwitchesDashDash) { cl.AppendArg("--arg2"); EXPECT_EQ(FILE_PATH_LITERAL("prog --switch1 --switch2=foo -- --arg1 --arg2"), - cl.command_line_string()); + cl.GetCommandLineString()); CommandLine::StringVector cl_argv = cl.argv(); EXPECT_EQ(FILE_PATH_LITERAL("prog"), cl_argv[0]); EXPECT_EQ(FILE_PATH_LITERAL("--switch1"), cl_argv[1]); @@ -246,7 +246,7 @@ TEST(CommandLineTest, AppendArguments) { CommandLine cl2(CommandLine::NO_PROGRAM); cl2.AppendArguments(cl1, true); EXPECT_EQ(cl1.GetProgram().value(), cl2.GetProgram().value()); - EXPECT_EQ(cl1.command_line_string(), cl2.command_line_string()); + EXPECT_EQ(cl1.GetCommandLineString(), cl2.GetCommandLineString()); CommandLine c1(FilePath(FILE_PATH_LITERAL("Program1"))); c1.AppendSwitch("switch1"); @@ -260,7 +260,7 @@ TEST(CommandLineTest, AppendArguments) { } #if defined(OS_WIN) -// Make sure that program paths of command_line_string are quoted as necessary. +// Make sure that the command line string program paths are quoted as necessary. // This only makes sense on Windows and the test is basically here to guard // against regressions. TEST(CommandLineTest, ProgramQuotes) { @@ -268,7 +268,7 @@ TEST(CommandLineTest, ProgramQuotes) { const FilePath kProgram(L"Program"); CommandLine cl_program(kProgram); EXPECT_EQ(kProgram.value(), cl_program.GetProgram().value()); - EXPECT_EQ(kProgram.value(), cl_program.command_line_string()); + EXPECT_EQ(kProgram.value(), cl_program.GetCommandLineString()); const FilePath kProgramPath(L"Program Path"); @@ -277,7 +277,7 @@ TEST(CommandLineTest, ProgramQuotes) { EXPECT_EQ(kProgramPath.value(), cl_program_path.GetProgram().value()); // Check that quotes are added to command line string paths containing spaces. - CommandLine::StringType cmd_string(cl_program_path.command_line_string()); + CommandLine::StringType cmd_string(cl_program_path.GetCommandLineString()); CommandLine::StringType program_string(cl_program_path.GetProgram().value()); EXPECT_EQ('"', cmd_string[0]); EXPECT_EQ(program_string, cmd_string.substr(1, program_string.length())); diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc index c2200db..3b05d03 100644 --- a/base/process_util_unittest.cc +++ b/base/process_util_unittest.cc @@ -389,7 +389,7 @@ TEST_F(ProcessUtilTest, LaunchAsUser) { base::UserTokenHandle token; ASSERT_TRUE(OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &token)); std::wstring cmdline = - this->MakeCmdLine("SimpleChildProcess", false).command_line_string(); + this->MakeCmdLine("SimpleChildProcess", false).GetCommandLineString(); base::LaunchOptions options; options.as_user = token; EXPECT_TRUE(base::LaunchProcess(cmdline, options, NULL)); diff --git a/base/process_util_win.cc b/base/process_util_win.cc index 9aa7f44..8a2eafe 100644 --- a/base/process_util_win.cc +++ b/base/process_util_win.cc @@ -271,7 +271,7 @@ bool LaunchProcess(const string16& cmdline, bool LaunchProcess(const CommandLine& cmdline, const LaunchOptions& options, ProcessHandle* process_handle) { - return LaunchProcess(cmdline.command_line_string(), options, process_handle); + return LaunchProcess(cmdline.GetCommandLineString(), options, process_handle); } // Attempts to kill the process identified by the given process @@ -317,7 +317,8 @@ bool GetAppOutput(const CommandLine& cl, std::string* output) { return false; } - // Now create the child process + std::wstring writable_command_line_string(cl.GetCommandLineString()); + PROCESS_INFORMATION proc_info = { 0 }; STARTUPINFO start_info = { 0 }; @@ -330,7 +331,7 @@ bool GetAppOutput(const CommandLine& cl, std::string* output) { // Create the child process. if (!CreateProcess(NULL, - const_cast<wchar_t*>(cl.command_line_string().c_str()), + &writable_command_line_string[0], NULL, NULL, TRUE, // Handles are inherited. 0, NULL, NULL, &start_info, &proc_info)) { diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc index 3b45594..dff8ad0 100644 --- a/chrome/app/chrome_main.cc +++ b/chrome/app/chrome_main.cc @@ -608,7 +608,7 @@ int ChromeMain(int argc, char** argv) { #if defined(OS_WIN) // Must do this before any other usage of command line! - if (HasDeprecatedArguments(command_line.command_line_string())) + if (HasDeprecatedArguments(command_line.GetCommandLineString())) return 1; #endif diff --git a/chrome/browser/about_flags_unittest.cc b/chrome/browser/about_flags_unittest.cc index 21a85cb..180e46f 100644 --- a/chrome/browser/about_flags_unittest.cc +++ b/chrome/browser/about_flags_unittest.cc @@ -250,8 +250,7 @@ TEST_F(AboutFlagsTest, CheckValues) { // Convert the flags to switches. ConvertFlagsToSwitches(&prefs_, &command_line); EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); - EXPECT_EQ(std::string(""), - command_line.GetSwitchValueASCII(kSwitch1)); + EXPECT_EQ(std::string(""), command_line.GetSwitchValueASCII(kSwitch1)); EXPECT_TRUE(command_line.HasSwitch(kSwitch2)); EXPECT_EQ(std::string(kValueForSwitch2), command_line.GetSwitchValueASCII(kSwitch2)); @@ -262,11 +261,11 @@ TEST_F(AboutFlagsTest, CheckValues) { std::string("="); #if defined(OS_WIN) EXPECT_EQ(std::wstring::npos, - command_line.command_line_string().find( + command_line.GetCommandLineString().find( ASCIIToWide(switch1_with_equals))); #else EXPECT_EQ(std::string::npos, - command_line.command_line_string().find(switch1_with_equals)); + command_line.GetCommandLineString().find(switch1_with_equals)); #endif // And confirm there is a '=' for switches with values. @@ -275,11 +274,11 @@ TEST_F(AboutFlagsTest, CheckValues) { std::string("="); #if defined(OS_WIN) EXPECT_NE(std::wstring::npos, - command_line.command_line_string().find( + command_line.GetCommandLineString().find( ASCIIToWide(switch2_with_equals))); #else EXPECT_NE(std::string::npos, - command_line.command_line_string().find(switch2_with_equals)); + command_line.GetCommandLineString().find(switch2_with_equals)); #endif // And it should persist diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 378072a..a150ee0 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -2619,7 +2619,7 @@ void TestingAutomationProvider::GetBrowserInfo( properties->SetString("HelperProcessExecutablePath", chrome::kHelperProcessExecutablePath); properties->SetString("command_line_string", - CommandLine::ForCurrentProcess()->command_line_string()); + CommandLine::ForCurrentProcess()->GetCommandLineString()); FilePath dumps_path; PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path); properties->SetString("DIR_CRASH_DUMPS", dumps_path.value()); diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 8b6f8ae..65c1d08 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -1136,7 +1136,7 @@ std::string AboutVersionStrings(DictionaryValue* localized_strings, #if defined(OS_WIN) localized_strings->SetString("command_line", - WideToUTF16(CommandLine::ForCurrentProcess()->command_line_string())); + WideToUTF16(CommandLine::ForCurrentProcess()->GetCommandLineString())); #elif defined(OS_POSIX) std::string command_line = ""; typedef std::vector<std::string> ArgvList; diff --git a/chrome/browser/browser_main_win.cc b/chrome/browser/browser_main_win.cc index 0f52bea..8a27a79 100644 --- a/chrome/browser/browser_main_win.cc +++ b/chrome/browser/browser_main_win.cc @@ -199,7 +199,7 @@ void RegisterApplicationRestart(const CommandLine& parsed_command_line) { command_line.AppendArguments(parsed_command_line, false); if (!command_line.HasSwitch(switches::kRestoreLastSession)) command_line.AppendSwitch(switches::kRestoreLastSession); - if (command_line.command_line_string().length() > RESTART_MAX_CMD_LINE) { + if (command_line.GetCommandLineString().length() > RESTART_MAX_CMD_LINE) { LOG(WARNING) << "Command line too long for RegisterApplicationRestart"; return; } @@ -207,7 +207,7 @@ void RegisterApplicationRestart(const CommandLine& parsed_command_line) { // Restart Chrome if the computer is restarted as the result of an update. // This could be extended to handle crashes, hangs, and patches. HRESULT hr = register_application_restart( - command_line.command_line_string().c_str(), + command_line.GetCommandLineString().c_str(), RESTART_NO_CRASH | RESTART_NO_HANG | RESTART_NO_PATCH); DCHECK(SUCCEEDED(hr)) << "RegisterApplicationRestart failed."; } diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index 28644d5..4623533 100644 --- a/chrome/browser/chromeos/login/login_utils.cc +++ b/chrome/browser/chromeos/login/login_utils.cc @@ -543,7 +543,7 @@ std::string LoginUtilsImpl::GetOffTheRecordCommandLine( switches::kHomePage, GURL(chrome::kChromeUINewTabURL).spec()); - std::string cmd_line_str = command_line->command_line_string(); + std::string cmd_line_str = command_line->GetCommandLineString(); // Special workaround for the arguments that should be quoted. // Copying switches won't be needed when Guest mode won't need restart // http://crosbug.com/6924 diff --git a/chrome/browser/chromeos/system/name_value_pairs_parser.cc b/chrome/browser/chromeos/system/name_value_pairs_parser.cc index 700ebac..f7a4683 100644 --- a/chrome/browser/chromeos/system/name_value_pairs_parser.cc +++ b/chrome/browser/chromeos/system/name_value_pairs_parser.cc @@ -72,7 +72,7 @@ bool NameValuePairsParser::GetSingleValueFromTool(int argc, // TODO(stevenjb,satorux): Make this non blocking: crosbug.com/5603. base::ThreadRestrictions::ScopedAllowIO allow_io_for_thread_join; if (argc < 1 || !base::GetAppOutput(command_line, &output_string)) { - LOG(WARNING) << "Error excuting: " << command_line.command_line_string(); + LOG(WARNING) << "Error excuting: " << command_line.GetCommandLineString(); return false; } TrimWhitespaceASCII(output_string, TRIM_ALL, &output_string); @@ -90,12 +90,12 @@ bool NameValuePairsParser::ParseNameValuePairsFromTool( // TODO(stevenjb,satorux): Make this non blocking: crosbug.com/5603. base::ThreadRestrictions::ScopedAllowIO allow_io_for_thread_join; if (argc < 1 || !base::GetAppOutput(command_line, &output_string)) { - LOG(WARNING) << "Error excuting: " << command_line.command_line_string(); + LOG(WARNING) << "Error excuting: " << command_line.GetCommandLineString(); return false; } if (!ParseNameValuePairs(output_string, eq, delim)) { LOG(WARNING) << "Error parsing values while excuting: " - << command_line.command_line_string(); + << command_line.GetCommandLineString(); return false; } return true; diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc index 577ccf5..1336ee6 100644 --- a/chrome/browser/jumplist_win.cc +++ b/chrome/browser/jumplist_win.cc @@ -430,7 +430,7 @@ bool UpdateJumpList(const wchar_t* app_id, if (!user_data_dir.empty()) command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir); - std::wstring chrome_switches = command_line.command_line_string(); + std::wstring chrome_switches = command_line.GetCommandLineString(); // We allocate 60% of the given JumpList slots to "most-visited" items // and 40% to "recently-closed" items, respectively. diff --git a/chrome/browser/safe_browsing/safe_browsing_test.cc b/chrome/browser/safe_browsing/safe_browsing_test.cc index 9ee6b9a..826db15 100644 --- a/chrome/browser/safe_browsing/safe_browsing_test.cc +++ b/chrome/browser/safe_browsing/safe_browsing_test.cc @@ -151,7 +151,7 @@ class SafeBrowsingTestServer { #endif if (!base::LaunchProcess(cmd_line, options, &server_handle_)) { LOG(ERROR) << "Failed to launch server: " - << cmd_line.command_line_string(); + << cmd_line.GetCommandLineString(); return false; } return true; diff --git a/chrome/browser/ui/webui/gpu_internals_ui.cc b/chrome/browser/ui/webui/gpu_internals_ui.cc index 09a01ed..ba902f9 100644 --- a/chrome/browser/ui/webui/gpu_internals_ui.cc +++ b/chrome/browser/ui/webui/gpu_internals_ui.cc @@ -467,7 +467,7 @@ Value* GpuMessageHandler::OnRequestClientInfo(const ListValue* list) { IDS_ABOUT_VERSION_UNOFFICIAL)); dict->SetString("command_line", - CommandLine::ForCurrentProcess()->command_line_string()); + CommandLine::ForCurrentProcess()->GetCommandLineString()); } dict->SetString("blacklist_version", diff --git a/chrome/browser/ui/webui/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals_ui.cc index a4341b2..a742d02 100644 --- a/chrome/browser/ui/webui/net_internals_ui.cc +++ b/chrome/browser/ui/webui/net_internals_ui.cc @@ -1503,7 +1503,7 @@ Value* NetInternalsUI::GetConstants() { "unofficial"); dict->SetString("os_type", version_info.OSType()); dict->SetString("command_line", - CommandLine::ForCurrentProcess()->command_line_string()); + CommandLine::ForCurrentProcess()->GetCommandLineString()); } constants_dict->Set("clientInfo", dict); diff --git a/chrome/browser/ui/webui/options/about_page_handler.cc b/chrome/browser/ui/webui/options/about_page_handler.cc index e50e008..3ca941e 100644 --- a/chrome/browser/ui/webui/options/about_page_handler.cc +++ b/chrome/browser/ui/webui/options/about_page_handler.cc @@ -241,7 +241,7 @@ void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { #if defined(OS_WIN) localized_strings->SetString("command_line_info", - WideToUTF16(CommandLine::ForCurrentProcess()->command_line_string())); + WideToUTF16(CommandLine::ForCurrentProcess()->GetCommandLineString())); #elif defined(OS_POSIX) // TODO(viettrungluu): something horrible might happen if there are non-UTF-8 // arguments (since |SetString()| requires Unicode). diff --git a/chrome/browser/ui/webui/options/options_ui.cc b/chrome/browser/ui/webui/options/options_ui.cc index b8eb577..538bf41 100644 --- a/chrome/browser/ui/webui/options/options_ui.cc +++ b/chrome/browser/ui/webui/options/options_ui.cc @@ -300,10 +300,11 @@ void OptionsUI::RenderViewCreated(RenderViewHost* render_view_host) { std::string command_line_string; #if defined(OS_WIN) - std::wstring wstr = CommandLine::ForCurrentProcess()->command_line_string(); + std::wstring wstr = CommandLine::ForCurrentProcess()->GetCommandLineString(); command_line_string = WideToASCII(wstr); #else - command_line_string = CommandLine::ForCurrentProcess()->command_line_string(); + command_line_string = + CommandLine::ForCurrentProcess()->GetCommandLineString(); #endif render_view_host->SetWebUIProperty("commandLineString", command_line_string); diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc index cbae635..65ffafe 100644 --- a/chrome/browser/web_applications/web_app.cc +++ b/chrome/browser/web_applications/web_app.cc @@ -334,7 +334,7 @@ bool CreateShortcutTask::CreateShortcut() { // properly quoted for a Windows command line. The method on // CommandLine should probably be renamed to better reflect that // fact. - std::wstring wide_switches(cmd_line.command_line_string()); + std::wstring wide_switches(cmd_line.GetCommandLineString()); // Sanitize description if (shortcut_info_.description.length() >= MAX_PATH) diff --git a/chrome/common/service_process_util_linux.cc b/chrome/common/service_process_util_linux.cc index fe3d04f..ab5957e 100644 --- a/chrome/common/service_process_util_linux.cc +++ b/chrome/common/service_process_util_linux.cc @@ -101,7 +101,7 @@ bool ServiceProcessState::AddToAutoRun() { return AutoStart::AddApplication( GetServiceProcessScopedName(GetBaseDesktopName()), app_name, - autorun_command_line_->command_line_string(), + autorun_command_line_->GetCommandLineString(), false); } diff --git a/chrome/common/service_process_util_win.cc b/chrome/common/service_process_util_win.cc index 1050f1e..2d5db85 100644 --- a/chrome/common/service_process_util_win.cc +++ b/chrome/common/service_process_util_win.cc @@ -153,7 +153,7 @@ bool ServiceProcessState::AddToAutoRun() { return base::win::AddCommandToAutoRun( HKEY_CURRENT_USER, UTF8ToWide(GetServiceProcessAutoRunKey()), - autorun_command_line_->command_line_string()); + autorun_command_line_->GetCommandLineString()); } bool ServiceProcessState::RemoveFromAutoRun() { diff --git a/chrome/common/switch_utils_unittest.cc b/chrome/common/switch_utils_unittest.cc index 49f2c38..74bc8af 100644 --- a/chrome/common/switch_utils_unittest.cc +++ b/chrome/common/switch_utils_unittest.cc @@ -20,7 +20,7 @@ TEST(SwitchUtilsTest, RemoveSwitches) { FILE_PATH_LITERAL("--foo"), FILE_PATH_LITERAL("--bar")}; CommandLine cmd_line(arraysize(argv), argv); - EXPECT_FALSE(cmd_line.command_line_string().empty()); + EXPECT_FALSE(cmd_line.GetCommandLineString().empty()); std::map<std::string, CommandLine::StringType> switches = cmd_line.GetSwitches(); @@ -45,7 +45,7 @@ TEST(SwitchUtilsTest, RemoveSwitchesFromString) { L" --make-default-browser" L" --foo" L" --bar"); - EXPECT_FALSE(cmd_line.command_line_string().empty()); + EXPECT_FALSE(cmd_line.GetCommandLineString().empty()); std::map<std::string, CommandLine::StringType> switches = cmd_line.GetSwitches(); diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc index 720e346..5a619f0 100644 --- a/chrome/installer/setup/install.cc +++ b/chrome/installer/setup/install.cc @@ -167,7 +167,7 @@ bool CreateOrUpdateChromeShortcuts(const InstallerState& installer_state, ret = file_util::CreateShortcutLink(setup_exe.value().c_str(), uninstall_link.value().c_str(), NULL, - arguments.command_line_string().c_str(), + arguments.GetCommandLineString().c_str(), NULL, setup_exe.value().c_str(), 0, diff --git a/chrome/installer/setup/install_worker.cc b/chrome/installer/setup/install_worker.cc index 8027f43..60c0127 100644 --- a/chrome/installer/setup/install_worker.cc +++ b/chrome/installer/setup/install_worker.cc @@ -158,13 +158,13 @@ void AddUninstallShortcutWorkItems(const InstallerState& installer_state, installer::kUninstallStringField, installer_path.value(), true); install_list->AddSetRegValueWorkItem(reg_root, update_state_key, installer::kUninstallArgumentsField, - uninstall_arguments.command_line_string(), true); + uninstall_arguments.GetCommandLineString(), true); // MSI installations will manage their own uninstall shortcuts. if (!installer_state.is_msi() && product.ShouldCreateUninstallEntry()) { // We need to quote the command line for the Add/Remove Programs dialog. CommandLine quoted_uninstall_cmd(installer_path); - DCHECK_EQ(quoted_uninstall_cmd.command_line_string()[0], '"'); + DCHECK_EQ(quoted_uninstall_cmd.GetCommandLineString()[0], '"'); quoted_uninstall_cmd.AppendArguments(uninstall_arguments, false); std::wstring uninstall_reg = browser_dist->GetUninstallRegPath(); @@ -174,7 +174,7 @@ void AddUninstallShortcutWorkItems(const InstallerState& installer_state, browser_dist->GetAppShortCutName(), true); install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, installer::kUninstallStringField, - quoted_uninstall_cmd.command_line_string(), true); + quoted_uninstall_cmd.GetCommandLineString(), true); install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, L"InstallLocation", @@ -589,7 +589,7 @@ bool AppendPostInstallTasks(const InstallerState& installer_state, root, version_key, google_update::kRegRenameCmdField, - product_rename_cmd.command_line_string(), + product_rename_cmd.GetCommandLineString(), true); } @@ -888,17 +888,17 @@ void AddChromeFrameWorkItems(const InstallationState& original_state, list->AddSetRegValueWorkItem(root, version_key, google_update::kRegCFTempOptOutCmdField, - temp_opt_out.command_line_string(), true); + temp_opt_out.GetCommandLineString(), true); list->AddSetRegValueWorkItem(root, version_key, google_update::kRegCFEndTempOptOutCmdField, - end_temp_opt_out.command_line_string(), + end_temp_opt_out.GetCommandLineString(), true); list->AddSetRegValueWorkItem(root, version_key, google_update::kRegCFOptOutCmdField, - opt_out.command_line_string(), true); + opt_out.GetCommandLineString(), true); list->AddSetRegValueWorkItem(root, version_key, google_update::kRegCFOptInCmdField, - opt_in.command_line_string(), true); + opt_in.GetCommandLineString(), true); } else { // If Chrome is not also being uninstalled, we need to update its command // line so that it doesn't include uninstalling Chrome Frame now. @@ -1196,7 +1196,7 @@ void AddQuickEnableWorkItems(const InstallerState& installer_state, if (installer_state.verbose_logging()) cmd_line.AppendSwitch(switches::kVerboseLogging); cmd_line.AppendSwitch(switches::kChromeFrameQuickEnable); - AppCommand cmd(cmd_line.command_line_string(), true, true); + AppCommand cmd(cmd_line.GetCommandLineString(), true, true); cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); } else { DCHECK(operation == REMOVE_COMMAND); diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index 7300c1e..e180b42 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -1159,7 +1159,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, installer::InitInstallerLogging(prefs); const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); - VLOG(1) << "Command Line: " << cmd_line.command_line_string(); + VLOG(1) << "Command Line: " << cmd_line.GetCommandLineString(); VLOG(1) << "multi install is " << prefs.is_multi_install(); bool system_install = false; diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index 5b8489d..e5efb86 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -767,7 +767,7 @@ void GoogleChromeDistribution::InactiveUserToastExperiment(int flavor, // The command line should now have the url added as: // "chrome.exe -- <url>" DCHECK_NE(std::wstring::npos, - options.command_line_string().find(L" -- " + url)); + options.GetCommandLineString().find(L" -- " + url)); } // Launch chrome now. It will show the toast UI. int32 exit_code = 0; diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index 8406c3b..95bc66c 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -118,7 +118,7 @@ bool InstallUtil::ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code) { DCHECK(!program.empty()); DCHECK_NE(program[0], L'\"'); - CommandLine::StringType params(cmd.command_line_string()); + CommandLine::StringType params(cmd.GetCommandLineString()); if (params[0] == '"') { DCHECK_EQ('"', params[program.length() + 1]); DCHECK_EQ(program, params.substr(1, program.length())); diff --git a/chrome/installer/util/installation_validator.cc b/chrome/installer/util/installation_validator.cc index 5a26b0f..2d109fe 100644 --- a/chrome/installer/util/installation_validator.cc +++ b/chrome/installer/util/installation_validator.cc @@ -390,7 +390,7 @@ void InstallationValidator::ValidateCommandExpectations( << (expectation.second ? " is missing" : " has") << " \"" << expectation.first << "\"" << (expectation.second ? "" : " but shouldn't") << ": " - << command.command_line_string(); + << command.GetCommandLineString(); } } } diff --git a/chrome/installer/util/installation_validator_unittest.cc b/chrome/installer/util/installation_validator_unittest.cc index f404baa..f4ff1e5 100644 --- a/chrome/installer/util/installation_validator_unittest.cc +++ b/chrome/installer/util/installation_validator_unittest.cc @@ -211,7 +211,7 @@ void FakeProductState::AddQuickEnableCfCommand( cmd_line.AppendSwitch(installer::switches::kSystemLevel); cmd_line.AppendSwitch(installer::switches::kChromeFrameQuickEnable); commands_.Set(installer::kCmdQuickEnableCf, - AppCommand(cmd_line.command_line_string(), true, true)); + AppCommand(cmd_line.GetCommandLineString(), true, true)); } // Removes the "quick-enable-cf" Google Update product command. diff --git a/chrome/installer/util/product.cc b/chrome/installer/util/product.cc index eb5286d..63299f1 100644 --- a/chrome/installer/util/product.cc +++ b/chrome/installer/util/product.cc @@ -79,15 +79,14 @@ bool Product::LaunchChromeAndWait(const FilePath& application_path, bool success = false; STARTUPINFOW si = { sizeof(si) }; PROCESS_INFORMATION pi = {0}; - // Cast away constness of the command_line_string() since CreateProcess - // might modify the string (insert \0 to separate the program from the - // arguments). Since we're not using the cmd variable beyond this point - // we don't care. + // Create a writable copy of the command line string, since CreateProcess may + // modify the string (insert \0 to separate the program from the arguments). + std::wstring writable_command_line_string(cmd.GetCommandLineString()); if (!::CreateProcess(cmd.GetProgram().value().c_str(), - const_cast<wchar_t*>(cmd.command_line_string().c_str()), + &writable_command_line_string[0], NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) { - PLOG(ERROR) << "Failed to launch: " << cmd.command_line_string(); + PLOG(ERROR) << "Failed to launch: " << cmd.GetCommandLineString(); } else { ::CloseHandle(pi.hThread); diff --git a/chrome/installer/util/product_state_unittest.cc b/chrome/installer/util/product_state_unittest.cc index ad81ed8..1c8400d 100644 --- a/chrome/installer/util/product_state_unittest.cc +++ b/chrome/installer/util/product_state_unittest.cc @@ -283,7 +283,7 @@ TEST_F(ProductStateTest, InitializeUninstallCommand) { ApplyUninstallCommand(NULL, NULL); EXPECT_TRUE(state.Initialize(system_install_, dist_)); EXPECT_TRUE(state.GetSetupPath().empty()); - EXPECT_TRUE(state.uninstall_command().command_line_string().empty()); + EXPECT_TRUE(state.uninstall_command().GetCommandLineString().empty()); EXPECT_TRUE(state.uninstall_command().GetSwitches().empty()); } @@ -293,7 +293,7 @@ TEST_F(ProductStateTest, InitializeUninstallCommand) { ApplyUninstallCommand(L"", L""); EXPECT_TRUE(state.Initialize(system_install_, dist_)); EXPECT_TRUE(state.GetSetupPath().empty()); - EXPECT_TRUE(state.uninstall_command().command_line_string().empty()); + EXPECT_TRUE(state.uninstall_command().GetCommandLineString().empty()); EXPECT_TRUE(state.uninstall_command().GetSwitches().empty()); } @@ -303,7 +303,8 @@ TEST_F(ProductStateTest, InitializeUninstallCommand) { ApplyUninstallCommand(NULL, L"--uninstall"); EXPECT_TRUE(state.Initialize(system_install_, dist_)); EXPECT_TRUE(state.GetSetupPath().empty()); - EXPECT_EQ(L" --uninstall", state.uninstall_command().command_line_string()); + EXPECT_EQ(L" --uninstall", + state.uninstall_command().GetCommandLineString()); EXPECT_EQ(1U, state.uninstall_command().GetSwitches().size()); } @@ -313,7 +314,7 @@ TEST_F(ProductStateTest, InitializeUninstallCommand) { ApplyUninstallCommand(L"setup.exe", NULL); EXPECT_TRUE(state.Initialize(system_install_, dist_)); EXPECT_EQ(L"setup.exe", state.GetSetupPath().value()); - EXPECT_EQ(L"setup.exe", state.uninstall_command().command_line_string()); + EXPECT_EQ(L"setup.exe", state.uninstall_command().GetCommandLineString()); EXPECT_TRUE(state.uninstall_command().GetSwitches().empty()); } @@ -324,7 +325,7 @@ TEST_F(ProductStateTest, InitializeUninstallCommand) { EXPECT_TRUE(state.Initialize(system_install_, dist_)); EXPECT_EQ(L"set up.exe", state.GetSetupPath().value()); EXPECT_EQ(L"\"set up.exe\"", - state.uninstall_command().command_line_string()); + state.uninstall_command().GetCommandLineString()); EXPECT_TRUE(state.uninstall_command().GetSwitches().empty()); } @@ -335,7 +336,7 @@ TEST_F(ProductStateTest, InitializeUninstallCommand) { EXPECT_TRUE(state.Initialize(system_install_, dist_)); EXPECT_EQ(L"setup.exe", state.GetSetupPath().value()); EXPECT_EQ(L"setup.exe --uninstall", - state.uninstall_command().command_line_string()); + state.uninstall_command().GetCommandLineString()); EXPECT_EQ(1U, state.uninstall_command().GetSwitches().size()); } } diff --git a/chrome/nacl/nacl_main.cc b/chrome/nacl/nacl_main.cc index 6d882d3..fcb5f28 100644 --- a/chrome/nacl/nacl_main.cc +++ b/chrome/nacl/nacl_main.cc @@ -43,7 +43,7 @@ int NaClBrokerMain(const MainFunctionParams& parameters) { const CommandLine& parsed_command_line = parameters.command_line_; DVLOG(1) << "Started NaCL broker with " - << parsed_command_line.command_line_string(); + << parsed_command_line.GetCommandLineString(); // NOTE: this code is duplicated from browser_main.cc // IMPORTANT: This piece of code needs to run as early as possible in the diff --git a/chrome/nacl/nacl_main_platform_delegate_win.cc b/chrome/nacl/nacl_main_platform_delegate_win.cc index 02feff0..75b3dc9 100644 --- a/chrome/nacl/nacl_main_platform_delegate_win.cc +++ b/chrome/nacl/nacl_main_platform_delegate_win.cc @@ -31,7 +31,7 @@ void NaClMainPlatformDelegate::PlatformUninitialize() { void NaClMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { const CommandLine& command_line = parameters_.command_line_; - DVLOG(1) << "Started NaClLdr with " << command_line.command_line_string(); + DVLOG(1) << "Started NaClLdr with " << command_line.GetCommandLineString(); sandbox::TargetServices* target_services = parameters_.sandbox_info_.TargetServices(); diff --git a/chrome/service/service_main.cc b/chrome/service/service_main.cc index 7ddddf8..9242c17 100644 --- a/chrome/service/service_main.cc +++ b/chrome/service/service_main.cc @@ -24,7 +24,7 @@ int ServiceProcessMain(const MainFunctionParams& parameters) { } VLOG(1) << "Service process launched: " - << parameters.command_line_.command_line_string(); + << parameters.command_line_.GetCommandLineString(); #if defined(OS_MACOSX) chrome_application_mac::RegisterCrApp(); diff --git a/chrome_frame/cfproxy_support.cc b/chrome_frame/cfproxy_support.cc index 7fd61b7..4e7d8070 100644 --- a/chrome_frame/cfproxy_support.cc +++ b/chrome_frame/cfproxy_support.cc @@ -300,7 +300,7 @@ std::wstring BuildCmdLine(const std::string& channel_id, command_line->AppendSwitchPath(switches::kUserDataDir, profile_path); - std::wstring command_line_string(command_line->command_line_string()); + std::wstring command_line_string(command_line->GetCommandLineString()); if (!extra_args.empty()) { command_line_string.append(L" "); command_line_string.append(extra_args); diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index 5ba5363..252f8fb 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -291,7 +291,7 @@ void AutomationProxyCacheEntry::CreateProxy(ChromeFrameLaunchParams* params, if (!params->language().empty()) command_line->AppendSwitchNative(switches::kLang, params->language()); - std::wstring command_line_string(command_line->command_line_string()); + std::wstring command_line_string(command_line->GetCommandLineString()); // If there are any extra arguments, append them to the command line. if (!params->extra_arguments().empty()) { command_line_string += L' ' + params->extra_arguments(); diff --git a/chrome_frame/chrome_launcher_unittest.cc b/chrome_frame/chrome_launcher_unittest.cc index caa02c0..0f2db43 100644 --- a/chrome_frame/chrome_launcher_unittest.cc +++ b/chrome_frame/chrome_launcher_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -15,22 +15,22 @@ TEST(ChromeLauncher, IsValidCommandLine) { bad.AppendSwitch(switches::kHomePage); // exists but not in whitelist EXPECT_FALSE(chrome_launcher::IsValidCommandLine( - bad.command_line_string().c_str())); + bad.GetCommandLineString().c_str())); CommandLine good(FilePath(L"dummy.exe")); good.AppendSwitch(switches::kNoFirstRun); // in whitelist good.AppendSwitchASCII(switches::kUserDataDir, "foo"); // in whitelist EXPECT_TRUE(chrome_launcher::IsValidCommandLine( - good.command_line_string().c_str())); + good.GetCommandLineString().c_str())); CommandLine no_params(FilePath(L"dummy.exe")); EXPECT_TRUE(chrome_launcher::IsValidCommandLine( - no_params.command_line_string().c_str())); + no_params.GetCommandLineString().c_str())); CommandLine empty(FilePath(L"")); EXPECT_TRUE(chrome_launcher::IsValidCommandLine( - empty.command_line_string().c_str())); + empty.GetCommandLineString().c_str())); } TEST(ChromeLauncher, TrimWhiteSpace) { diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index 45c610b..b77d94e 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -330,7 +330,7 @@ HRESULT SetupRunOnce() { "0"); run_once_cmd.AppendSwitch(switches::kChromeFrame); ret = run_once.WriteValue(L"A", - run_once_cmd.command_line_string().c_str()); + run_once_cmd.GetCommandLineString().c_str()); } result = HRESULT_FROM_WIN32(ret); } else { diff --git a/cloud_print/virtual_driver/win/install/setup.cc b/cloud_print/virtual_driver/win/install/setup.cc index c9dfe6b..5ea687f 100644 --- a/cloud_print/virtual_driver/win/install/setup.cc +++ b/cloud_print/virtual_driver/win/install/setup.cc @@ -323,4 +323,3 @@ int WINAPI WinMain(__in HINSTANCE hInstance, } return retval; } - diff --git a/content/common/sandbox_policy.cc b/content/common/sandbox_policy.cc index dd0473e..bfa7db1 100644 --- a/content/common/sandbox_policy.cc +++ b/content/common/sandbox_policy.cc @@ -447,7 +447,7 @@ base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line, result = g_broker_services->SpawnTarget( cmd_line->GetProgram().value().c_str(), - cmd_line->command_line_string().c_str(), + cmd_line->GetCommandLineString().c_str(), policy, &target); policy->Release(); diff --git a/content/plugin/plugin_main.cc b/content/plugin/plugin_main.cc index 2dea5e6..63d5d68 100644 --- a/content/plugin/plugin_main.cc +++ b/content/plugin/plugin_main.cc @@ -103,7 +103,7 @@ int PluginMain(const MainFunctionParams& parameters) { CoInitialize(NULL); DVLOG(1) << "Started plugin with " - << parsed_command_line.command_line_string(); + << parsed_command_line.GetCommandLineString(); HMODULE sandbox_test_module = NULL; bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); diff --git a/content/renderer/renderer_main_platform_delegate_win.cc b/content/renderer/renderer_main_platform_delegate_win.cc index 50a8059..dbf5b08 100644 --- a/content/renderer/renderer_main_platform_delegate_win.cc +++ b/content/renderer/renderer_main_platform_delegate_win.cc @@ -94,7 +94,7 @@ void RendererMainPlatformDelegate::PlatformUninitialize() { bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { const CommandLine& command_line = parameters_.command_line_; - DVLOG(1) << "Started renderer with " << command_line.command_line_string(); + DVLOG(1) << "Started renderer with " << command_line.GetCommandLineString(); sandbox::TargetServices* target_services = parameters_.sandbox_info_.TargetServices(); diff --git a/net/test/test_server_posix.cc b/net/test/test_server_posix.cc index 3455694..2efc54f 100644 --- a/net/test/test_server_posix.cc +++ b/net/test/test_server_posix.cc @@ -125,7 +125,7 @@ bool TestServer::LaunchPython(const FilePath& testserver_path) { base::LaunchOptions options; options.fds_to_remap = &map_write_fd; if (!base::LaunchProcess(python_command, options, &process_handle_)) { - LOG(ERROR) << "Failed to launch " << python_command.command_line_string(); + LOG(ERROR) << "Failed to launch " << python_command.GetCommandLineString(); return false; } diff --git a/net/test/test_server_win.cc b/net/test/test_server_win.cc index 96c899e..b01da32 100644 --- a/net/test/test_server_win.cc +++ b/net/test/test_server_win.cc @@ -38,7 +38,7 @@ bool LaunchTestServerAsJob(const CommandLine& cmdline, // automatically associated with a job object created by the debugger. // The CREATE_BREAKAWAY_FROM_JOB flag is used to prevent this. if (!CreateProcess( - NULL, const_cast<wchar_t*>(cmdline.command_line_string().c_str()), + NULL, const_cast<wchar_t*>(cmdline.GetCommandLineString().c_str()), NULL, NULL, TRUE, CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &startup_info, &process_info)) { LOG(ERROR) << "Could not create process."; @@ -183,7 +183,7 @@ bool TestServer::LaunchPython(const FilePath& testserver_path) { true, &process_handle_, &job_handle_)) { - LOG(ERROR) << "Failed to launch " << python_command.command_line_string(); + LOG(ERROR) << "Failed to launch " << python_command.GetCommandLineString(); return false; } diff --git a/net/tools/dump_cache/dump_cache.cc b/net/tools/dump_cache/dump_cache.cc index ee5a50e..59b85f8 100644 --- a/net/tools/dump_cache/dump_cache.cc +++ b/net/tools/dump_cache/dump_cache.cc @@ -71,35 +71,25 @@ int Help() { } // Starts a new process, to generate the files. -int LaunchSlave(const CommandLine& command_line, - const std::wstring& pipe_number, int version) { - // TODO(port): remove this string-munging hackery. - std::wstring hacked_command_line = command_line.command_line_string(); - const std::wstring old_exe(L"dump_cache"); - size_t to_remove = hacked_command_line.find(old_exe); - hacked_command_line.erase(to_remove, old_exe.size()); - +int LaunchSlave(CommandLine command_line, + const std::wstring& pipe_number, + int version) { bool do_upgrade = command_line.HasSwitch(kUpgrade); bool do_convert_to_text = command_line.HasSwitch(kDumpToFiles); - std::wstring new_program; - if (do_upgrade) - new_program = base::StringPrintf(L"%ls%d", L"dump_cache_", version); - else - new_program = base::StringPrintf(L"dump_cache"); - - hacked_command_line.insert(to_remove, new_program); - - CommandLine new_command_line = CommandLine::FromString(hacked_command_line); + if (do_upgrade) { + FilePath program(base::StringPrintf(L"%ls%d", L"dump_cache", version)); + command_line.SetProgram(program); + } if (do_upgrade || do_convert_to_text) - new_command_line.AppendSwitch(kSlave); + command_line.AppendSwitch(kSlave); // TODO(evanm): remove needless usage of wstring from here and elsewhere. - new_command_line.AppendSwitchASCII(kPipe, WideToASCII(pipe_number)); - if (!base::LaunchProcess(new_command_line, base::LaunchOptions(), NULL)) { + command_line.AppendSwitchASCII(kPipe, WideToASCII(pipe_number)); + if (!base::LaunchProcess(command_line, base::LaunchOptions(), NULL)) { printf("Unable to launch the needed version of this tool: %ls\n", - new_program.c_str()); + command_line.GetProgram().value().c_str()); printf(kUpgradeHelp); return TOOL_NOT_FOUND; } |