diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-26 22:39:33 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-26 22:39:33 +0000 |
commit | 51343d5ae5d463fc4f84f4af79b44962a580cd4f (patch) | |
tree | 8d53ff6a0097950f2732ee5376bf0c83297c9c87 /chrome | |
parent | 7b9db43fbc1731cabc985f6e026a07a2ceaafc28 (diff) | |
download | chromium_src-51343d5ae5d463fc4f84f4af79b44962a580cd4f.zip chromium_src-51343d5ae5d463fc4f84f4af79b44962a580cd4f.tar.gz chromium_src-51343d5ae5d463fc4f84f4af79b44962a580cd4f.tar.bz2 |
Remove deprecated CommandLine(std::wstring) ctor.
Add a ctor for creating a CommandLine for carrying arguments;
convert all the users to either that or the FilePath version.
BUG=24672
Review URL: http://codereview.chromium.org/329017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30117 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/chrome_main_uitest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/app_controller_mac.mm | 2 | ||||
-rw-r--r-- | chrome/browser/browser_init_browsertest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/first_run_win.cc | 4 | ||||
-rw-r--r-- | chrome/browser/images_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context_unittest.cc | 17 | ||||
-rw-r--r-- | chrome/browser/process_singleton_win.cc | 3 | ||||
-rw-r--r-- | chrome/browser/shell_integration_win.cc | 3 | ||||
-rw-r--r-- | chrome/browser/user_data_manager.cc | 4 | ||||
-rw-r--r-- | chrome/installer/setup/setup_util_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/installer/util/google_chrome_distribution.cc | 2 | ||||
-rw-r--r-- | chrome/installer/util/shell_util.cc | 3 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy_uitest.cc | 4 | ||||
-rw-r--r-- | chrome/test/reliability/page_load_test.cc | 2 | ||||
-rw-r--r-- | chrome/test/render_view_test.cc | 6 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 13 | ||||
-rw-r--r-- | chrome/tools/crash_service/crash_service.cc | 3 |
18 files changed, 37 insertions, 46 deletions
diff --git a/chrome/app/chrome_main_uitest.cc b/chrome/app/chrome_main_uitest.cc index 48ef39e..ab79407f 100644 --- a/chrome/app/chrome_main_uitest.cc +++ b/chrome/app/chrome_main_uitest.cc @@ -44,7 +44,8 @@ TEST_F(ChromeMainTest, SecondLaunch) { include_testing_id_ = false; use_existing_browser_ = true; - ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed(CommandLine(L""))); + ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed( + CommandLine(CommandLine::ARGUMENTS_ONLY))); ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, action_timeout_ms())); } @@ -55,9 +56,8 @@ TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) { FilePath test_file = test_data_directory_.AppendASCII("empty.html"); - CommandLine command_line(L""); + CommandLine command_line(CommandLine::ARGUMENTS_ONLY); command_line.AppendLooseValue(test_file.ToWStringHack()); - ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed(command_line)); ASSERT_TRUE(automation()->IsURLDisplayed(net::FilePathToFileURL(test_file))); diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index db96e05..fcbdb23 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -573,7 +573,7 @@ browser->window()->Show(); } - CommandLine dummy((std::wstring())); + CommandLine dummy(CommandLine::ARGUMENTS_ONLY); BrowserInit::LaunchWithProfile launch(std::wstring(), dummy); launch.OpenURLsInBrowser(browser, false, urls); } diff --git a/chrome/browser/browser_init_browsertest.cc b/chrome/browser/browser_init_browsertest.cc index f5337f4..5c6d60a 100644 --- a/chrome/browser/browser_init_browsertest.cc +++ b/chrome/browser/browser_init_browsertest.cc @@ -46,7 +46,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenURLsPopup) { ASSERT_EQ(popup->type(), Browser::TYPE_POPUP); ASSERT_EQ(popup, observer.added_browser_); - CommandLine dummy((std::wstring())); + CommandLine dummy(CommandLine::ARGUMENTS_ONLY); BrowserInit::LaunchWithProfile launch(std::wstring(), dummy); // This should create a new window, but re-use the profile from |popup|. If // it used a NULL or invalid profile, it would crash. diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index 44c35c4..45cad68 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -1533,7 +1533,7 @@ TEST(ExtensionsServiceTestSimple, Enabledness) { .AppendASCII(ExtensionsService::kInstallDirectoryName); // By default, we are enabled. - command_line.reset(new CommandLine(L"")); + command_line.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); service = new ExtensionsService(&profile, command_line.get(), profile.GetPrefs(), install_dir, &loop, &loop, false); EXPECT_TRUE(service->extensions_enabled()); @@ -1561,7 +1561,7 @@ TEST(ExtensionsServiceTestSimple, Enabledness) { EXPECT_TRUE(recorder.ready()); recorder.set_ready(false); - command_line.reset(new CommandLine(L"")); + command_line.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); service = new ExtensionsService(&profile, command_line.get(), profile.GetPrefs(), install_dir, &loop, &loop, false); EXPECT_FALSE(service->extensions_enabled()); diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc index 2f608b0..6514d872 100644 --- a/chrome/browser/first_run_win.cc +++ b/chrome/browser/first_run_win.cc @@ -118,7 +118,7 @@ bool LaunchSetupWithParam(const std::string& param, const std::wstring& value, exe_path = exe_path.Append(installer_util::kInstallerDir); exe_path = exe_path.Append(installer_util::kSetupExe); base::ProcessHandle ph; - CommandLine cl(exe_path.ToWStringHack()); + CommandLine cl(exe_path); cl.AppendSwitchWithValue(param, value); if (!base::LaunchApp(cl, false, false, &ph)) return false; @@ -563,7 +563,7 @@ bool DecodeImportParams(const std::wstring& encoded, bool FirstRun::ImportSettings(Profile* profile, int browser_type, int items_to_import, HWND parent_window) { const CommandLine& cmdline = *CommandLine::ForCurrentProcess(); - CommandLine import_cmd(cmdline.program()); + CommandLine import_cmd(cmdline.GetProgram()); // Propagate user data directory switch. if (cmdline.HasSwitch(switches::kUserDataDir)) { import_cmd.AppendSwitchWithValue( diff --git a/chrome/browser/images_uitest.cc b/chrome/browser/images_uitest.cc index a9f7605..054ca6e 100644 --- a/chrome/browser/images_uitest.cc +++ b/chrome/browser/images_uitest.cc @@ -12,7 +12,7 @@ class ImagesTest : public UITest { ImagesTest() : UITest() { FilePath path(test_data_directory_); path = path.AppendASCII("animated-gifs.html"); - launch_arguments_ = CommandLine(L""); + launch_arguments_ = CommandLine(CommandLine::ARGUMENTS_ONLY); launch_arguments_.AppendLooseValue(path.ToWStringHack()); } }; diff --git a/chrome/browser/net/chrome_url_request_context_unittest.cc b/chrome/browser/net/chrome_url_request_context_unittest.cc index e756d79..4b70ca9 100644 --- a/chrome/browser/net/chrome_url_request_context_unittest.cc +++ b/chrome/browser/net/chrome_url_request_context_unittest.cc @@ -14,33 +14,34 @@ #define TEST_DESC(desc) StringPrintf("at line %d <%s>", __LINE__, desc) TEST(ChromeUrlRequestContextTest, CreateProxyConfigTest) { + FilePath unused_path(FILE_PATH_LITERAL("foo.exe")); // Build the input command lines here. - CommandLine empty(L"foo.exe"); - CommandLine no_proxy(L"foo.exe"); + CommandLine empty(unused_path); + CommandLine no_proxy(unused_path); no_proxy.AppendSwitch(switches::kNoProxyServer); - CommandLine no_proxy_extra_params(L"foo.exe"); + CommandLine no_proxy_extra_params(unused_path); no_proxy_extra_params.AppendSwitch(switches::kNoProxyServer); no_proxy_extra_params.AppendSwitchWithValue(switches::kProxyServer, L"http://proxy:8888"); - CommandLine single_proxy(L"foo.exe"); + CommandLine single_proxy(unused_path); single_proxy.AppendSwitchWithValue(switches::kProxyServer, L"http://proxy:8888"); - CommandLine per_scheme_proxy(L"foo.exe"); + CommandLine per_scheme_proxy(unused_path); per_scheme_proxy.AppendSwitchWithValue(switches::kProxyServer, L"http=httpproxy:8888;ftp=ftpproxy:8889"); - CommandLine per_scheme_proxy_bypass(L"foo.exe"); + CommandLine per_scheme_proxy_bypass(unused_path); per_scheme_proxy_bypass.AppendSwitchWithValue(switches::kProxyServer, L"http=httpproxy:8888;ftp=ftpproxy:8889"); per_scheme_proxy_bypass.AppendSwitchWithValue( switches::kProxyBypassList, L".google.com, foo.com:99, 1.2.3.4:22, 127.0.0.1/8"); - CommandLine with_pac_url(L"foo.exe"); + CommandLine with_pac_url(unused_path); with_pac_url.AppendSwitchWithValue(switches::kProxyPacUrl, L"http://wpad/wpad.dat"); with_pac_url.AppendSwitchWithValue( switches::kProxyBypassList, L".google.com, foo.com:99, 1.2.3.4:22, 127.0.0.1/8"); - CommandLine with_auto_detect(L"foo.exe"); + CommandLine with_auto_detect(unused_path); with_auto_detect.AppendSwitch(switches::kProxyAutoDetect); // Inspired from proxy_config_service_win_unittest.cc. diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc index bf048aa..9997efd 100644 --- a/chrome/browser/process_singleton_win.cc +++ b/chrome/browser/process_singleton_win.cc @@ -231,8 +231,7 @@ LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { const std::wstring cmd_line = msg.substr(second_null + 1, third_null - second_null); - CommandLine parsed_command_line(L""); - parsed_command_line.ParseFromString(cmd_line); + CommandLine parsed_command_line = CommandLine::FromString(cmd_line); PrefService* prefs = g_browser_process->local_state(); DCHECK(prefs); diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index cebc421..f52a434 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc @@ -111,8 +111,7 @@ ShellIntegration::DefaultBrowserState ShellIntegration::IsDefaultBrowser() { if (!key.Valid() || !key.ReadValue(L"", &value)) return UNKNOWN_DEFAULT_BROWSER; // Need to normalize path in case it's been munged. - CommandLine command_line(L""); - command_line.ParseFromString(value); + CommandLine command_line = CommandLine::FromString(value); std::wstring short_path; GetShortPathName(command_line.program().c_str(), WriteInto(&short_path, MAX_PATH), MAX_PATH); diff --git a/chrome/browser/user_data_manager.cc b/chrome/browser/user_data_manager.cc index 37aa55c..5e9e0e6 100644 --- a/chrome/browser/user_data_manager.cc +++ b/chrome/browser/user_data_manager.cc @@ -188,8 +188,8 @@ std::wstring UserDataManager::GetUserDataFolderForProfile( void UserDataManager::LaunchChromeForProfile( const std::wstring& profile_name) const { std::wstring user_data_dir = GetUserDataFolderForProfile(profile_name); - std::wstring command; - DeprecatedPathServiceGet(base::FILE_EXE, &command); + FilePath command; + PathService::Get(base::FILE_EXE, &command); CommandLine command_line(command); command_line.AppendSwitch(switches::kEnableUserDataDirProfiles); command_line.AppendSwitchWithValue(switches::kUserDataDir, diff --git a/chrome/installer/setup/setup_util_unittest.cc b/chrome/installer/setup/setup_util_unittest.cc index 44af7fc..e0f87ae 100644 --- a/chrome/installer/setup/setup_util_unittest.cc +++ b/chrome/installer/setup/setup_util_unittest.cc @@ -86,8 +86,7 @@ TEST_F(SetupUtilTest, GetInstallPreferencesTest) { cmd_str.append(L" --create-all-shortcuts"); cmd_str.append(L" --do-not-launch-chrome"); cmd_str.append(L" --alt-desktop-shortcut"); - CommandLine cmd_line(L""); - cmd_line.ParseFromString(cmd_str); + CommandLine cmd_line = CommandLine::FromString(cmd_str); scoped_ptr<DictionaryValue> prefs( setup_util::GetInstallPreferences(cmd_line)); EXPECT_TRUE(prefs.get() != NULL); diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index 3dd8699..e4ee42b 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -105,7 +105,7 @@ int GetDirectoryWriteAgeInHours(const wchar_t* path) { // Launches again this same process with a single switch --|flag|=|value|. // Does not wait for the process to terminate. bool RelaunchSetup(const std::wstring& flag, int value) { - CommandLine cmd_line(CommandLine::ForCurrentProcess()->program()); + CommandLine cmd_line(CommandLine::ForCurrentProcess()->GetProgram()); // TODO: make switches into ASCII. cmd_line.AppendSwitchWithValue(WideToASCII(flag), IntToWString(value)); return base::LaunchApp(cmd_line, false, false, NULL); diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 8e00ba2..6982fa7 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -301,8 +301,7 @@ bool ElevateAndRegisterChrome(const std::wstring& chrome_exe, HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; RegKey key(reg_root, dist->GetUninstallRegPath().c_str()); key.ReadValue(installer_util::kUninstallStringField, &exe_path); - CommandLine command_line(L""); - command_line.ParseFromString(exe_path); + CommandLine command_line = CommandLine::FromString(exe_path); exe_path = command_line.program(); } if (file_util::PathExists(FilePath::FromWStringHack(exe_path))) { diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index a8d29b0..6187dfb 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -389,7 +389,7 @@ class AutomationProxyTest2 : public AutomationProxyVisibleTest { document1_= test_data_directory_.AppendASCII("title1.html"); document2_ = test_data_directory_.AppendASCII("title2.html"); - launch_arguments_ = CommandLine(L""); + launch_arguments_ = CommandLine(CommandLine::ARGUMENTS_ONLY); launch_arguments_.AppendLooseValue(document1_.ToWStringHack()); launch_arguments_.AppendLooseValue(document2_.ToWStringHack()); } @@ -570,7 +570,7 @@ class AutomationProxyTest3 : public UITest { document1_ = document1_.AppendASCII("frame_dom_access.html"); dom_automation_enabled_ = true; - launch_arguments_ = CommandLine(L""); + launch_arguments_ = CommandLine(CommandLine::ARGUMENTS_ONLY); launch_arguments_.AppendLooseValue(document1_.ToWStringHack()); } diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc index a5e6625..4df7423 100644 --- a/chrome/test/reliability/page_load_test.cc +++ b/chrome/test/reliability/page_load_test.cc @@ -726,7 +726,7 @@ void SetPageRange(const CommandLine& parsed_command_line) { // The command line switch may override the default v8 log path. if (parsed_command_line.HasSwitch(switches::kJavaScriptFlags)) { CommandLine v8_command_line( - parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags)); + parsed_command_line.GetSwitchValuePath(switches::kJavaScriptFlags)); if (v8_command_line.HasSwitch(kV8LogFileSwitch)) { g_v8_log_path = FilePath::FromWStringHack( v8_command_line.GetSwitchValue(kV8LogFileSwitch)); diff --git a/chrome/test/render_view_test.cc b/chrome/test/render_view_test.cc index f80c845..ccd7da5 100644 --- a/chrome/test/render_view_test.cc +++ b/chrome/test/render_view_test.cc @@ -61,11 +61,7 @@ void RenderViewTest::LoadHTML(const char* html) { void RenderViewTest::SetUp() { sandbox_init_wrapper_.reset(new SandboxInitWrapper()); -#if defined(OS_WIN) - command_line_.reset(new CommandLine(std::wstring())); -#elif defined(OS_POSIX) - command_line_.reset(new CommandLine(std::vector<std::string>())); -#endif + command_line_.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); params_.reset(new MainFunctionParams(*command_line_, *sandbox_init_wrapper_, NULL)); platform_.reset(new RendererMainPlatformDelegate(*params_)); diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 725092a..e9ca10e 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -97,7 +97,7 @@ const char kEnableErrorDialogs[] = "enable-errdialogs"; UITest::UITest() : testing::Test(), - launch_arguments_(L""), + launch_arguments_(CommandLine::ARGUMENTS_ONLY), expected_errors_(0), expected_crashes_(0), homepage_(L"about:blank"), @@ -257,9 +257,9 @@ static CommandLine* CreatePythonCommandLine() { .Append(FILE_PATH_LITERAL("third_party")) .Append(FILE_PATH_LITERAL("python_24")) .Append(FILE_PATH_LITERAL("python.exe")); - return new CommandLine(python_runtime.ToWStringHack()); + return new CommandLine(python_runtime); #elif defined(OS_POSIX) - return new CommandLine(L"python"); + return new CommandLine(FilePath("python")); #endif } @@ -1010,10 +1010,9 @@ bool UITest::LaunchBrowserHelper(const CommandLine& arguments, bool use_existing_browser, bool wait, base::ProcessHandle* process) { - FilePath command = browser_directory_; - command = command.Append(FilePath::FromWStringHack( - chrome::kBrowserProcessExecutablePath)); - CommandLine command_line(command.ToWStringHack()); + FilePath command = browser_directory_.Append( + FilePath::FromWStringHack(chrome::kBrowserProcessExecutablePath)); + CommandLine command_line(command); // Add any explicit command line flags passed to the process. std::wstring extra_chrome_flags = diff --git a/chrome/tools/crash_service/crash_service.cc b/chrome/tools/crash_service/crash_service.cc index 058c40a..ddc7598 100644 --- a/chrome/tools/crash_service/crash_service.cc +++ b/chrome/tools/crash_service/crash_service.cc @@ -194,8 +194,7 @@ bool CrashService::Initialize(const std::wstring& command_line) { return false; } - CommandLine cmd_line(L""); - cmd_line.ParseFromString(command_line); + CommandLine cmd_line = CommandLine::FromString(command_line); // We can override the send reports quota with a command line switch. if (cmd_line.HasSwitch(kMaxReports)) |