Index: chrome/renderer/pepper/ppb_nacl_private_impl.cc |
=================================================================== |
--- chrome/renderer/pepper/ppb_nacl_private_impl.cc (revision 135227) |
+++ chrome/renderer/pepper/ppb_nacl_private_impl.cc (working copy) |
@@ -22,13 +22,39 @@ |
#include "content/public/common/sandbox_init.h" |
#endif |
+#include "base/path_service.h" |
+#include "chrome/common/chrome_paths.h" |
+#include "content/public/browser/plugin_service.h" |
+#include "content/public/common/content_client.h" |
+#include "content/public/renderer/render_thread.h" |
+#include "content/public/renderer/render_view.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
+#include "webkit/plugins/ppapi/host_globals.h" |
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
+ |
+using content::RenderThread; |
+using webkit::ppapi::HostGlobals; |
+using webkit::ppapi::PluginInstance; |
+using WebKit::WebElement; |
+using WebKit::WebView; |
bbudge
2012/05/07 18:08:53
I will get these sorted and pruned down to just wh
|
+ |
namespace { |
base::LazyInstance<scoped_refptr<IPC::SyncMessageFilter> > |
g_background_thread_sender = LAZY_INSTANCE_INITIALIZER; |
+IPC::ChannelHandle g_plugin_ppapi_channel; |
+base::ProcessHandle g_plugin_process_handle; |
+base::ProcessId g_plugin_process_id; |
bbudge
2012/05/07 18:08:53
I need to figure out what to do with these globals
|
+ |
// Launch NaCl's sel_ldr process. |
-bool LaunchSelLdr(const char* alleged_url, int socket_count, |
+bool LaunchSelLdr(PP_Instance instance, |
+ const char* alleged_url, int socket_count, |
void* imc_handles) { |
std::vector<nacl::FileDescriptor> sockets; |
IPC::Message::Sender* sender = content::RenderThread::Get(); |
@@ -36,7 +62,10 @@ |
sender = g_background_thread_sender.Pointer()->get(); |
if (!sender->Send(new ChromeViewHostMsg_LaunchNaCl( |
- GURL(alleged_url), socket_count, &sockets))) |
+ GURL(alleged_url), socket_count, &sockets, |
+ &g_plugin_ppapi_channel, |
+ &g_plugin_process_handle, |
+ &g_plugin_process_id))) |
return false; |
CHECK(static_cast<int>(sockets.size()) == socket_count); |
@@ -44,9 +73,33 @@ |
static_cast<nacl::Handle*>(imc_handles)[i] = |
nacl::ToNativeHandle(sockets[i]); |
} |
+ |
return true; |
} |
+bool StartPpapiProxy(PP_Instance instance) { |
+ // Using the RenderView, establish the HostDispatcher for the PPAPI proxy. |
+ webkit::ppapi::PluginInstance* plugin_instance = |
+ content::GetHostGlobals()->GetInstance(instance); |
+ if (!plugin_instance) |
+ return false; |
+ FilePath plugin_path; |
+ if (!PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_path)) |
+ return false; |
+ if (g_plugin_ppapi_channel.name.empty()) |
+ return false; |
+ |
+ WebView* view = |
+ plugin_instance->container()->element().document().frame()->view(); |
+ content::RenderView* render_view = content::RenderView::FromWebView(view); |
+ render_view->CreatePepperHostDispatcher(plugin_path, |
+ g_plugin_process_id, |
+ g_plugin_process_handle, |
+ g_plugin_ppapi_channel); |
+ |
+ return true; |
+} |
+ |
int UrandomFD(void) { |
#if defined(OS_POSIX) |
return GetUrandomFD(); |
@@ -80,6 +133,7 @@ |
const PPB_NaCl_Private nacl_interface = { |
&LaunchSelLdr, |
+ &StartPpapiProxy, |
&UrandomFD, |
&Are3DInterfacesDisabled, |
&EnableBackgroundSelLdrLaunch, |