Chromium Code Reviews| Index: chrome/browser/nacl_host/nacl_process_host.cc |
| =================================================================== |
| --- chrome/browser/nacl_host/nacl_process_host.cc (revision 154817) |
| +++ chrome/browser/nacl_host/nacl_process_host.cc (working copy) |
| @@ -34,6 +34,9 @@ |
| #include "chrome/common/url_constants.h" |
| #include "content/public/browser/browser_child_process_host.h" |
| #include "content/public/browser/child_process_data.h" |
| +#include "content/public/browser/pepper_helper.h" |
| +#include "content/public/browser/render_process_host.h" |
| +#include "content/public/browser/resource_context.h" |
| #include "content/public/common/child_process_host.h" |
| #include "ipc/ipc_channel.h" |
| #include "ipc/ipc_switches.h" |
| @@ -59,6 +62,8 @@ |
| using content::BrowserThread; |
| using content::ChildProcessData; |
| using content::ChildProcessHost; |
| +using content::RenderProcessHost; |
| +using content::ResourceContext; |
| using ppapi::proxy::SerializedHandle; |
| namespace { |
| @@ -712,13 +717,21 @@ |
| &ipc_plugin_listener_, |
| base::MessageLoopProxy::current())); |
| // Send a message to create the NaCl-Renderer channel. The handle is just |
| - // a place holder. |
| + // a place holder, filled in by NaCl process trusted code. |
| ipc_proxy_channel_->Send( |
| new PpapiMsg_CreateNaClChannel( |
| chrome_render_message_filter_->render_process_id(), |
| chrome_render_message_filter_->off_the_record(), |
| SerializedHandle(SerializedHandle::CHANNEL_HANDLE, |
| IPC::InvalidPlatformFileForTransit()))); |
| + // We will need a ResourceContext to enable the channel so messages get |
| + // dispatched to the browser. This must be accessed on the UI thread. |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind(&NaClProcessHost::EnablePpapiChannelOnUIThread, |
| + base::Unretained(this), |
|
brettw
2012/09/06 23:38:09
You're using unretained here and below. What ensur
bbudge
2012/09/08 01:17:27
Moving this to PMF. Done.
|
| + chrome_render_message_filter_->render_process_id())); |
| } else if (reply_msg_) { |
| // Otherwise, this must be a renderer channel. |
| ReplyToRenderer(channel_handle); |
| @@ -729,6 +742,28 @@ |
| } |
| } |
| +void NaClProcessHost::EnablePpapiChannelOnUIThread( |
| + int render_process_id) { |
| + content::RenderProcessHost* rph = |
| + content::RenderProcessHost::FromID(render_process_id); |
| + if (rph) { |
| + // ResourceContext::GetHostResolver must be called on the IO thread. |
| + BrowserThread::PostTask( |
| + BrowserThread::IO, |
| + FROM_HERE, |
| + base::Bind(&NaClProcessHost::EnablePpapiChannelOnIOThread, |
| + base::Unretained(this), |
| + rph->GetBrowserContext()->GetResourceContext())); |
| + } |
| +} |
| + |
| +void NaClProcessHost::EnablePpapiChannelOnIOThread( |
| + ResourceContext* resource_context) { |
| + DCHECK(resource_context); |
| + content::PepperHelper::EnablePepperSupportForChannel( |
| + ipc_proxy_channel_.get(), resource_context->GetHostResolver()); |
| +} |
| + |
| bool NaClProcessHost::OnUntrustedMessageForwarded(const IPC::Message& msg) { |
| // Handle messages that have been forwarded from our PluginListener. |
| // These messages come from untrusted code so should be handled with care. |