| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 void RenderProcessHostImpl::EnableSendQueue() { | 694 void RenderProcessHostImpl::EnableSendQueue() { |
| 695 is_initialized_ = false; | 695 is_initialized_ = false; |
| 696 } | 696 } |
| 697 | 697 |
| 698 bool RenderProcessHostImpl::Init() { | 698 bool RenderProcessHostImpl::Init() { |
| 699 // calling Init() more than once does nothing, this makes it more convenient | 699 // calling Init() more than once does nothing, this makes it more convenient |
| 700 // for the view host which may not be sure in some cases | 700 // for the view host which may not be sure in some cases |
| 701 if (channel_) | 701 if (channel_) |
| 702 return true; | 702 return true; |
| 703 | 703 |
| 704 shell_pipe_token_ = RegisterChildWithExternalShell(id_, instance_id_++, this); | 704 RegisterChildWithExternalShell(id_, instance_id_++, this); |
| 705 | 705 |
| 706 base::CommandLine::StringType renderer_prefix; | 706 base::CommandLine::StringType renderer_prefix; |
| 707 // A command prefix is something prepended to the command line of the spawned | 707 // A command prefix is something prepended to the command line of the spawned |
| 708 // process. | 708 // process. |
| 709 const base::CommandLine& browser_command_line = | 709 const base::CommandLine& browser_command_line = |
| 710 *base::CommandLine::ForCurrentProcess(); | 710 *base::CommandLine::ForCurrentProcess(); |
| 711 renderer_prefix = | 711 renderer_prefix = |
| 712 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 712 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
| 713 | 713 |
| 714 #if defined(OS_LINUX) | 714 #if defined(OS_LINUX) |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1619 // Add kWaitForDebugger to let renderer process wait for a debugger. | 1619 // Add kWaitForDebugger to let renderer process wait for a debugger. |
| 1620 if (browser_cmd.HasSwitch(switches::kWaitForDebuggerChildren)) { | 1620 if (browser_cmd.HasSwitch(switches::kWaitForDebuggerChildren)) { |
| 1621 // Look to pass-on the kWaitForDebugger flag. | 1621 // Look to pass-on the kWaitForDebugger flag. |
| 1622 std::string value = | 1622 std::string value = |
| 1623 browser_cmd.GetSwitchValueASCII(switches::kWaitForDebuggerChildren); | 1623 browser_cmd.GetSwitchValueASCII(switches::kWaitForDebuggerChildren); |
| 1624 if (value.empty() || value == switches::kRendererProcess) { | 1624 if (value.empty() || value == switches::kRendererProcess) { |
| 1625 renderer_cmd->AppendSwitch(switches::kWaitForDebugger); | 1625 renderer_cmd->AppendSwitch(switches::kWaitForDebugger); |
| 1626 } | 1626 } |
| 1627 } | 1627 } |
| 1628 | 1628 |
| 1629 if (!shell_pipe_token_.empty()) { | |
| 1630 renderer_cmd->AppendSwitchASCII(switches::kMojoPrimordialPipeToken, | |
| 1631 shell_pipe_token_); | |
| 1632 } | |
| 1633 | |
| 1634 #if defined(OS_WIN) && !defined(OFFICIAL_BUILD) | 1629 #if defined(OS_WIN) && !defined(OFFICIAL_BUILD) |
| 1635 // Needed because we can't show the dialog from the sandbox. Don't pass | 1630 // Needed because we can't show the dialog from the sandbox. Don't pass |
| 1636 // --no-sandbox in official builds because that would bypass the bad_flgs | 1631 // --no-sandbox in official builds because that would bypass the bad_flgs |
| 1637 // prompt. | 1632 // prompt. |
| 1638 if (renderer_cmd->HasSwitch(switches::kRendererStartupDialog) && | 1633 if (renderer_cmd->HasSwitch(switches::kRendererStartupDialog) && |
| 1639 !renderer_cmd->HasSwitch(switches::kNoSandbox)) { | 1634 !renderer_cmd->HasSwitch(switches::kNoSandbox)) { |
| 1640 renderer_cmd->AppendSwitch(switches::kNoSandbox); | 1635 renderer_cmd->AppendSwitch(switches::kNoSandbox); |
| 1641 } | 1636 } |
| 1642 #endif | 1637 #endif |
| 1643 } | 1638 } |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2575 // ExtensionService uses this notification to initialize the renderer process | 2570 // ExtensionService uses this notification to initialize the renderer process |
| 2576 // with state that must be there before any JavaScript executes. | 2571 // with state that must be there before any JavaScript executes. |
| 2577 // | 2572 // |
| 2578 // The queued messages contain such things as "navigate". If this notification | 2573 // The queued messages contain such things as "navigate". If this notification |
| 2579 // was after, we can end up executing JavaScript before the initialization | 2574 // was after, we can end up executing JavaScript before the initialization |
| 2580 // happens. | 2575 // happens. |
| 2581 NotificationService::current()->Notify(NOTIFICATION_RENDERER_PROCESS_CREATED, | 2576 NotificationService::current()->Notify(NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 2582 Source<RenderProcessHost>(this), | 2577 Source<RenderProcessHost>(this), |
| 2583 NotificationService::NoDetails()); | 2578 NotificationService::NoDetails()); |
| 2584 | 2579 |
| 2580 if (child_process_launcher_.get()) { |
| 2581 base::ProcessHandle process_handle = |
| 2582 child_process_launcher_->GetProcess().Handle(); |
| 2583 mojo::edk::ScopedPlatformHandle client_pipe = |
| 2584 mojo::edk::ChildProcessLaunched(process_handle); |
| 2585 Send(new ChildProcessMsg_SetMojoParentPipeHandle( |
| 2586 IPC::GetFileHandleForProcess(client_pipe.release().handle, |
| 2587 process_handle, true))); |
| 2588 } |
| 2589 |
| 2590 // Send the mojo shell handle to the renderer. |
| 2591 SendExternalMojoShellHandleToChild(GetHandle(), this); |
| 2592 |
| 2585 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. | 2593 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. |
| 2586 // This way, Mojo can be safely used from the renderer in response to any | 2594 // This way, Mojo can be safely used from the renderer in response to any |
| 2587 // Chrome IPC message. | 2595 // Chrome IPC message. |
| 2588 mojo_application_host_->Activate(this, GetHandle()); | 2596 mojo_application_host_->Activate(this, GetHandle()); |
| 2589 | 2597 |
| 2590 while (!queued_messages_.empty()) { | 2598 while (!queued_messages_.empty()) { |
| 2591 Send(queued_messages_.front()); | 2599 Send(queued_messages_.front()); |
| 2592 queued_messages_.pop(); | 2600 queued_messages_.pop(); |
| 2593 } | 2601 } |
| 2594 | 2602 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2795 | 2803 |
| 2796 // Skip widgets in other processes. | 2804 // Skip widgets in other processes. |
| 2797 if (rvh->GetProcess()->GetID() != GetID()) | 2805 if (rvh->GetProcess()->GetID() != GetID()) |
| 2798 continue; | 2806 continue; |
| 2799 | 2807 |
| 2800 rvh->OnWebkitPreferencesChanged(); | 2808 rvh->OnWebkitPreferencesChanged(); |
| 2801 } | 2809 } |
| 2802 } | 2810 } |
| 2803 | 2811 |
| 2804 } // namespace content | 2812 } // namespace content |
| OLD | NEW |