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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 // Launch NaCl's sel_ldr process. | 80 // Launch NaCl's sel_ldr process. |
81 PP_NaClResult LaunchSelLdr(PP_Instance instance, | 81 PP_NaClResult LaunchSelLdr(PP_Instance instance, |
82 const char* alleged_url, | 82 const char* alleged_url, |
83 PP_Bool uses_irt, | 83 PP_Bool uses_irt, |
84 PP_Bool uses_ppapi, | 84 PP_Bool uses_ppapi, |
85 PP_Bool enable_ppapi_dev, | 85 PP_Bool enable_ppapi_dev, |
86 PP_Bool enable_dyncode_syscalls, | 86 PP_Bool enable_dyncode_syscalls, |
87 PP_Bool enable_exception_handling, | 87 PP_Bool enable_exception_handling, |
88 void* imc_handle) { | 88 void* imc_handle, |
| 89 struct PP_Var* error_message) { |
89 nacl::FileDescriptor result_socket; | 90 nacl::FileDescriptor result_socket; |
90 IPC::Sender* sender = content::RenderThread::Get(); | 91 IPC::Sender* sender = content::RenderThread::Get(); |
91 DCHECK(sender); | 92 DCHECK(sender); |
| 93 *error_message = PP_MakeUndefined(); |
92 int routing_id = 0; | 94 int routing_id = 0; |
93 // If the nexe uses ppapi APIs, we need a routing ID. | 95 // If the nexe uses ppapi APIs, we need a routing ID. |
94 // To get the routing ID, we must be on the main thread. | 96 // To get the routing ID, we must be on the main thread. |
95 // Some nexes do not use ppapi and launch from the background thread, | 97 // Some nexes do not use ppapi and launch from the background thread, |
96 // so those nexes can skip finding a routing_id. | 98 // so those nexes can skip finding a routing_id. |
97 if (uses_ppapi) { | 99 if (uses_ppapi) { |
98 routing_id = GetRoutingID(instance); | 100 routing_id = GetRoutingID(instance); |
99 if (!routing_id) | 101 if (!routing_id) |
100 return PP_NACL_FAILED; | 102 return PP_NACL_FAILED; |
101 } | 103 } |
102 | 104 |
103 InstanceInfo instance_info; | 105 InstanceInfo instance_info; |
104 instance_info.url = GURL(alleged_url); | 106 instance_info.url = GURL(alleged_url); |
105 | 107 |
106 uint32_t perm_bits = ppapi::PERMISSION_NONE; | 108 uint32_t perm_bits = ppapi::PERMISSION_NONE; |
107 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so | 109 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so |
108 // it's clearer to developers when they are using 'Dev' inappropriately. We | 110 // it's clearer to developers when they are using 'Dev' inappropriately. We |
109 // must also check on the trusted side of the proxy. | 111 // must also check on the trusted side of the proxy. |
110 if (enable_ppapi_dev) | 112 if (enable_ppapi_dev) |
111 perm_bits |= ppapi::PERMISSION_DEV; | 113 perm_bits |= ppapi::PERMISSION_DEV; |
112 instance_info.permissions = | 114 instance_info.permissions = |
113 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); | 115 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); |
| 116 std::string error_message_string; |
| 117 nacl::NaClLaunchResult launch_result; |
114 | 118 |
115 if (!sender->Send(new NaClHostMsg_LaunchNaCl( | 119 if (!sender->Send(new NaClHostMsg_LaunchNaCl( |
116 nacl::NaClLaunchParams(instance_info.url.spec(), | 120 nacl::NaClLaunchParams(instance_info.url.spec(), |
117 routing_id, | 121 routing_id, |
118 perm_bits, | 122 perm_bits, |
119 PP_ToBool(uses_irt), | 123 PP_ToBool(uses_irt), |
120 PP_ToBool(enable_dyncode_syscalls), | 124 PP_ToBool(enable_dyncode_syscalls), |
121 PP_ToBool(enable_exception_handling)), | 125 PP_ToBool(enable_exception_handling)), |
122 &result_socket, | 126 &launch_result, |
123 &instance_info.channel_handle, | 127 &error_message_string))) { |
124 &instance_info.plugin_pid, | |
125 &instance_info.plugin_child_id))) { | |
126 return PP_NACL_FAILED; | 128 return PP_NACL_FAILED; |
127 } | 129 } |
128 | 130 if (!error_message_string.empty()) { |
| 131 *error_message = ppapi::StringVar::StringToPPVar(error_message_string); |
| 132 return PP_NACL_FAILED; |
| 133 } |
| 134 result_socket = launch_result.imc_channel_handle; |
| 135 instance_info.channel_handle = launch_result.ipc_channel_handle; |
| 136 instance_info.plugin_pid = launch_result.plugin_pid; |
| 137 instance_info.plugin_child_id = launch_result.plugin_child_id; |
129 // Don't save instance_info if channel handle is invalid. | 138 // Don't save instance_info if channel handle is invalid. |
130 bool invalid_handle = instance_info.channel_handle.name.empty(); | 139 bool invalid_handle = instance_info.channel_handle.name.empty(); |
131 #if defined(OS_POSIX) | 140 #if defined(OS_POSIX) |
132 if (!invalid_handle) | 141 if (!invalid_handle) |
133 invalid_handle = (instance_info.channel_handle.socket.fd == -1); | 142 invalid_handle = (instance_info.channel_handle.socket.fd == -1); |
134 #endif | 143 #endif |
135 if (!invalid_handle) | 144 if (!invalid_handle) |
136 g_instance_info.Get()[instance] = instance_info; | 145 g_instance_info.Get()[instance] = instance_info; |
137 | 146 |
138 *(static_cast<NaClHandle*>(imc_handle)) = | 147 *(static_cast<NaClHandle*>(imc_handle)) = |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 &OpenNaClExecutable | 375 &OpenNaClExecutable |
367 }; | 376 }; |
368 | 377 |
369 } // namespace | 378 } // namespace |
370 | 379 |
371 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { | 380 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { |
372 return &nacl_interface; | 381 return &nacl_interface; |
373 } | 382 } |
374 | 383 |
375 #endif // DISABLE_NACL | 384 #endif // DISABLE_NACL |
OLD | NEW |