OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 10 #include <algorithm> |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 in_process_renderer_->StartWithOptions(options); | 324 in_process_renderer_->StartWithOptions(options); |
325 | 325 |
326 OnProcessLaunched(); // Fake a callback that the process is ready. | 326 OnProcessLaunched(); // Fake a callback that the process is ready. |
327 } else { | 327 } else { |
328 // Build command line for renderer. We call AppendRendererCommandLine() | 328 // Build command line for renderer. We call AppendRendererCommandLine() |
329 // first so the process type argument will appear first. | 329 // first so the process type argument will appear first. |
330 CommandLine* cmd_line = new CommandLine(renderer_path); | 330 CommandLine* cmd_line = new CommandLine(renderer_path); |
331 if (!renderer_prefix.empty()) | 331 if (!renderer_prefix.empty()) |
332 cmd_line->PrependWrapper(renderer_prefix); | 332 cmd_line->PrependWrapper(renderer_prefix); |
333 AppendRendererCommandLine(cmd_line); | 333 AppendRendererCommandLine(cmd_line); |
334 cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, | 334 cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, channel_id); |
335 ASCIIToWide(channel_id)); | |
336 | 335 |
337 // Spawn the child process asynchronously to avoid blocking the UI thread. | 336 // Spawn the child process asynchronously to avoid blocking the UI thread. |
338 // As long as there's no renderer prefix, we can use the zygote process | 337 // As long as there's no renderer prefix, we can use the zygote process |
339 // at this stage. | 338 // at this stage. |
340 child_process_.reset(new ChildProcessLauncher( | 339 child_process_.reset(new ChildProcessLauncher( |
341 #if defined(OS_WIN) | 340 #if defined(OS_WIN) |
342 FilePath(), | 341 FilePath(), |
343 #elif defined(POSIX) | 342 #elif defined(POSIX) |
344 renderer_prefix.empty(), | 343 renderer_prefix.empty(), |
345 base::environment_vector(), | 344 base::environment_vector(), |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 451 |
453 if (logging::DialogsAreSuppressed()) | 452 if (logging::DialogsAreSuppressed()) |
454 command_line->AppendSwitch(switches::kNoErrorDialogs); | 453 command_line->AppendSwitch(switches::kNoErrorDialogs); |
455 | 454 |
456 // Now send any options from our own command line we want to propogate. | 455 // Now send any options from our own command line we want to propogate. |
457 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 456 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
458 PropagateBrowserCommandLineToRenderer(browser_command_line, command_line); | 457 PropagateBrowserCommandLineToRenderer(browser_command_line, command_line); |
459 | 458 |
460 // Pass on the browser locale. | 459 // Pass on the browser locale. |
461 const std::string locale = g_browser_process->GetApplicationLocale(); | 460 const std::string locale = g_browser_process->GetApplicationLocale(); |
462 command_line->AppendSwitchWithValue(switches::kLang, ASCIIToWide(locale)); | 461 command_line->AppendSwitchWithValue(switches::kLang, locale); |
463 | 462 |
464 // If we run FieldTrials, we want to pass to their state to the renderer so | 463 // If we run FieldTrials, we want to pass to their state to the renderer so |
465 // that it can act in accordance with each state, or record histograms | 464 // that it can act in accordance with each state, or record histograms |
466 // relating to the FieldTrial states. | 465 // relating to the FieldTrial states. |
467 std::string field_trial_states; | 466 std::string field_trial_states; |
468 FieldTrialList::StatesToString(&field_trial_states); | 467 FieldTrialList::StatesToString(&field_trial_states); |
469 if (!field_trial_states.empty()) { | 468 if (!field_trial_states.empty()) { |
470 command_line->AppendSwitchWithValue(switches::kForceFieldTestNameAndValue, | 469 command_line->AppendSwitchWithValue(switches::kForceFieldTestNameAndValue, |
471 field_trial_states); | 470 field_trial_states); |
472 } | 471 } |
473 | 472 |
474 BrowserChildProcessHost::SetCrashReporterCommandLine(command_line); | 473 BrowserChildProcessHost::SetCrashReporterCommandLine(command_line); |
475 | 474 |
476 FilePath user_data_dir = | 475 FilePath user_data_dir = |
477 browser_command_line.GetSwitchValuePath(switches::kUserDataDir); | 476 browser_command_line.GetSwitchValuePath(switches::kUserDataDir); |
478 | |
479 if (!user_data_dir.empty()) | 477 if (!user_data_dir.empty()) |
480 command_line->AppendSwitchWithValue(switches::kUserDataDir, | 478 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
481 user_data_dir.value()); | |
482 #if defined(OS_CHROMEOS) | 479 #if defined(OS_CHROMEOS) |
483 const std::string& profile = | 480 const std::string& profile = |
484 browser_command_line.GetSwitchValueASCII(switches::kProfile); | 481 browser_command_line.GetSwitchValueASCII(switches::kProfile); |
485 if (!profile.empty()) | 482 if (!profile.empty()) |
486 command_line->AppendSwitchWithValue(switches::kProfile, profile); | 483 command_line->AppendSwitchWithValue(switches::kProfile, profile); |
487 #endif | 484 #endif |
488 } | 485 } |
489 | 486 |
490 void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( | 487 void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( |
491 const CommandLine& browser_cmd, | 488 const CommandLine& browser_cmd, |
492 CommandLine* renderer_cmd) const { | 489 CommandLine* renderer_cmd) const { |
493 // Propagate the following switches to the renderer command line (along | 490 // Propagate the following switches to the renderer command line (along |
494 // with any associated values) if present in the browser command line. | 491 // with any associated values) if present in the browser command line. |
495 static const char* const switch_names[] = { | 492 static const char* const kSwitchNames[] = { |
496 switches::kRendererAssertTest, | 493 switches::kRendererAssertTest, |
497 #if !defined(OFFICIAL_BUILD) | 494 #if !defined(OFFICIAL_BUILD) |
498 switches::kRendererCheckFalseTest, | 495 switches::kRendererCheckFalseTest, |
499 #endif // !defined(OFFICIAL_BUILD) | 496 #endif // !defined(OFFICIAL_BUILD) |
500 switches::kRendererCrashTest, | 497 switches::kRendererCrashTest, |
501 switches::kRendererStartupDialog, | 498 switches::kRendererStartupDialog, |
502 switches::kNoSandbox, | 499 switches::kNoSandbox, |
503 switches::kTestSandbox, | 500 switches::kTestSandbox, |
504 #if defined(USE_SECCOMP_SANDBOX) | 501 #if defined(USE_SECCOMP_SANDBOX) |
505 switches::kDisableSeccompSandbox, | 502 switches::kDisableSeccompSandbox, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 // Allow this to be set when invoking the browser and relayed along. | 570 // Allow this to be set when invoking the browser and relayed along. |
574 switches::kEnableSandboxLogging, | 571 switches::kEnableSandboxLogging, |
575 switches::kDisableFlashCoreAnimation, | 572 switches::kDisableFlashCoreAnimation, |
576 #endif | 573 #endif |
577 switches::kRemoteShellPort, | 574 switches::kRemoteShellPort, |
578 switches::kEnablePepperTesting, | 575 switches::kEnablePepperTesting, |
579 switches::kEnableChromoting, | 576 switches::kEnableChromoting, |
580 switches::kEnableClickToPlay, | 577 switches::kEnableClickToPlay, |
581 switches::kPrelaunchGpuProcess, | 578 switches::kPrelaunchGpuProcess, |
582 }; | 579 }; |
583 | 580 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, |
584 for (size_t i = 0; i < arraysize(switch_names); ++i) { | 581 arraysize(kSwitchNames)); |
585 if (browser_cmd.HasSwitch(switch_names[i])) { | |
586 renderer_cmd->AppendSwitchWithValue(switch_names[i], | |
587 browser_cmd.GetSwitchValueASCII(switch_names[i])); | |
588 } | |
589 } | |
590 | 582 |
591 // Disable databases in incognito mode. | 583 // Disable databases in incognito mode. |
592 if (profile()->IsOffTheRecord() && | 584 if (profile()->IsOffTheRecord() && |
593 !browser_cmd.HasSwitch(switches::kDisableDatabases)) { | 585 !browser_cmd.HasSwitch(switches::kDisableDatabases)) { |
594 renderer_cmd->AppendSwitch(switches::kDisableDatabases); | 586 renderer_cmd->AppendSwitch(switches::kDisableDatabases); |
595 } | 587 } |
596 } | 588 } |
597 | 589 |
598 base::ProcessHandle BrowserRenderProcessHost::GetHandle() { | 590 base::ProcessHandle BrowserRenderProcessHost::GetHandle() { |
599 // child_process_ is null either because we're in single process mode, we have | 591 // child_process_ is null either because we're in single process mode, we have |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 IPC::InvalidPlatformFileForTransit(), | 1064 IPC::InvalidPlatformFileForTransit(), |
1073 std::vector<std::string>(), | 1065 std::vector<std::string>(), |
1074 std::string(), | 1066 std::string(), |
1075 false)); | 1067 false)); |
1076 } | 1068 } |
1077 } | 1069 } |
1078 | 1070 |
1079 void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) { | 1071 void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) { |
1080 Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable)); | 1072 Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable)); |
1081 } | 1073 } |
OLD | NEW |