| Index: chrome/renderer/pepper/ppb_nacl_private_impl.cc
|
| ===================================================================
|
| --- chrome/renderer/pepper/ppb_nacl_private_impl.cc (revision 136022)
|
| +++ chrome/renderer/pepper/ppb_nacl_private_impl.cc (working copy)
|
| @@ -9,44 +9,97 @@
|
| #include "base/command_line.h"
|
| #include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| +#include "base/path_service.h"
|
| #include "base/rand_util_c.h"
|
| +#include "chrome/common/chrome_paths.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/render_messages.h"
|
| +#include "content/public/common/content_client.h"
|
| #include "content/public/common/content_switches.h"
|
| #include "content/public/renderer/render_thread.h"
|
| +#include "content/public/renderer/render_view.h"
|
| #include "ipc/ipc_sync_message_filter.h"
|
| -#include "native_client/src/shared/imc/nacl_imc.h"
|
| #include "ppapi/c/private/ppb_nacl_private.h"
|
| #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.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/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"
|
|
|
| #if defined(OS_WIN)
|
| #include "content/public/common/sandbox_init.h"
|
| #endif
|
|
|
| +using content::RenderThread;
|
| +using webkit::ppapi::HostGlobals;
|
| +using webkit::ppapi::PluginInstance;
|
| +using WebKit::WebView;
|
| +
|
| 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;
|
| +
|
| // Launch NaCl's sel_ldr process.
|
| -bool LaunchSelLdr(const char* alleged_url, int socket_count,
|
| - void* imc_handles) {
|
| +PP_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();
|
| if (sender == NULL)
|
| sender = g_background_thread_sender.Pointer()->get();
|
|
|
| if (!sender->Send(new ChromeViewHostMsg_LaunchNaCl(
|
| - GURL(alleged_url), socket_count, &sockets)))
|
| - return false;
|
| + GURL(alleged_url), socket_count, &sockets,
|
| + &g_plugin_ppapi_channel,
|
| + &g_plugin_process_handle,
|
| + &g_plugin_process_id)))
|
| + return PP_FALSE;
|
|
|
| CHECK(static_cast<int>(sockets.size()) == socket_count);
|
| for (int i = 0; i < socket_count; i++) {
|
| static_cast<nacl::Handle*>(imc_handles)[i] =
|
| nacl::ToNativeHandle(sockets[i]);
|
| }
|
| - return true;
|
| +
|
| + return PP_TRUE;
|
| }
|
|
|
| +PP_Bool StartPpapiProxy(PP_Instance instance) {
|
| + if (CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableNaClIPCProxy)) {
|
| + webkit::ppapi::PluginInstance* plugin_instance =
|
| + content::GetHostGlobals()->GetInstance(instance);
|
| + if (!plugin_instance)
|
| + return PP_FALSE;
|
| + FilePath plugin_path;
|
| + if (!PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_path))
|
| + return PP_FALSE;
|
| + if (g_plugin_ppapi_channel.name.empty())
|
| + return PP_FALSE;
|
| +
|
| + WebView* view =
|
| + plugin_instance->container()->element().document().frame()->view();
|
| + content::RenderView* render_view = content::RenderView::FromWebView(view);
|
| + // Establish the HostDispatcher for the PPAPI proxy.
|
| + if (render_view->CreatePepperHostDispatcher(
|
| + plugin_path,
|
| + g_plugin_process_id,
|
| + g_plugin_process_handle,
|
| + g_plugin_ppapi_channel))
|
| + return PP_TRUE;
|
| + }
|
| +
|
| + return PP_FALSE;
|
| +}
|
| +
|
| int UrandomFD(void) {
|
| #if defined(OS_POSIX)
|
| return GetUrandomFD();
|
| @@ -80,6 +133,7 @@
|
|
|
| const PPB_NaCl_Private nacl_interface = {
|
| &LaunchSelLdr,
|
| + &StartPpapiProxy,
|
| &UrandomFD,
|
| &Are3DInterfacesDisabled,
|
| &EnableBackgroundSelLdrLaunch,
|
|
|