summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-21 01:00:22 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-21 01:00:22 +0000
commitbb97536b768ac68fcbc4605c35461a798ef6e5ff (patch)
tree479bde96cd05a9e1f9d2746dd82313e2eb715e8e /chrome/browser/renderer_host
parent8731a63268015f4e5d684833c11a1b44bd9ae468 (diff)
downloadchromium_src-bb97536b768ac68fcbc4605c35461a798ef6e5ff.zip
chromium_src-bb97536b768ac68fcbc4605c35461a798ef6e5ff.tar.gz
chromium_src-bb97536b768ac68fcbc4605c35461a798ef6e5ff.tar.bz2
Make CommandLine into a normal object, with some statics for getting at the current process's command line.
One explicit goal of this change is to *not* deal with the string/wstring issues at the API on POSIX; the functions are the same as before, which means they remain as broken as before. (I did try to fix the internals, though, so migrating the callers is now possible by adding platform-appropriate hooks.) Review URL: http://codereview.chromium.org/18248 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc43
1 files changed, 20 insertions, 23 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 198d886..cb43eb9 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -167,7 +167,7 @@ bool BrowserRenderProcessHost::Init() {
widget_helper_,
profile()->GetSpellChecker());
- CommandLine browser_command_line;
+ const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
// setup IPC channel
std::wstring channel_id = GenerateRandomChannelID(this);
@@ -188,10 +188,9 @@ bool BrowserRenderProcessHost::Init() {
if (renderer_path.empty())
if (!GetRendererPath(&renderer_path))
return false;
- std::wstring cmd_line;
- cmd_line = L"\"" + renderer_path + L"\"";
+ CommandLine cmd_line(renderer_path);
if (logging::DialogsAreSuppressed())
- CommandLine::AppendSwitch(&cmd_line, switches::kNoErrorDialogs);
+ cmd_line.AppendSwitch(switches::kNoErrorDialogs);
// propagate the following switches to the renderer command line
// (along with any associated values) if present in the browser command line
@@ -229,15 +228,14 @@ bool BrowserRenderProcessHost::Init() {
for (int i = 0; i < arraysize(switch_names); ++i) {
if (browser_command_line.HasSwitch(switch_names[i])) {
- CommandLine::AppendSwitchWithValue(
- &cmd_line, switch_names[i],
+ cmd_line.AppendSwitchWithValue(switch_names[i],
browser_command_line.GetSwitchValue(switch_names[i]));
}
}
// Pass on the browser locale.
const std::wstring locale = g_browser_process->GetApplicationLocale();
- CommandLine::AppendSwitchWithValue(&cmd_line, switches::kLang, locale);
+ cmd_line.AppendSwitchWithValue(switches::kLang, locale);
bool in_sandbox = !browser_command_line.HasSwitch(switches::kNoSandbox);
if (browser_command_line.HasSwitch(switches::kInProcessPlugins)) {
@@ -249,19 +247,17 @@ bool BrowserRenderProcessHost::Init() {
DebugFlags::ProcessDebugFlags(&cmd_line,
DebugFlags::RENDERER,
in_sandbox);
- CommandLine::AppendSwitchWithValue(&cmd_line,
- switches::kProcessType,
- switches::kRendererProcess);
+ cmd_line.AppendSwitchWithValue(switches::kProcessType,
+ switches::kRendererProcess);
- CommandLine::AppendSwitchWithValue(&cmd_line,
- switches::kProcessChannelID,
- channel_id);
+ cmd_line.AppendSwitchWithValue(switches::kProcessChannelID,
+ channel_id);
const std::wstring& profile_path =
browser_command_line.GetSwitchValue(switches::kUserDataDir);
if (!profile_path.empty())
- CommandLine::AppendSwitchWithValue(&cmd_line, switches::kUserDataDir,
- profile_path);
+ cmd_line.AppendSwitchWithValue(switches::kUserDataDir,
+ profile_path);
bool run_in_process = run_renderer_in_process();
if (run_in_process) {
@@ -286,7 +282,8 @@ bool BrowserRenderProcessHost::Init() {
g_browser_process->local_state()->GetBoolean(
prefs::kStartRenderersManually)) {
std::wstring message =
- L"Please start a renderer process using:\n" + cmd_line;
+ L"Please start a renderer process using:\n" +
+ cmd_line.command_line_string();
// We don't know the owner window for BrowserRenderProcessHost and therefore we
// pass a NULL HWND argument.
@@ -328,8 +325,7 @@ bool BrowserRenderProcessHost::Init() {
return false;
}
- CommandLine command_line;
- if (command_line.HasSwitch(switches::kGearsInRenderer)) {
+ if (browser_command_line.HasSwitch(switches::kGearsInRenderer)) {
if (!AddPolicyForGearsInRenderer(policy)) {
NOTREACHED();
return false;
@@ -341,9 +337,10 @@ bool BrowserRenderProcessHost::Init() {
return false;
}
- result = broker_service->SpawnTarget(renderer_path.c_str(),
- cmd_line.c_str(),
- policy, &target);
+ result =
+ broker_service->SpawnTarget(renderer_path.c_str(),
+ cmd_line.command_line_string().c_str(),
+ policy, &target);
policy->Release();
if (desktop)
@@ -465,8 +462,8 @@ void BrowserRenderProcessHost::InitVisitedLinks() {
}
void BrowserRenderProcessHost::InitUserScripts() {
- CommandLine command_line;
- if (!command_line.HasSwitch(switches::kEnableUserScripts)) {
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableUserScripts)) {
return;
}