OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 const std::string locale = g_browser_process->GetApplicationLocale(); | 448 const std::string locale = g_browser_process->GetApplicationLocale(); |
449 command_line->AppendSwitchWithValue(switches::kLang, ASCIIToWide(locale)); | 449 command_line->AppendSwitchWithValue(switches::kLang, ASCIIToWide(locale)); |
450 | 450 |
451 // If we run FieldTrials, we want to pass to their state to the renderer so | 451 // If we run FieldTrials, we want to pass to their state to the renderer so |
452 // that it can act in accordance with each state, or record histograms | 452 // that it can act in accordance with each state, or record histograms |
453 // relating to the FieldTrial states. | 453 // relating to the FieldTrial states. |
454 std::string field_trial_states; | 454 std::string field_trial_states; |
455 FieldTrialList::StatesToString(&field_trial_states); | 455 FieldTrialList::StatesToString(&field_trial_states); |
456 if (!field_trial_states.empty()) { | 456 if (!field_trial_states.empty()) { |
457 command_line->AppendSwitchWithValue(switches::kForceFieldTestNameAndValue, | 457 command_line->AppendSwitchWithValue(switches::kForceFieldTestNameAndValue, |
458 ASCIIToWide(field_trial_states)); | 458 field_trial_states); |
459 } | 459 } |
460 | 460 |
461 // A command prefix is something prepended to the command line of the spawned | 461 // A command prefix is something prepended to the command line of the spawned |
462 // process. It is supported only on POSIX systems. | 462 // process. It is supported only on POSIX systems. |
463 #if defined(OS_POSIX) | 463 #if defined(OS_POSIX) |
464 *has_cmd_prefix = | 464 *has_cmd_prefix = |
465 browser_command_line.HasSwitch(switches::kRendererCmdPrefix); | 465 browser_command_line.HasSwitch(switches::kRendererCmdPrefix); |
466 if (*has_cmd_prefix) { | 466 if (*has_cmd_prefix) { |
467 // launch the renderer child with some prefix (usually "gdb --args") | 467 // launch the renderer child with some prefix (usually "gdb --args") |
468 const std::wstring prefix = | 468 const std::wstring prefix = |
469 browser_command_line.GetSwitchValue(switches::kRendererCmdPrefix); | 469 browser_command_line.GetSwitchValue(switches::kRendererCmdPrefix); |
470 command_line->PrependWrapper(prefix); | 470 command_line->PrependWrapper(prefix); |
471 } | 471 } |
472 #else | 472 #else |
473 *has_cmd_prefix = false; | 473 *has_cmd_prefix = false; |
474 #endif // defined(OS_POSIX) | 474 #endif // defined(OS_POSIX) |
475 | 475 |
476 ChildProcessHost::SetCrashReporterCommandLine(command_line); | 476 ChildProcessHost::SetCrashReporterCommandLine(command_line); |
477 | 477 |
478 const std::wstring& profile_path = | 478 const std::string& profile_path = |
479 browser_command_line.GetSwitchValue(switches::kUserDataDir); | 479 browser_command_line.GetSwitchValueASCII(switches::kUserDataDir); |
480 if (!profile_path.empty()) | 480 if (!profile_path.empty()) |
481 command_line->AppendSwitchWithValue(switches::kUserDataDir, profile_path); | 481 command_line->AppendSwitchWithValue(switches::kUserDataDir, profile_path); |
482 } | 482 } |
483 | 483 |
484 void BrowserRenderProcessHost::PropogateBrowserCommandLineToRenderer( | 484 void BrowserRenderProcessHost::PropogateBrowserCommandLineToRenderer( |
485 const CommandLine& browser_cmd, | 485 const CommandLine& browser_cmd, |
486 CommandLine* renderer_cmd) const { | 486 CommandLine* renderer_cmd) const { |
487 // Propagate the following switches to the renderer command line (along | 487 // Propagate the following switches to the renderer command line (along |
488 // with any associated values) if present in the browser command line. | 488 // with any associated values) if present in the browser command line. |
489 static const char* const switch_names[] = { | 489 static const char* const switch_names[] = { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 switches::kChromeFrame, | 534 switches::kChromeFrame, |
535 #if defined(OS_MACOSX) | 535 #if defined(OS_MACOSX) |
536 // Allow this to be set when invoking the browser and relayed along. | 536 // Allow this to be set when invoking the browser and relayed along. |
537 switches::kEnableSandboxLogging, | 537 switches::kEnableSandboxLogging, |
538 #endif | 538 #endif |
539 }; | 539 }; |
540 | 540 |
541 for (size_t i = 0; i < arraysize(switch_names); ++i) { | 541 for (size_t i = 0; i < arraysize(switch_names); ++i) { |
542 if (browser_cmd.HasSwitch(switch_names[i])) { | 542 if (browser_cmd.HasSwitch(switch_names[i])) { |
543 renderer_cmd->AppendSwitchWithValue(switch_names[i], | 543 renderer_cmd->AppendSwitchWithValue(switch_names[i], |
544 browser_cmd.GetSwitchValue(switch_names[i])); | 544 browser_cmd.GetSwitchValueASCII(switch_names[i])); |
545 } | 545 } |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 #if defined(OS_WIN) | 549 #if defined(OS_WIN) |
550 | 550 |
551 base::ProcessHandle BrowserRenderProcessHost::ExecuteRenderer( | 551 base::ProcessHandle BrowserRenderProcessHost::ExecuteRenderer( |
552 CommandLine* cmd_line, | 552 CommandLine* cmd_line, |
553 bool has_cmd_prefix) { | 553 bool has_cmd_prefix) { |
554 return sandbox::StartProcess(cmd_line); | 554 return sandbox::StartProcess(cmd_line); |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 profile()->GetExtensionMessageService()->RemoveEventListener( | 1040 profile()->GetExtensionMessageService()->RemoveEventListener( |
1041 event_name, id()); | 1041 event_name, id()); |
1042 } | 1042 } |
1043 } | 1043 } |
1044 | 1044 |
1045 void BrowserRenderProcessHost::OnExtensionCloseChannel(int port_id) { | 1045 void BrowserRenderProcessHost::OnExtensionCloseChannel(int port_id) { |
1046 if (profile()->GetExtensionMessageService()) { | 1046 if (profile()->GetExtensionMessageService()) { |
1047 profile()->GetExtensionMessageService()->CloseChannel(port_id); | 1047 profile()->GetExtensionMessageService()->CloseChannel(port_id); |
1048 } | 1048 } |
1049 } | 1049 } |
OLD | NEW |