| 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 RegisterChildWithExternalShell(id_, instance_id_++, this); | 704 shell_pipe_token_ = 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 |
| 1629 #if defined(OS_WIN) && !defined(OFFICIAL_BUILD) | 1634 #if defined(OS_WIN) && !defined(OFFICIAL_BUILD) |
| 1630 // Needed because we can't show the dialog from the sandbox. Don't pass | 1635 // Needed because we can't show the dialog from the sandbox. Don't pass |
| 1631 // --no-sandbox in official builds because that would bypass the bad_flgs | 1636 // --no-sandbox in official builds because that would bypass the bad_flgs |
| 1632 // prompt. | 1637 // prompt. |
| 1633 if (renderer_cmd->HasSwitch(switches::kRendererStartupDialog) && | 1638 if (renderer_cmd->HasSwitch(switches::kRendererStartupDialog) && |
| 1634 !renderer_cmd->HasSwitch(switches::kNoSandbox)) { | 1639 !renderer_cmd->HasSwitch(switches::kNoSandbox)) { |
| 1635 renderer_cmd->AppendSwitch(switches::kNoSandbox); | 1640 renderer_cmd->AppendSwitch(switches::kNoSandbox); |
| 1636 } | 1641 } |
| 1637 #endif | 1642 #endif |
| 1638 } | 1643 } |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2585 // ExtensionService uses this notification to initialize the renderer process | 2590 // ExtensionService uses this notification to initialize the renderer process |
| 2586 // with state that must be there before any JavaScript executes. | 2591 // with state that must be there before any JavaScript executes. |
| 2587 // | 2592 // |
| 2588 // The queued messages contain such things as "navigate". If this notification | 2593 // The queued messages contain such things as "navigate". If this notification |
| 2589 // was after, we can end up executing JavaScript before the initialization | 2594 // was after, we can end up executing JavaScript before the initialization |
| 2590 // happens. | 2595 // happens. |
| 2591 NotificationService::current()->Notify(NOTIFICATION_RENDERER_PROCESS_CREATED, | 2596 NotificationService::current()->Notify(NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 2592 Source<RenderProcessHost>(this), | 2597 Source<RenderProcessHost>(this), |
| 2593 NotificationService::NoDetails()); | 2598 NotificationService::NoDetails()); |
| 2594 | 2599 |
| 2595 if (child_process_launcher_.get()) { | |
| 2596 base::ProcessHandle process_handle = | |
| 2597 child_process_launcher_->GetProcess().Handle(); | |
| 2598 mojo::edk::ScopedPlatformHandle client_pipe = | |
| 2599 mojo::edk::ChildProcessLaunched(process_handle); | |
| 2600 Send(new ChildProcessMsg_SetMojoParentPipeHandle( | |
| 2601 IPC::GetFileHandleForProcess(client_pipe.release().handle, | |
| 2602 process_handle, true))); | |
| 2603 } | |
| 2604 | |
| 2605 // Send the mojo shell handle to the renderer. | |
| 2606 SendExternalMojoShellHandleToChild(GetHandle(), this); | |
| 2607 | |
| 2608 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. | 2600 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. |
| 2609 // This way, Mojo can be safely used from the renderer in response to any | 2601 // This way, Mojo can be safely used from the renderer in response to any |
| 2610 // Chrome IPC message. | 2602 // Chrome IPC message. |
| 2611 mojo_application_host_->Activate(this, GetHandle()); | 2603 mojo_application_host_->Activate(this, GetHandle()); |
| 2612 | 2604 |
| 2613 while (!queued_messages_.empty()) { | 2605 while (!queued_messages_.empty()) { |
| 2614 Send(queued_messages_.front()); | 2606 Send(queued_messages_.front()); |
| 2615 queued_messages_.pop(); | 2607 queued_messages_.pop(); |
| 2616 } | 2608 } |
| 2617 | 2609 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2818 | 2810 |
| 2819 // Skip widgets in other processes. | 2811 // Skip widgets in other processes. |
| 2820 if (rvh->GetProcess()->GetID() != GetID()) | 2812 if (rvh->GetProcess()->GetID() != GetID()) |
| 2821 continue; | 2813 continue; |
| 2822 | 2814 |
| 2823 rvh->OnWebkitPreferencesChanged(); | 2815 rvh->OnWebkitPreferencesChanged(); |
| 2824 } | 2816 } |
| 2825 } | 2817 } |
| 2826 | 2818 |
| 2827 } // namespace content | 2819 } // namespace content |
| OLD | NEW |