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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 13 #include "chrome/browser/nacl_host/nacl_host_messages.h" |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/render_messages.h" | |
15 #include "chrome/renderer/chrome_render_process_observer.h" | 15 #include "chrome/renderer/chrome_render_process_observer.h" |
16 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
18 #include "content/public/common/sandbox_init.h" | 18 #include "content/public/common/sandbox_init.h" |
19 #include "content/public/renderer/renderer_ppapi_host.h" | 19 #include "content/public/renderer/renderer_ppapi_host.h" |
20 #include "content/public/renderer/render_thread.h" | 20 #include "content/public/renderer/render_thread.h" |
21 #include "content/public/renderer/render_view.h" | 21 #include "content/public/renderer/render_view.h" |
22 #include "ipc/ipc_sync_message_filter.h" | 22 #include "ipc/ipc_sync_message_filter.h" |
23 #include "ppapi/c/pp_bool.h" | 23 #include "ppapi/c/pp_bool.h" |
24 #include "ppapi/c/private/pp_file_handle.h" | 24 #include "ppapi/c/private/pp_file_handle.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 uint32_t perm_bits = ppapi::PERMISSION_NONE; | 96 uint32_t perm_bits = ppapi::PERMISSION_NONE; |
97 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so | 97 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so |
98 // it's clearer to developers when they are using 'Dev' inappropriately. We | 98 // it's clearer to developers when they are using 'Dev' inappropriately. We |
99 // must also check on the trusted side of the proxy. | 99 // must also check on the trusted side of the proxy. |
100 if (enable_ppapi_dev) | 100 if (enable_ppapi_dev) |
101 perm_bits |= ppapi::PERMISSION_DEV; | 101 perm_bits |= ppapi::PERMISSION_DEV; |
102 instance_info.permissions = | 102 instance_info.permissions = |
103 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); | 103 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); |
104 | 104 |
105 if (!sender->Send(new ChromeViewHostMsg_LaunchNaCl( | 105 if (!sender->Send(new NaClHostMsg_LaunchNaCl( |
106 nacl::NaClLaunchParams(instance_info.url.spec(), | 106 nacl::NaClLaunchParams(instance_info.url.spec(), |
107 routing_id, | 107 routing_id, |
108 perm_bits, | 108 perm_bits, |
109 PP_ToBool(uses_irt), | 109 PP_ToBool(uses_irt), |
110 PP_ToBool(enable_dyncode_syscalls)), | 110 PP_ToBool(enable_dyncode_syscalls)), |
111 &result_socket, | 111 &result_socket, |
112 &instance_info.channel_handle, | 112 &instance_info.channel_handle, |
113 &instance_info.plugin_pid, | 113 &instance_info.plugin_pid, |
114 &instance_info.plugin_child_id))) { | 114 &instance_info.plugin_child_id))) { |
115 return PP_NACL_FAILED; | 115 return PP_NACL_FAILED; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 return 0; | 204 return 0; |
205 #endif | 205 #endif |
206 } | 206 } |
207 | 207 |
208 PP_FileHandle GetReadonlyPnaclFD(const char* filename) { | 208 PP_FileHandle GetReadonlyPnaclFD(const char* filename) { |
209 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); | 209 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); |
210 IPC::Sender* sender = content::RenderThread::Get(); | 210 IPC::Sender* sender = content::RenderThread::Get(); |
211 if (sender == NULL) | 211 if (sender == NULL) |
212 sender = g_background_thread_sender.Pointer()->get(); | 212 sender = g_background_thread_sender.Pointer()->get(); |
213 | 213 |
214 if (!sender->Send(new ChromeViewHostMsg_GetReadonlyPnaclFD( | 214 if (!sender->Send(new NaClHostMsg_GetReadonlyPnaclFD( |
215 std::string(filename), | 215 std::string(filename), |
216 &out_fd))) { | 216 &out_fd))) { |
217 return base::kInvalidPlatformFileValue; | 217 return base::kInvalidPlatformFileValue; |
218 } | 218 } |
219 | 219 |
220 if (out_fd == IPC::InvalidPlatformFileForTransit()) { | 220 if (out_fd == IPC::InvalidPlatformFileForTransit()) { |
221 return base::kInvalidPlatformFileValue; | 221 return base::kInvalidPlatformFileValue; |
222 } | 222 } |
223 | 223 |
224 base::PlatformFile handle = | 224 base::PlatformFile handle = |
225 IPC::PlatformFileForTransitToPlatformFile(out_fd); | 225 IPC::PlatformFileForTransitToPlatformFile(out_fd); |
226 return handle; | 226 return handle; |
227 } | 227 } |
228 | 228 |
229 PP_FileHandle CreateTemporaryFile(PP_Instance instance) { | 229 PP_FileHandle CreateTemporaryFile(PP_Instance instance) { |
230 IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit(); | 230 IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit(); |
231 IPC::Sender* sender = content::RenderThread::Get(); | 231 IPC::Sender* sender = content::RenderThread::Get(); |
232 if (sender == NULL) | 232 if (sender == NULL) |
233 sender = g_background_thread_sender.Pointer()->get(); | 233 sender = g_background_thread_sender.Pointer()->get(); |
234 | 234 |
235 if (!sender->Send(new ChromeViewHostMsg_NaClCreateTemporaryFile( | 235 if (!sender->Send(new NaClHostMsg_NaClCreateTemporaryFile( |
236 &transit_fd))) { | 236 &transit_fd))) { |
237 return base::kInvalidPlatformFileValue; | 237 return base::kInvalidPlatformFileValue; |
238 } | 238 } |
239 | 239 |
240 if (transit_fd == IPC::InvalidPlatformFileForTransit()) { | 240 if (transit_fd == IPC::InvalidPlatformFileForTransit()) { |
241 return base::kInvalidPlatformFileValue; | 241 return base::kInvalidPlatformFileValue; |
242 } | 242 } |
243 | 243 |
244 base::PlatformFile handle = IPC::PlatformFileForTransitToPlatformFile( | 244 base::PlatformFile handle = IPC::PlatformFileForTransitToPlatformFile( |
245 transit_fd); | 245 transit_fd); |
246 return handle; | 246 return handle; |
247 } | 247 } |
248 | 248 |
249 PP_Bool IsOffTheRecord() { | 249 PP_Bool IsOffTheRecord() { |
250 return PP_FromBool(ChromeRenderProcessObserver::is_incognito_process()); | 250 return PP_FromBool(ChromeRenderProcessObserver::is_incognito_process()); |
251 } | 251 } |
252 | 252 |
253 PP_Bool IsPnaclEnabled() { | 253 PP_Bool IsPnaclEnabled() { |
254 return PP_FromBool( | 254 return PP_FromBool( |
255 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePnacl)); | 255 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePnacl)); |
256 } | 256 } |
257 | 257 |
258 PP_NaClResult ReportNaClError(PP_Instance instance, | 258 PP_NaClResult ReportNaClError(PP_Instance instance, |
259 PP_NaClError error_id) { | 259 PP_NaClError error_id) { |
260 IPC::Sender* sender = content::RenderThread::Get(); | 260 IPC::Sender* sender = content::RenderThread::Get(); |
261 | 261 |
262 if (!sender->Send( | 262 if (!sender->Send( |
263 new ChromeViewHostMsg_NaClErrorStatus( | 263 new NaClHostMsg_NaClErrorStatus( |
264 // TODO(dschuff): does this enum need to be sent as an int, | 264 // TODO(dschuff): does this enum need to be sent as an int, |
265 // or is it safe to include the appropriate headers in | 265 // or is it safe to include the appropriate headers in |
266 // render_messages.h? | 266 // render_messages.h? |
267 GetRoutingID(instance), static_cast<int>(error_id)))) { | 267 GetRoutingID(instance), static_cast<int>(error_id)))) { |
268 return PP_NACL_FAILED; | 268 return PP_NACL_FAILED; |
269 } | 269 } |
270 return PP_NACL_OK; | 270 return PP_NACL_OK; |
271 } | 271 } |
272 | 272 |
273 PP_FileHandle OpenNaClExecutable(PP_Instance instance, | 273 PP_FileHandle OpenNaClExecutable(PP_Instance instance, |
274 const char* file_url, | 274 const char* file_url, |
275 uint64_t* nonce_lo, | 275 uint64_t* nonce_lo, |
276 uint64_t* nonce_hi) { | 276 uint64_t* nonce_hi) { |
277 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); | 277 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); |
278 IPC::Sender* sender = content::RenderThread::Get(); | 278 IPC::Sender* sender = content::RenderThread::Get(); |
279 if (sender == NULL) | 279 if (sender == NULL) |
280 sender = g_background_thread_sender.Pointer()->get(); | 280 sender = g_background_thread_sender.Pointer()->get(); |
281 | 281 |
282 *nonce_lo = 0; | 282 *nonce_lo = 0; |
283 *nonce_hi = 0; | 283 *nonce_hi = 0; |
284 base::FilePath file_path; | 284 base::FilePath file_path; |
285 if (!sender->Send( | 285 if (!sender->Send( |
286 new ChromeViewHostMsg_OpenNaClExecutable(GetRoutingID(instance), | 286 new NaClHostMsg_OpenNaClExecutable(GetRoutingID(instance), |
287 GURL(file_url), | 287 GURL(file_url), |
288 &out_fd, | 288 &out_fd, |
289 nonce_lo, | 289 nonce_lo, |
290 nonce_hi))) { | 290 nonce_hi))) { |
291 return base::kInvalidPlatformFileValue; | 291 return base::kInvalidPlatformFileValue; |
292 } | 292 } |
293 | 293 |
294 if (out_fd == IPC::InvalidPlatformFileForTransit()) { | 294 if (out_fd == IPC::InvalidPlatformFileForTransit()) { |
295 return base::kInvalidPlatformFileValue; | 295 return base::kInvalidPlatformFileValue; |
296 } | 296 } |
(...skipping 18 matching lines...) Expand all Loading... |
315 &OpenNaClExecutable | 315 &OpenNaClExecutable |
316 }; | 316 }; |
317 | 317 |
318 } // namespace | 318 } // namespace |
319 | 319 |
320 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { | 320 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { |
321 return &nacl_interface; | 321 return &nacl_interface; |
322 } | 322 } |
323 | 323 |
324 #endif // DISABLE_NACL | 324 #endif // DISABLE_NACL |
OLD | NEW |