diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-29 23:02:34 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-29 23:02:34 +0000 |
commit | 4f08c83f354cb0c9d2ee5c79c39c1ad08e560cdf (patch) | |
tree | 41963c12afc6c484be43d69d1c31c242ed5b7488 | |
parent | d7ab056d66464c89ba336c4b466a8ad45f2afb6e (diff) | |
download | chromium_src-4f08c83f354cb0c9d2ee5c79c39c1ad08e560cdf.zip chromium_src-4f08c83f354cb0c9d2ee5c79c39c1ad08e560cdf.tar.gz chromium_src-4f08c83f354cb0c9d2ee5c79c39c1ad08e560cdf.tar.bz2 |
CommandLine: add a CopySwitchesFrom() and AppendSwitchPath()
These are two common patterns in Chrome code: copying a
subset of switches from one CommandLine to another, and
appending a FilePath to a CommandLine. This sets me up
to do a lot more deprecation in a follow-up change.
Review URL: http://codereview.chromium.org/3012021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54218 0039d316-1c4b-4281-b951-d872f2087c98
40 files changed, 165 insertions, 222 deletions
diff --git a/base/command_line.cc b/base/command_line.cc index b11902b..19f508a 100644 --- a/base/command_line.cc +++ b/base/command_line.cc @@ -291,10 +291,10 @@ std::string CommandLine::GetSwitchValueASCII( FilePath CommandLine::GetSwitchValuePath( const std::string& switch_string) const { - return FilePath::FromWStringHack(GetSwitchValue(switch_string)); + return FilePath(GetSwitchValueNative(switch_string)); } -std::wstring CommandLine::GetSwitchValue( +CommandLine::StringType CommandLine::GetSwitchValueNative( const std::string& switch_string) const { std::string lowercased_switch(switch_string); #if defined(OS_WIN) @@ -305,18 +305,26 @@ std::wstring CommandLine::GetSwitchValue( switches_.find(lowercased_switch); if (result == switches_.end()) { - return L""; + return CommandLine::StringType(); } else { -#if defined(OS_WIN) return result->second; + } +} + +std::wstring CommandLine::GetSwitchValue( + const std::string& switch_string) const { + // TODO(evanm): deprecate. + CommandLine::StringType value = GetSwitchValueNative(switch_string); +#if defined(OS_WIN) + return value; #else - return base::SysNativeMBToWide(result->second); + return base::SysNativeMBToWide(value); #endif - } } std::wstring CommandLine::GetSwitchValue( const std::wstring& switch_string) const { + // TODO(evanm): deprecate. return GetSwitchValue(WideToASCII(switch_string)); } @@ -377,6 +385,11 @@ void CommandLine::AppendSwitch(const std::string& switch_string) { void CommandLine::AppendSwitchWithValue(const std::string& switch_string, const std::wstring& value_string) { + AppendSwitchNative(switch_string, value_string); +} + +void CommandLine::AppendSwitchNative(const std::string& switch_string, + const std::wstring& value_string) { std::wstring value_string_edit; // NOTE(jhughes): If the value contains a quotation mark at one @@ -433,13 +446,18 @@ void CommandLine::AppendSwitch(const std::string& switch_string) { switches_[switch_string] = ""; } +void CommandLine::AppendSwitchNative(const std::string& switch_string, + const std::string& value) { + argv_.push_back(kSwitchPrefixes[0] + switch_string + + kSwitchValueSeparator + value); + switches_[switch_string] = value; +} + void CommandLine::AppendSwitchWithValue(const std::string& switch_string, const std::wstring& value_string) { + // TODO(evanm): deprecate. std::string mb_value = base::SysWideToNativeMB(value_string); - - argv_.push_back(kSwitchPrefixes[0] + switch_string + - kSwitchValueSeparator + mb_value); - switches_[switch_string] = mb_value; + AppendSwitchNative(switch_string, mb_value); } void CommandLine::AppendLooseValue(const std::wstring& value) { @@ -470,11 +488,27 @@ void CommandLine::PrependWrapper(const std::wstring& wrapper_wide) { #endif +void CommandLine::AppendSwitchPath(const std::string& switch_string, + const FilePath& path) { + AppendSwitchNative(switch_string, path.value()); +} + void CommandLine::AppendSwitchWithValue(const std::string& switch_string, const std::string& value_string) { AppendSwitchWithValue(switch_string, ASCIIToWide(value_string)); } +void CommandLine::CopySwitchesFrom(const CommandLine& source, + const char* const switches[], + size_t count) { + for (size_t i = 0; i < count; ++i) { + if (source.HasSwitch(switches[i])) { + StringType value = source.GetSwitchValueNative(switches[i]); + AppendSwitchNative(switches[i], value); + } + } +} + // private CommandLine::CommandLine() { } diff --git a/base/command_line.h b/base/command_line.h index 7ef83bc..89df392 100644 --- a/base/command_line.h +++ b/base/command_line.h @@ -101,10 +101,9 @@ class CommandLine { // Returns the value associated with the given switch. If the // switch has no value or isn't present, this method returns // the empty string. - // TODO(evanm): move these into command_line.cpp once we've fixed the - // wstringness. std::string GetSwitchValueASCII(const std::string& switch_string) const; FilePath GetSwitchValuePath(const std::string& switch_string) const; + StringType GetSwitchValueNative(const std::string& switch_string) const; // Deprecated versions of the above. std::wstring GetSwitchValue(const std::string& switch_string) const; @@ -156,12 +155,17 @@ class CommandLine { const std::string& switch_string, const std::wstring& value_string); - // Appends the given switch string (preceded by a space and a switch - // prefix) to the given string. + // Append a switch to the command line. void AppendSwitch(const std::string& switch_string); - // Appends the given switch string (preceded by a space and a switch - // prefix) to the given string, with the given value attached. + // Append a switch and value to the command line. + void AppendSwitchPath(const std::string& switch_string, const FilePath& path); + void AppendSwitchNative(const std::string& switch_string, + const StringType& value); + + // Append a switch and value to the command line. + // TODO(evanm): remove all AppendSwitchWithValue() instances. + // TODO(evanm): add an *ASCII() version. void AppendSwitchWithValue(const std::string& switch_string, const std::wstring& value_string); void AppendSwitchWithValue(const std::string& switch_string, @@ -179,6 +183,11 @@ class CommandLine { // "valgrind" or "gdb --args"). void PrependWrapper(const std::wstring& wrapper); + // Copy a set of switches (and their values, if any) from another command + // line. Commonly used when launching a subprocess. + void CopySwitchesFrom(const CommandLine& source, const char* const switches[], + size_t count); + private: friend class InProcessBrowserTest; diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 2a2bc93..82bc172 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -572,8 +572,8 @@ Profile* CreateProfile(const MainFunctionParams& parameters, // TODO(tc): It would be nice to remove the flag we don't want, but that // sounds risky if we parse differently than CommandLineToArgvW. CommandLine new_command_line = parameters.command_line_; - new_command_line.AppendSwitchWithValue(switches::kUserDataDir, - new_user_data_dir.ToWStringHack()); + new_command_line.AppendSwitchPath(switches::kUserDataDir, + new_user_data_dir); base::LaunchApp(new_command_line, false, false, NULL); } #else diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc index 404edd8..dce449d 100644 --- a/chrome/browser/browser_uitest.cc +++ b/chrome/browser/browser_uitest.cc @@ -278,8 +278,7 @@ public: file_util::Delete(tmp_profile_, true); file_util::CreateDirectory(tmp_profile_); - launch_arguments_.AppendSwitchWithValue(switches::kUserDataDir, - tmp_profile_.ToWStringHack()); + launch_arguments_.AppendSwitchPath(switches::kUserDataDir, tmp_profile_); } bool LaunchAppWithProfile() { diff --git a/chrome/browser/configuration_policy_pref_store_unittest.cc b/chrome/browser/configuration_policy_pref_store_unittest.cc index 0762a6f..0cac13f 100644 --- a/chrome/browser/configuration_policy_pref_store_unittest.cc +++ b/chrome/browser/configuration_policy_pref_store_unittest.cc @@ -198,11 +198,11 @@ TEST_F(ConfigurationPolicyPrefStoreTest, TestSettingsProxyConfig) { command_line.AppendSwitch(switches::kNoProxyServer); command_line.AppendSwitch(switches::kProxyAutoDetect); command_line.AppendSwitchWithValue(switches::kProxyPacUrl, - L"http://chromium.org/test.pac"); + "http://chromium.org/test.pac"); command_line.AppendSwitchWithValue(switches::kProxyServer, - L"http://chromium2.org"); + "http://chromium2.org"); command_line.AppendSwitchWithValue(switches::kProxyBypassList, - L"http://chromium3.org"); + "http://chromium3.org"); ConfigurationPolicyPrefStore store(&command_line, NULL); EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); @@ -232,11 +232,11 @@ TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyProxyConfigManualOverride) { command_line.AppendSwitch(switches::kNoProxyServer); command_line.AppendSwitch(switches::kProxyAutoDetect); command_line.AppendSwitchWithValue(switches::kProxyPacUrl, - L"http://chromium.org/test.pac"); + "http://chromium.org/test.pac"); command_line.AppendSwitchWithValue(switches::kProxyServer, - L"http://chromium.org"); + "http://chromium.org"); command_line.AppendSwitchWithValue(switches::kProxyBypassList, - L"http://chromium.org"); + "http://chromium.org"); scoped_ptr<MockConfigurationPolicyProvider> provider( new MockConfigurationPolicyProvider()); diff --git a/chrome/browser/extensions/extension_startup_browsertest.cc b/chrome/browser/extensions/extension_startup_browsertest.cc index 0d056d0..165054d 100644 --- a/chrome/browser/extensions/extension_startup_browsertest.cc +++ b/chrome/browser/extensions/extension_startup_browsertest.cc @@ -60,9 +60,8 @@ class ExtensionStartupTestBase : public InProcessBrowserTest { command_line->AppendSwitch(switches::kDisableExtensions); } - if (!load_extension_.value().empty()) { - command_line->AppendSwitchWithValue(switches::kLoadExtension, - load_extension_.ToWStringHack()); + if (!load_extension_.empty()) { + command_line->AppendSwitchPath(switches::kLoadExtension, load_extension_); command_line->AppendSwitch(switches::kDisableExtensionsFileAccessCheck); } } diff --git a/chrome/browser/extensions/extension_uitest.cc b/chrome/browser/extensions/extension_uitest.cc index 8344d5d..2076949 100644 --- a/chrome/browser/extensions/extension_uitest.cc +++ b/chrome/browser/extensions/extension_uitest.cc @@ -57,10 +57,8 @@ class ExtensionUITest : public ExternalTabUITest { public: explicit ExtensionUITest(const std::string& extension_path) : loop_(MessageLoop::current()) { - FilePath filename(test_data_directory_); - filename = filename.AppendASCII(extension_path); - launch_arguments_.AppendSwitchWithValue(switches::kLoadExtension, - filename.value()); + FilePath filename = test_data_directory_.AppendASCII(extension_path); + launch_arguments_.AppendSwitchPath(switches::kLoadExtension, filename); functions_enabled_.push_back("*"); } diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc index 32866ff..38b5b66 100644 --- a/chrome/browser/first_run_win.cc +++ b/chrome/browser/first_run_win.cc @@ -682,12 +682,13 @@ bool FirstRun::ImportSettings(Profile* profile, int browser_type, HWND parent_window) { const CommandLine& cmdline = *CommandLine::ForCurrentProcess(); CommandLine import_cmd(cmdline.GetProgram()); - // Propagate user data directory switch. - if (cmdline.HasSwitch(switches::kUserDataDir)) { - import_cmd.AppendSwitchWithValue( - switches::kUserDataDir, - cmdline.GetSwitchValueASCII(switches::kUserDataDir)); - } + + const char* kSwitchNames[] = { + switches::kUserDataDir, + switches::kChromeFrame, + switches::kCountry, + }; + import_cmd.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames)); // Since ImportSettings is called before the local state is stored on disk // we pass the language as an argument. GetApplicationLocale checks the @@ -706,15 +707,6 @@ bool FirstRun::ImportSettings(Profile* profile, int browser_type, switches::kImportFromFile, import_bookmarks_path.c_str()); } - if (cmdline.HasSwitch(switches::kChromeFrame)) { - import_cmd.AppendSwitch(switches::kChromeFrame); - } - - if (cmdline.HasSwitch(switches::kCountry)) { - import_cmd.AppendSwitchWithValue(switches::kCountry, - cmdline.GetSwitchValueASCII(switches::kCountry)); - } - // Time to launch the process that is going to do the import. base::ProcessHandle import_process; if (!base::LaunchApp(import_cmd, false, false, &import_process)) diff --git a/chrome/browser/gpu_process_host.cc b/chrome/browser/gpu_process_host.cc index cdf1102..03222fd 100644 --- a/chrome/browser/gpu_process_host.cc +++ b/chrome/browser/gpu_process_host.cc @@ -90,19 +90,15 @@ bool GpuProcessHost::Init() { ASCIIToWide(channel_id())); // Propagate relevant command line switches. - static const char* const switch_names[] = { + static const char* const kSwitchNames[] = { switches::kUseGL, + switches::kDisableLogging, + switches::kEnableLogging, + switches::kGpuStartupDialog, + switches::kLoggingLevel, }; - - for (size_t i = 0; i < arraysize(switch_names); ++i) { - if (browser_command_line.HasSwitch(switch_names[i])) { - cmd_line->AppendSwitchWithValue(switch_names[i], - browser_command_line.GetSwitchValueASCII(switch_names[i])); - } - } - - const CommandLine& browser_cmd_line = *CommandLine::ForCurrentProcess(); - PropagateBrowserCommandLineToGpu(browser_cmd_line, cmd_line); + cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, + arraysize(kSwitchNames)); // If specified, prepend a launcher program to the command line. if (!gpu_launcher.empty()) @@ -215,26 +211,6 @@ void GpuProcessHost::ReplyToRenderer( filter->Send(message); } -void GpuProcessHost::PropagateBrowserCommandLineToGpu( - const CommandLine& browser_cmd, - CommandLine* gpu_cmd) const { - // Propagate the following switches to the GPU process command line (along - // with any associated values) if present in the browser command line. - static const char* const switch_names[] = { - switches::kDisableLogging, - switches::kEnableLogging, - switches::kGpuStartupDialog, - switches::kLoggingLevel, - }; - - for (size_t i = 0; i < arraysize(switch_names); ++i) { - if (browser_cmd.HasSwitch(switch_names[i])) { - gpu_cmd->AppendSwitchWithValue(switch_names[i], - browser_cmd.GetSwitchValueASCII(switch_names[i])); - } - } -} - URLRequestContext* GpuProcessHost::GetRequestContext( uint32 request_id, const ViewHostMsg_Resource_Request& request_data) { diff --git a/chrome/browser/gpu_process_host.h b/chrome/browser/gpu_process_host.h index 662bae8..c81b565 100644 --- a/chrome/browser/gpu_process_host.h +++ b/chrome/browser/gpu_process_host.h @@ -92,12 +92,6 @@ class GpuProcessHost : public BrowserChildProcessHost { void ReplyToRenderer(const IPC::ChannelHandle& channel, ResourceMessageFilter* filter); - // Copies applicable command line switches from the given |browser_cmd| line - // flags to the output |gpu_cmd| line flags. Not all switches will be - // copied over. - void PropagateBrowserCommandLineToGpu(const CommandLine& browser_cmd, - CommandLine* gpu_cmd) const; - // ResourceDispatcherHost::Receiver implementation: virtual URLRequestContext* GetRequestContext( uint32 request_id, diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc index e77b55c..1f434f6 100644 --- a/chrome/browser/jumplist_win.cc +++ b/chrome/browser/jumplist_win.cc @@ -422,10 +422,10 @@ bool UpdateJumpList(const wchar_t* app_id, // Retrieve the command-line switches of this process. CommandLine command_line(CommandLine::ARGUMENTS_ONLY); - std::wstring user_data_dir = CommandLine::ForCurrentProcess()-> - GetSwitchValue(switches::kUserDataDir); + FilePath user_data_dir = CommandLine::ForCurrentProcess()-> + GetSwitchValuePath(switches::kUserDataDir); if (!user_data_dir.empty()) - command_line.AppendSwitchWithValue(switches::kUserDataDir, user_data_dir); + command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir); std::wstring chrome_switches = command_line.command_line_string(); diff --git a/chrome/browser/nacl_host/nacl_broker_host_win.cc b/chrome/browser/nacl_host/nacl_broker_host_win.cc index f479030..2847e85 100644 --- a/chrome/browser/nacl_host/nacl_broker_host_win.cc +++ b/chrome/browser/nacl_host/nacl_broker_host_win.cc @@ -47,8 +47,7 @@ bool NaClBrokerHost::Init() { cmd_line->AppendSwitchWithValue(switches::kProcessType, switches::kNaClBrokerProcess); - cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, - ASCIIToWide(channel_id())); + cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, channel_id()); BrowserChildProcessHost::Launch(FilePath(), cmd_line); return true; diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc index 5c9d9da..dde5cb1 100644 --- a/chrome/browser/nacl_host/nacl_process_host.cc +++ b/chrome/browser/nacl_host/nacl_process_host.cc @@ -134,8 +134,7 @@ bool NaClProcessHost::LaunchSelLdr() { cmd_line->AppendSwitchWithValue(switches::kProcessType, switches::kNaClLoaderProcess); - cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, - ASCIIToWide(channel_id())); + cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, channel_id()); // On Windows we might need to start the broker process to launch a new loader #if defined(OS_WIN) diff --git a/chrome/browser/net/chrome_url_request_context_unittest.cc b/chrome/browser/net/chrome_url_request_context_unittest.cc index 7ba2dff..9f42e7b 100644 --- a/chrome/browser/net/chrome_url_request_context_unittest.cc +++ b/chrome/browser/net/chrome_url_request_context_unittest.cc @@ -25,25 +25,25 @@ TEST(ChromeURLRequestContextTest, CreateProxyConfigTest) { 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"); + "http://proxy:8888"); CommandLine single_proxy(unused_path); single_proxy.AppendSwitchWithValue(switches::kProxyServer, - L"http://proxy:8888"); + "http://proxy:8888"); CommandLine per_scheme_proxy(unused_path); per_scheme_proxy.AppendSwitchWithValue(switches::kProxyServer, - L"http=httpproxy:8888;ftp=ftpproxy:8889"); + "http=httpproxy:8888;ftp=ftpproxy:8889"); CommandLine per_scheme_proxy_bypass(unused_path); per_scheme_proxy_bypass.AppendSwitchWithValue(switches::kProxyServer, - L"http=httpproxy:8888;ftp=ftpproxy:8889"); + "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"); + ".google.com, foo.com:99, 1.2.3.4:22, 127.0.0.1/8"); CommandLine with_pac_url(unused_path); with_pac_url.AppendSwitchWithValue(switches::kProxyPacUrl, - L"http://wpad/wpad.dat"); + "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"); + ".google.com, foo.com:99, 1.2.3.4:22, 127.0.0.1/8"); CommandLine with_auto_detect(unused_path); with_auto_detect.AppendSwitch(switches::kProxyAutoDetect); diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc index 7c2aeb0..d6380cc 100644 --- a/chrome/browser/plugin_process_host.cc +++ b/chrome/browser/plugin_process_host.cc @@ -363,15 +363,14 @@ bool PluginProcessHost::Init(const WebPluginInfo& info, // in process listings using native process management tools. cmd_line->AppendSwitchWithValue(switches::kProcessType, switches::kPluginProcess); - cmd_line->AppendSwitchWithValue(switches::kPluginPath, - info.path.ToWStringHack()); + cmd_line->AppendSwitchPath(switches::kPluginPath, info.path); if (logging::DialogsAreSuppressed()) cmd_line->AppendSwitch(switches::kNoErrorDialogs); // Propagate the following switches to the plugin command line (along with // any associated values) if present in the browser command line - static const char* const switch_names[] = { + static const char* const kSwitchNames[] = { switches::kPluginStartupDialog, switches::kNoSandbox, switches::kSafePlugins, @@ -396,13 +395,8 @@ bool PluginProcessHost::Init(const WebPluginInfo& info, #endif }; - for (size_t i = 0; i < arraysize(switch_names); ++i) { - if (browser_command_line.HasSwitch(switch_names[i])) { - cmd_line->AppendSwitchWithValue( - switch_names[i], - browser_command_line.GetSwitchValueASCII(switch_names[i])); - } - } + cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, + arraysize(kSwitchNames)); // If specified, prepend a launcher program to the command line. if (!plugin_launcher.empty()) @@ -415,13 +409,12 @@ bool PluginProcessHost::Init(const WebPluginInfo& info, } // Gears requires the data dir to be available on startup. - std::wstring data_dir = - PluginService::GetInstance()->GetChromePluginDataDir().ToWStringHack(); + FilePath data_dir = + PluginService::GetInstance()->GetChromePluginDataDir(); DCHECK(!data_dir.empty()); - cmd_line->AppendSwitchWithValue(switches::kPluginDataDir, data_dir); + cmd_line->AppendSwitchPath(switches::kPluginDataDir, data_dir); - cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, - ASCIIToWide(channel_id())); + cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, channel_id()); SetCrashReporterCommandLine(cmd_line); diff --git a/chrome/browser/pref_service_uitest.cc b/chrome/browser/pref_service_uitest.cc index 87dcb2c..2f8f4e0 100644 --- a/chrome/browser/pref_service_uitest.cc +++ b/chrome/browser/pref_service_uitest.cc @@ -49,8 +49,7 @@ class PreferenceServiceTest : public UITest { FILE_ATTRIBUTE_NORMAL)); #endif - launch_arguments_.AppendSwitchWithValue(switches::kUserDataDir, - tmp_profile_.ToWStringHack()); + launch_arguments_.AppendSwitchPath(switches::kUserDataDir, tmp_profile_); } bool LaunchAppWithProfile() { diff --git a/chrome/browser/printing/printing_layout_uitest.cc b/chrome/browser/printing/printing_layout_uitest.cc index db20963..4d35c75 100644 --- a/chrome/browser/printing/printing_layout_uitest.cc +++ b/chrome/browser/printing/printing_layout_uitest.cc @@ -28,10 +28,8 @@ const wchar_t kDocRoot[] = L"chrome/test/data"; class PrintingLayoutTest : public PrintingTest<UITest> { public: PrintingLayoutTest() { - emf_path_ = browser_directory_; - emf_path_ = emf_path_.AppendASCII("metafile_dumps"); - launch_arguments_.AppendSwitchWithValue("debug-print", - L'"' + emf_path_.value() + L'"'); + emf_path_ = browser_directory_.AppendASCII("metafile_dumps"); + launch_arguments_.AppendSwitchPath("debug-print", emf_path_); show_window_ = true; } diff --git a/chrome/browser/process_singleton_uitest.cc b/chrome/browser/process_singleton_uitest.cc index ee8756a..8b7da6b 100644 --- a/chrome/browser/process_singleton_uitest.cc +++ b/chrome/browser/process_singleton_uitest.cc @@ -62,8 +62,7 @@ class ChromeStarter : public base::RefCountedThreadSafe<ChromeStarter> { FilePath user_data_directory; PathService::Get(chrome::DIR_USER_DATA, &user_data_directory); - command_line.AppendSwitchWithValue(switches::kUserDataDir, - user_data_directory.ToWStringHack()); + command_line.AppendSwitchPath(switches::kUserDataDir, user_data_directory); if (first_run) command_line.AppendSwitch(switches::kFirstRun); diff --git a/chrome/browser/profile_import_process_host.cc b/chrome/browser/profile_import_process_host.cc index 84a2684..eaeb6dc 100644 --- a/chrome/browser/profile_import_process_host.cc +++ b/chrome/browser/profile_import_process_host.cc @@ -87,8 +87,7 @@ bool ProfileImportProcessHost::StartProcess() { CommandLine* cmd_line = new CommandLine(exe_path); cmd_line->AppendSwitchWithValue(switches::kProcessType, switches::kProfileImportProcess); - cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, - ASCIIToWide(channel_id())); + cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, channel_id()); SetCrashReporterCommandLine(cmd_line); diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 1f87fca..2506617 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -331,8 +331,7 @@ bool BrowserRenderProcessHost::Init(bool is_extensions_process, if (!renderer_prefix.empty()) cmd_line->PrependWrapper(renderer_prefix); AppendRendererCommandLine(cmd_line); - cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, - ASCIIToWide(channel_id)); + cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, channel_id); // Spawn the child process asynchronously to avoid blocking the UI thread. // As long as there's no renderer prefix, we can use the zygote process @@ -459,7 +458,7 @@ void BrowserRenderProcessHost::AppendRendererCommandLine( // Pass on the browser locale. const std::string locale = g_browser_process->GetApplicationLocale(); - command_line->AppendSwitchWithValue(switches::kLang, ASCIIToWide(locale)); + command_line->AppendSwitchWithValue(switches::kLang, locale); // If we run FieldTrials, we want to pass to their state to the renderer so // that it can act in accordance with each state, or record histograms @@ -475,10 +474,8 @@ void BrowserRenderProcessHost::AppendRendererCommandLine( FilePath user_data_dir = browser_command_line.GetSwitchValuePath(switches::kUserDataDir); - if (!user_data_dir.empty()) - command_line->AppendSwitchWithValue(switches::kUserDataDir, - user_data_dir.value()); + command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); #if defined(OS_CHROMEOS) const std::string& profile = browser_command_line.GetSwitchValueASCII(switches::kProfile); @@ -492,7 +489,7 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( CommandLine* renderer_cmd) const { // Propagate the following switches to the renderer command line (along // with any associated values) if present in the browser command line. - static const char* const switch_names[] = { + static const char* const kSwitchNames[] = { switches::kRendererAssertTest, #if !defined(OFFICIAL_BUILD) switches::kRendererCheckFalseTest, @@ -580,13 +577,8 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( switches::kEnableClickToPlay, switches::kPrelaunchGpuProcess, }; - - for (size_t i = 0; i < arraysize(switch_names); ++i) { - if (browser_cmd.HasSwitch(switch_names[i])) { - renderer_cmd->AppendSwitchWithValue(switch_names[i], - browser_cmd.GetSwitchValueASCII(switch_names[i])); - } - } + renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, + arraysize(kSwitchNames)); // Disable databases in incognito mode. if (profile()->IsOffTheRecord() && diff --git a/chrome/browser/utility_process_host.cc b/chrome/browser/utility_process_host.cc index 857c38d..dbcf94b 100644 --- a/chrome/browser/utility_process_host.cc +++ b/chrome/browser/utility_process_host.cc @@ -80,8 +80,7 @@ bool UtilityProcessHost::StartProcess(const FilePath& exposed_dir) { CommandLine* cmd_line = new CommandLine(exe_path); cmd_line->AppendSwitchWithValue(switches::kProcessType, switches::kUtilityProcess); - cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, - ASCIIToWide(channel_id())); + cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, channel_id()); std::string locale = g_browser_process->GetApplicationLocale(); cmd_line->AppendSwitchWithValue(switches::kLang, locale); @@ -114,8 +113,7 @@ bool UtilityProcessHost::StartProcess(const FilePath& exposed_dir) { switches::kUtilityCmdPrefix)); } - cmd_line->AppendSwitchWithValue(switches::kUtilityProcessAllowedDir, - exposed_dir.value().c_str()); + cmd_line->AppendSwitchPath(switches::kUtilityProcessAllowedDir, exposed_dir); #endif Launch( diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc index 762a0c5..f995cbd 100644 --- a/chrome/browser/worker_host/worker_process_host.cc +++ b/chrome/browser/worker_host/worker_process_host.cc @@ -107,8 +107,7 @@ bool WorkerProcessHost::Init() { CommandLine* cmd_line = new CommandLine(exe_path); cmd_line->AppendSwitchWithValue(switches::kProcessType, switches::kWorkerProcess); - cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, - ASCIIToWide(channel_id())); + cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, channel_id()); SetCrashReporterCommandLine(cmd_line); if (CommandLine::ForCurrentProcess()->HasSwitch( @@ -140,8 +139,7 @@ bool WorkerProcessHost::Init() { const std::wstring level = CommandLine::ForCurrentProcess()->GetSwitchValue( switches::kLoggingLevel); - cmd_line->AppendSwitchWithValue( - switches::kLoggingLevel, level); + cmd_line->AppendSwitchWithValue(switches::kLoggingLevel, level); } if (CommandLine::ForCurrentProcess()->HasSwitch( diff --git a/chrome/browser/zygote_host_linux.cc b/chrome/browser/zygote_host_linux.cc index 49c93c2..983e2ce 100644 --- a/chrome/browser/zygote_host_linux.cc +++ b/chrome/browser/zygote_host_linux.cc @@ -96,16 +96,9 @@ void ZygoteHost::Init(const std::string& sandbox_cmd) { #else switches::kEnableSeccompSandbox, #endif - NULL }; - for (const char** sw = kForwardSwitches; *sw; sw++) { - if (browser_command_line.HasSwitch(*sw)) { - // Always append with value for those switches which need it; it does no - // harm for those which don't. - cmd_line.AppendSwitchWithValue(*sw, - browser_command_line.GetSwitchValueASCII(*sw)); - } - } + cmd_line.CopySwitchesFrom(browser_command_line, kForwardSwitches, + arraysize(kForwardSwitches)); sandbox_binary_ = sandbox_cmd.c_str(); struct stat st; diff --git a/chrome/common/nacl_cmd_line.cc b/chrome/common/nacl_cmd_line.cc index a54f196..82c2634 100644 --- a/chrome/common/nacl_cmd_line.cc +++ b/chrome/common/nacl_cmd_line.cc @@ -16,7 +16,7 @@ namespace nacl { // Propagate the following switches to the NaCl loader command line (along // with any associated values) if present in the browser command line. // TODO(gregoryd): check which flags of those below can be supported. - static const char* const switch_names[] = { + static const char* const kSwitchNames[] = { switches::kNoSandbox, switches::kTestNaClSandbox, switches::kDisableBreakpad, @@ -28,13 +28,7 @@ namespace nacl { switches::kSilentDumpOnDCHECK, switches::kMemoryProfiling, }; - - for (size_t i = 0; i < arraysize(switch_names); ++i) { - if (browser_command_line.HasSwitch(switch_names[i])) { - cmd_line->AppendSwitchWithValue( - switch_names[i], - browser_command_line.GetSwitchValueASCII(switch_names[i])); - } - } + cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, + arraysize(kSwitchNames)); } } diff --git a/chrome/renderer/renderer_main_unittest.cc b/chrome/renderer/renderer_main_unittest.cc index a63b0a6..4b561f8 100644 --- a/chrome/renderer/renderer_main_unittest.cc +++ b/chrome/renderer/renderer_main_unittest.cc @@ -79,7 +79,7 @@ MULTIPROCESS_TEST_MAIN(SimpleRenderer) { SandboxInitWrapper dummy_sandbox_init; CommandLine cl(*CommandLine::ForCurrentProcess()); cl.AppendSwitchWithValue(switches::kProcessChannelID, - ASCIIToWide(kRendererTestChannelName)); + kRendererTestChannelName); MainFunctionParams dummy_params(cl, dummy_sandbox_init, NULL); return RendererMain(dummy_params); diff --git a/chrome/service/service_utility_process_host.cc b/chrome/service/service_utility_process_host.cc index e465eb2..3776bc0 100644 --- a/chrome/service/service_utility_process_host.cc +++ b/chrome/service/service_utility_process_host.cc @@ -83,8 +83,7 @@ bool ServiceUtilityProcessHost::StartProcess() { CommandLine cmd_line(exe_path); cmd_line.AppendSwitchWithValue(switches::kProcessType, switches::kUtilityProcess); - cmd_line.AppendSwitchWithValue(switches::kProcessChannelID, - ASCIIToWide(channel_id())); + cmd_line.AppendSwitchWithValue(switches::kProcessChannelID, channel_id()); cmd_line.AppendSwitch(switches::kLang); return Launch(&cmd_line); diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index ccdff3f..a16ac12 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -45,7 +45,7 @@ class AutomationProxyTest : public UITest { AutomationProxyTest() { dom_automation_enabled_ = true; launch_arguments_.AppendSwitchWithValue(switches::kLang, - L"en-US"); + "en-US"); } }; diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc index 0cbb39d..b8b8d90 100644 --- a/chrome/test/in_process_browser_test.cc +++ b/chrome/test/in_process_browser_test.cc @@ -136,15 +136,13 @@ void InProcessBrowserTest::SetUp() { // Turn off tip loading for tests; see http://crbug.com/17725 command_line->AppendSwitch(switches::kDisableWebResources); - command_line->AppendSwitchWithValue(switches::kUserDataDir, - user_data_dir.ToWStringHack()); + command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); // Don't show the first run ui. command_line->AppendSwitch(switches::kNoFirstRun); // This is a Browser test. - command_line->AppendSwitchWithValue(switches::kTestType, - ASCIIToWide(kBrowserTestType)); + command_line->AppendSwitchWithValue(switches::kTestType, kBrowserTestType); // Single-process mode is not set in BrowserMain so it needs to be processed // explicitly. @@ -155,8 +153,8 @@ void InProcessBrowserTest::SetUp() { #if defined(OS_WIN) // The Windows sandbox requires that the browser and child processes are the // same binary. So we launch browser_process.exe which loads chrome.dll - command_line->AppendSwitchWithValue(switches::kBrowserSubprocessPath, - command_line->GetProgram().value()); + command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, + command_line->GetProgram()); #else // Explicitly set the path of the binary used for child processes, otherwise // they'll try to use browser_tests which doesn't contain ChromeMain. @@ -165,8 +163,8 @@ void InProcessBrowserTest::SetUp() { subprocess_path = subprocess_path.DirName(); subprocess_path = subprocess_path.AppendASCII(WideToASCII( chrome::kBrowserProcessExecutablePath)); - command_line->AppendSwitchWithValue(switches::kBrowserSubprocessPath, - subprocess_path.ToWStringHack()); + command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, + subprocess_path); #endif // Enable warning level logging so that we can see when bad stuff happens. diff --git a/chrome/test/memory_test/memory_test.cc b/chrome/test/memory_test/memory_test.cc index 079e0a4..249cf16 100644 --- a/chrome/test/memory_test/memory_test.cc +++ b/chrome/test/memory_test/memory_test.cc @@ -116,8 +116,7 @@ class MemoryTest : public UITest { browser_directory_ = browser_dir; } - launch_arguments_.AppendSwitchWithValue(switches::kUserDataDir, - user_data_dir_.ToWStringHack()); + launch_arguments_.AppendSwitchPath(switches::kUserDataDir, user_data_dir_); UITest::SetUp(); } diff --git a/chrome/test/nacl/nacl_sandbox_test.cc b/chrome/test/nacl/nacl_sandbox_test.cc index 41aa97a..2517403 100644 --- a/chrome/test/nacl/nacl_sandbox_test.cc +++ b/chrome/test/nacl/nacl_sandbox_test.cc @@ -18,18 +18,16 @@ const FilePath::CharType kSrpcHwHtmlFileName[] = NaClSandboxTest::NaClSandboxTest() : NaClTest() { // Append the --test-nacl-sandbox=$TESTDLL flag before launching. - FilePath dylibDir; - PathService::Get(base::DIR_EXE, &dylibDir); + FilePath dylib_dir; + PathService::Get(base::DIR_EXE, &dylib_dir); #if defined(OS_MACOSX) - dylibDir = dylibDir.AppendASCII("libnacl_security_tests.dylib"); - launch_arguments_.AppendSwitchWithValue(switches::kTestNaClSandbox, - dylibDir.value()); + dylib_dir = dylib_dir.AppendASCII("libnacl_security_tests.dylib"); + launch_arguments_.AppendSwitchPath(switches::kTestNaClSandbox, dylib_dir); #elif defined(OS_WIN) // Let the NaCl process detect if it is 64-bit or not and hack on // the appropriate suffix to this dll. - dylibDir = dylibDir.AppendASCII("nacl_security_tests"); - launch_arguments_.AppendSwitchWithValue(switches::kTestNaClSandbox, - dylibDir.value()); + dylib_dir = dylib_dir.AppendASCII("nacl_security_tests"); + launch_arguments_.AppendSwitchPath(switches::kTestNaClSandbox, dylib_dir); #elif defined(OS_LINUX) // We currently do not test the Chrome Linux SUID or seccomp sandboxes. #endif diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc index 1f5b49a..45bf07a 100644 --- a/chrome/test/page_cycler/page_cycler_test.cc +++ b/chrome/test/page_cycler/page_cycler_test.cc @@ -163,7 +163,7 @@ class PageCyclerTest : public UITest { // Expose garbage collection for the page cycler tests. launch_arguments_.AppendSwitchWithValue(switches::kJavaScriptFlags, - L"--expose_gc"); + "--expose_gc"); #if defined(OS_MACOSX) static rlim_t initial_fd_limit = GetFileDescriptorLimit(); fd_limit_ = initial_fd_limit; diff --git a/chrome/test/plugin/plugin_test.cpp b/chrome/test/plugin/plugin_test.cpp index d8c81a5..80643b7 100644 --- a/chrome/test/plugin/plugin_test.cpp +++ b/chrome/test/plugin/plugin_test.cpp @@ -65,7 +65,7 @@ class PluginTest : public UITest { launch_arguments_.AppendSwitch(kUseOldWMPPluginSwitch); } else if (strcmp(test_info->name(), "FlashSecurity") == 0) { launch_arguments_.AppendSwitchWithValue(switches::kTestSandbox, - L"security_tests.dll"); + "security_tests.dll"); } UITest::SetUp(); diff --git a/chrome/test/ui/npapi_test_helper.cc b/chrome/test/ui/npapi_test_helper.cc index 18e71a0..2bf6f10 100644 --- a/chrome/test/ui/npapi_test_helper.cc +++ b/chrome/test/ui/npapi_test_helper.cc @@ -49,8 +49,8 @@ void NPAPITesterBase::SetUp() { #if defined(OS_MACOSX) // The plugins directory isn't read by default on the Mac, so it needs to be // explicitly registered. - launch_arguments_.AppendSwitchWithValue(switches::kExtraPluginDir, - plugins_directory.value()); + launch_arguments_.AppendSwitchPath(switches::kExtraPluginDir, + plugins_directory); #endif UITest::SetUp(); diff --git a/chrome/test/ui/ppapi_uitest.cc b/chrome/test/ui/ppapi_uitest.cc index 5cb4aa8..b012262 100644 --- a/chrome/test/ui/ppapi_uitest.cc +++ b/chrome/test/ui/ppapi_uitest.cc @@ -36,15 +36,10 @@ class PPAPITest : public UITest { FilePath plugin_lib = plugin_dir.Append(library_name); EXPECT_TRUE(file_util::PathExists(plugin_lib)); - -#if defined(OS_WIN) - std::wstring pepper_plugin = plugin_lib.value(); -#else - std::wstring pepper_plugin = UTF8ToWide(plugin_lib.value()); -#endif - pepper_plugin.append(L";application/x-ppapi-tests"); - launch_arguments_.AppendSwitchWithValue(switches::kRegisterPepperPlugins, - pepper_plugin); + FilePath::StringType pepper_plugin = plugin_lib.value(); + pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests")); + launch_arguments_.AppendSwitchNative(switches::kRegisterPepperPlugins, + pepper_plugin); // The test sends us the result via a cookie. launch_arguments_.AppendSwitch(switches::kEnableFileCookies); diff --git a/chrome/test/ui/sandbox_uitests.cc b/chrome/test/ui/sandbox_uitests.cc index 85d4708..172028b 100644 --- a/chrome/test/ui/sandbox_uitests.cc +++ b/chrome/test/ui/sandbox_uitests.cc @@ -14,7 +14,7 @@ class SandboxTest : public UITest { // Launches chrome with the --test-sandbox=security_tests.dll flag. SandboxTest() : UITest() { launch_arguments_.AppendSwitchWithValue(switches::kTestSandbox, - L"security_tests.dll"); + "security_tests.dll"); } }; diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 3b92b99..f3eff50 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -336,7 +336,7 @@ void UITestBase::StartHttpServerWithPort(const FilePath& root_directory, ASSERT_TRUE(cmd_line.get()); cmd_line->AppendSwitchWithValue("server", "start"); cmd_line->AppendSwitch("register_cygwin"); - cmd_line->AppendSwitchWithValue("root", root_directory.ToWStringHack()); + cmd_line->AppendSwitchPath("root", root_directory); // For Windows 7, if we start the lighttpd server on the foreground mode, // it will mess up with the command window and cause conhost.exe to crash. To @@ -1118,12 +1118,10 @@ bool UITestBase::LaunchBrowserHelper(const CommandLine& arguments, command_line.AppendSwitch(switches::kNoDefaultBrowserCheck); // This is a UI test. - command_line.AppendSwitchWithValue(switches::kTestType, - ASCIIToWide(kUITestType)); + command_line.AppendSwitchWithValue(switches::kTestType, kUITestType); // Tell the browser to use a temporary directory just for this test. - command_line.AppendSwitchWithValue(switches::kUserDataDir, - user_data_dir().ToWStringHack()); + command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir()); // We need cookies on file:// for things like the page cycler. if (enable_file_cookies_) @@ -1134,7 +1132,7 @@ bool UITestBase::LaunchBrowserHelper(const CommandLine& arguments, if (include_testing_id_) { command_line.AppendSwitchWithValue(switches::kTestingChannelID, - ASCIIToWide(server_->channel_id())); + server_->channel_id()); } if (!show_error_dialogs_ && @@ -1156,14 +1154,12 @@ bool UITestBase::LaunchBrowserHelper(const CommandLine& arguments, if (disable_breakpad_) command_line.AppendSwitch(switches::kDisableBreakpad); if (!homepage_.empty()) - command_line.AppendSwitchWithValue(switches::kHomePage, - homepage_); + command_line.AppendSwitchWithValue(switches::kHomePage, homepage_); // Don't try to fetch web resources during UI testing. command_line.AppendSwitch(switches::kDisableWebResources); if (!js_flags_.empty()) - command_line.AppendSwitchWithValue(switches::kJavaScriptFlags, - js_flags_); + command_line.AppendSwitchWithValue(switches::kJavaScriptFlags, js_flags_); if (!log_level_.empty()) command_line.AppendSwitchWithValue(switches::kLoggingLevel, log_level_); @@ -1180,8 +1176,7 @@ bool UITestBase::LaunchBrowserHelper(const CommandLine& arguments, #endif if (!ui_test_name_.empty()) - command_line.AppendSwitchWithValue(switches::kTestName, - ui_test_name_); + command_line.AppendSwitchWithValue(switches::kTestName, ui_test_name_); // The tests assume that file:// URIs can freely access other file:// URIs. command_line.AppendSwitch(switches::kAllowFileAccessFromFiles); diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc index 8e11ebf..a1abccd 100644 --- a/chrome/test/ui_test_utils.cc +++ b/chrome/test/ui_test_utils.cc @@ -618,11 +618,10 @@ TestWebSocketServer::TestWebSocketServer(const FilePath& root_directory) { cmd_line->AppendSwitchWithValue("server", "start"); cmd_line->AppendSwitch("chromium"); cmd_line->AppendSwitch("register_cygwin"); - cmd_line->AppendSwitchWithValue("root", root_directory.ToWStringHack()); + cmd_line->AppendSwitchPath("root", root_directory); temp_dir_.CreateUniqueTempDir(); websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid"); - cmd_line->AppendSwitchWithValue("pidfile", - websocket_pid_file_.ToWStringHack()); + cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_); SetPythonPath(); base::LaunchApp(*cmd_line.get(), true, false, NULL); } @@ -664,8 +663,7 @@ TestWebSocketServer::~TestWebSocketServer() { scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); cmd_line->AppendSwitchWithValue("server", "stop"); cmd_line->AppendSwitch("chromium"); - cmd_line->AppendSwitchWithValue("pidfile", - websocket_pid_file_.ToWStringHack()); + cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_); base::LaunchApp(*cmd_line.get(), true, false, NULL); } diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index 8909923..bed7be2 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -280,7 +280,7 @@ void ProxyFactory::CreateProxy(ProxyFactory::ProxyCacheEntry* entry, scoped_ptr<CommandLine> command_line( chrome_launcher::CreateLaunchCommandLine()); command_line->AppendSwitchWithValue(switches::kAutomationClientChannelID, - ASCIIToWide(proxy->channel_id())); + proxy->channel_id()); // Run Chrome in Chrome Frame mode. In practice, this modifies the paths // and registry keys that Chrome looks in via the BrowserDistribution @@ -304,8 +304,7 @@ void ProxyFactory::CreateProxy(ProxyFactory::ProxyCacheEntry* entry, command_line->AppendSwitch(switches::kFullMemoryCrashReport); DLOG(INFO) << "Profile path: " << params.profile_path.value(); - command_line->AppendSwitchWithValue(switches::kUserDataDir, - params.profile_path.value()); + command_line->AppendSwitchPath(switches::kUserDataDir, params.profile_path); std::wstring command_line_string(command_line->command_line_string()); // If there are any extra arguments, append them to the command line. diff --git a/chrome_frame/chrome_launcher_unittest.cc b/chrome_frame/chrome_launcher_unittest.cc index 835fc35..9511b40 100644 --- a/chrome_frame/chrome_launcher_unittest.cc +++ b/chrome_frame/chrome_launcher_unittest.cc @@ -20,7 +20,7 @@ TEST(ChromeLauncher, IsValidCommandLine) { CommandLine good(FilePath(L"dummy.exe")); good.AppendSwitch(switches::kNoFirstRun); // in whitelist - good.AppendSwitchWithValue(switches::kUserDataDir, L"foo"); // in whitelist + good.AppendSwitchWithValue(switches::kUserDataDir, "foo"); // in whitelist EXPECT_TRUE(chrome_launcher::IsValidCommandLine( good.command_line_string().c_str())); diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index 920adfd..f7ff496 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -281,7 +281,7 @@ HRESULT SetupRunOnce() { if (run_once.Create(HKEY_CURRENT_USER, kRunOnce, KEY_READ | KEY_WRITE)) { CommandLine run_once_command(chrome_launcher::GetChromeExecutablePath()); run_once_command.AppendSwitchWithValue( - switches::kAutomationClientChannelID, L"0"); + switches::kAutomationClientChannelID, "0"); run_once_command.AppendSwitch(switches::kChromeFrame); run_once.WriteValue(L"A", run_once_command.command_line_string().c_str()); } |