| Index: content/browser/renderer_host/render_process_host_impl.cc
|
| diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
|
| index 5ce5e599bde2418bc37fd530267810ddcb7cc4df..32246aed47381fb3799b434162a8c70e8c9ccdca 100644
|
| --- a/content/browser/renderer_host/render_process_host_impl.cc
|
| +++ b/content/browser/renderer_host/render_process_host_impl.cc
|
| @@ -395,6 +395,7 @@ RenderProcessHostImpl::RenderProcessHostImpl(
|
| is_self_deleted_(false),
|
| #endif
|
| pending_views_(0),
|
| + mojo_activation_required_(false),
|
| visible_widgets_(0),
|
| backgrounded_(true),
|
| is_initialized_(false),
|
| @@ -604,6 +605,20 @@ bool RenderProcessHostImpl::Init() {
|
| return true;
|
| }
|
|
|
| +void RenderProcessHostImpl::MaybeActivateMojo() {
|
| + // TODO(darin): Following security review, we can unconditionally initialize
|
| + // Mojo in all renderers. We will then be able to directly call Activate()
|
| + // from OnProcessLaunched.
|
| + if (!mojo_activation_required_)
|
| + return; // Waiting on someone to require Mojo.
|
| +
|
| + if (!GetHandle())
|
| + return; // Waiting on renderer startup.
|
| +
|
| + if (!mojo_application_host_->did_activate())
|
| + mojo_application_host_->Activate(this, GetHandle());
|
| +}
|
| +
|
| void RenderProcessHostImpl::CreateMessageFilters() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| AddFilter(new ResourceSchedulerFilter(GetID()));
|
| @@ -1972,13 +1987,10 @@ void RenderProcessHostImpl::OnProcessLaunched() {
|
| Source<RenderProcessHost>(this),
|
| NotificationService::NoDetails());
|
|
|
| - // TODO(darin): This is blocked on security review. Un-commenting this will
|
| - // allow Mojo calls from all renderers.
|
| -#if 0
|
| - // Let the Mojo system get setup on the child process side before any other
|
| - // IPCs arrive. This way those may safely generate Mojo-related RPCs.
|
| - mojo_application_host_->Activate(this, GetHandle());
|
| -#endif
|
| + // Allow Mojo to be setup before the renderer sees any Chrome IPC messages.
|
| + // This way, Mojo can be safely used from the renderer in response to any
|
| + // Chrome IPC message.
|
| + MaybeActivateMojo();
|
|
|
| while (!queued_messages_.empty()) {
|
| Send(queued_messages_.front());
|
| @@ -2065,8 +2077,8 @@ void RenderProcessHostImpl::DecrementWorkerRefCount() {
|
| void RenderProcessHostImpl::ConnectTo(
|
| const base::StringPiece& service_name,
|
| mojo::ScopedMessagePipeHandle handle) {
|
| - if (!mojo_application_host_->did_activate())
|
| - mojo_application_host_->Activate(this, GetHandle());
|
| + mojo_activation_required_ = true;
|
| + MaybeActivateMojo();
|
|
|
| mojo::AllocationScope scope;
|
| mojo_application_host_->shell_client()->AcceptConnection(service_name,
|
|
|