OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/renderer/pepper/ppb_nacl_private_impl.h" | 5 #include "chrome/renderer/pepper/ppb_nacl_private_impl.h" |
6 | 6 |
7 #ifndef DISABLE_NACL | 7 #ifndef DISABLE_NACL |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 }; | 50 }; |
51 | 51 |
52 typedef std::map<PP_Instance, InstanceInfo> InstanceInfoMap; | 52 typedef std::map<PP_Instance, InstanceInfo> InstanceInfoMap; |
53 | 53 |
54 base::LazyInstance<InstanceInfoMap> g_instance_info = | 54 base::LazyInstance<InstanceInfoMap> g_instance_info = |
55 LAZY_INSTANCE_INITIALIZER; | 55 LAZY_INSTANCE_INITIALIZER; |
56 | 56 |
57 // Launch NaCl's sel_ldr process. | 57 // Launch NaCl's sel_ldr process. |
58 PP_NaClResult LaunchSelLdr(PP_Instance instance, | 58 PP_NaClResult LaunchSelLdr(PP_Instance instance, |
59 const char* alleged_url, | 59 const char* alleged_url, |
60 PP_Bool uses_ppapi, | |
60 PP_Bool enable_ppapi_dev, | 61 PP_Bool enable_ppapi_dev, |
61 int socket_count, | 62 int socket_count, |
62 void* imc_handles) { | 63 void* imc_handles) { |
63 std::vector<nacl::FileDescriptor> sockets; | 64 std::vector<nacl::FileDescriptor> sockets; |
64 IPC::Sender* sender = content::RenderThread::Get(); | 65 IPC::Sender* sender = content::RenderThread::Get(); |
65 if (sender == NULL) | 66 if (sender == NULL) |
66 sender = g_background_thread_sender.Pointer()->get(); | 67 sender = g_background_thread_sender.Pointer()->get(); |
67 | 68 |
68 webkit::ppapi::PluginInstance* plugin_instance = | 69 int routing_id = 0; |
69 content::GetHostGlobals()->GetInstance(instance); | 70 // If the nexe uses ppapi APIs, we need a routing ID. |
70 if (!plugin_instance) | 71 // To get the routing ID, we must be on the main thread. |
71 return PP_NACL_FAILED; | 72 // Some nexes do not use ppapi and launch from the background thread, |
73 // so those nexes can skip finding a routing_id. | |
74 if (uses_ppapi) { | |
75 webkit::ppapi::PluginInstance* plugin_instance = | |
brettw
2012/11/29 04:57:18
Can you add an assertion at the top here that cont
jvoung (off chromium)
2012/11/29 22:46:46
Done.
| |
76 content::GetHostGlobals()->GetInstance(instance); | |
77 if (!plugin_instance) | |
78 return PP_NACL_FAILED; | |
72 | 79 |
73 WebKit::WebView* web_view = | 80 WebKit::WebView* web_view = |
74 plugin_instance->container()->element().document().frame()->view(); | 81 plugin_instance->container()->element().document().frame()->view(); |
75 content::RenderView* render_view = | 82 content::RenderView* render_view = |
76 content::RenderView::FromWebView(web_view); | 83 content::RenderView::FromWebView(web_view); |
77 if (!render_view) | 84 if (!render_view) |
78 return PP_NACL_FAILED; | 85 return PP_NACL_FAILED; |
86 routing_id = render_view->GetRoutingID(); | |
87 } | |
79 | 88 |
80 InstanceInfo instance_info; | 89 InstanceInfo instance_info; |
81 instance_info.url = GURL(alleged_url); | 90 instance_info.url = GURL(alleged_url); |
82 | 91 |
83 uint32_t perm_bits = ppapi::PERMISSION_NONE; | 92 uint32_t perm_bits = ppapi::PERMISSION_NONE; |
84 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so | 93 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so |
85 // it's clearer to developers when they are using 'Dev' inappropriately. We | 94 // it's clearer to developers when they are using 'Dev' inappropriately. We |
86 // must also check on the trusted side of the proxy. | 95 // must also check on the trusted side of the proxy. |
87 // TODO(bbudge) verify we're blocking 'Dev' interfaces on the trusted side. | 96 // TODO(bbudge) verify we're blocking 'Dev' interfaces on the trusted side. |
88 if (enable_ppapi_dev) | 97 if (enable_ppapi_dev) |
89 perm_bits |= ppapi::PERMISSION_DEV; | 98 perm_bits |= ppapi::PERMISSION_DEV; |
90 instance_info.permissions = ppapi::PpapiPermissions(perm_bits); | 99 instance_info.permissions = ppapi::PpapiPermissions(perm_bits); |
91 | 100 |
92 if (!sender->Send(new ChromeViewHostMsg_LaunchNaCl( | 101 if (!sender->Send(new ChromeViewHostMsg_LaunchNaCl( |
93 instance_info.url, | 102 instance_info.url, |
94 render_view->GetRoutingID(), | 103 routing_id, |
95 perm_bits, | 104 perm_bits, |
96 socket_count, &sockets, | 105 socket_count, &sockets, |
97 &instance_info.channel_handle, | 106 &instance_info.channel_handle, |
98 &instance_info.plugin_child_id))) { | 107 &instance_info.plugin_child_id))) { |
99 return PP_NACL_FAILED; | 108 return PP_NACL_FAILED; |
100 } | 109 } |
101 | 110 |
102 // Don't save instance_info if channel handle is invalid. | 111 // Don't save instance_info if channel handle is invalid. |
103 bool invalid_handle = instance_info.channel_handle.name.empty(); | 112 bool invalid_handle = instance_info.channel_handle.name.empty(); |
104 #if defined(OS_POSIX) | 113 #if defined(OS_POSIX) |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 &IsPnaclEnabled | 263 &IsPnaclEnabled |
255 }; | 264 }; |
256 | 265 |
257 } // namespace | 266 } // namespace |
258 | 267 |
259 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { | 268 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { |
260 return &nacl_interface; | 269 return &nacl_interface; |
261 } | 270 } |
262 | 271 |
263 #endif // DISABLE_NACL | 272 #endif // DISABLE_NACL |
OLD | NEW |