| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/ppapi_plugin/ppapi_thread.h" | 5 #include "content/ppapi_plugin/ppapi_thread.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "content/common/child_process.h" | 13 #include "content/common/child_process.h" |
| 14 #include "content/common/sandbox_init_wrapper.h" | |
| 15 #include "content/ppapi_plugin/broker_process_dispatcher.h" | 14 #include "content/ppapi_plugin/broker_process_dispatcher.h" |
| 16 #include "content/ppapi_plugin/plugin_process_dispatcher.h" | 15 #include "content/ppapi_plugin/plugin_process_dispatcher.h" |
| 17 #include "content/ppapi_plugin/ppapi_webkit_thread.h" | 16 #include "content/ppapi_plugin/ppapi_webkit_thread.h" |
| 18 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 18 #include "content/public/common/sandbox_init.h" |
| 19 #include "ipc/ipc_channel_handle.h" | 19 #include "ipc/ipc_channel_handle.h" |
| 20 #include "ipc/ipc_sync_channel.h" | 20 #include "ipc/ipc_sync_channel.h" |
| 21 #include "ppapi/c/dev/ppp_network_state_dev.h" | 21 #include "ppapi/c/dev/ppp_network_state_dev.h" |
| 22 #include "ppapi/c/pp_errors.h" | 22 #include "ppapi/c/pp_errors.h" |
| 23 #include "ppapi/c/ppp.h" | 23 #include "ppapi/c/ppp.h" |
| 24 #include "ppapi/proxy/ppapi_messages.h" | 24 #include "ppapi/proxy/ppapi_messages.h" |
| 25 #include "ppapi/proxy/interface_list.h" | 25 #include "ppapi/proxy/interface_list.h" |
| 26 #include "webkit/plugins/ppapi/webkit_forwarding_impl.h" | 26 #include "webkit/plugins/ppapi/webkit_forwarding_impl.h" |
| 27 | 27 |
| 28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 library.GetFunctionPointer("PPP_GetInterface")); | 194 library.GetFunctionPointer("PPP_GetInterface")); |
| 195 if (!get_plugin_interface_) { | 195 if (!get_plugin_interface_) { |
| 196 LOG(WARNING) << "No PPP_GetInterface in plugin library"; | 196 LOG(WARNING) << "No PPP_GetInterface in plugin library"; |
| 197 return; | 197 return; |
| 198 } | 198 } |
| 199 | 199 |
| 200 #if defined(OS_MACOSX) | 200 #if defined(OS_MACOSX) |
| 201 // We need to do this after getting |PPP_GetInterface()| (or presumably | 201 // We need to do this after getting |PPP_GetInterface()| (or presumably |
| 202 // doing something nontrivial with the library), else the sandbox | 202 // doing something nontrivial with the library), else the sandbox |
| 203 // intercedes. | 203 // intercedes. |
| 204 CommandLine* parsed_command_line = CommandLine::ForCurrentProcess(); | 204 if (!content::InitializeSandbox()) { |
| 205 SandboxInitWrapper sandbox_wrapper; | |
| 206 if (!sandbox_wrapper.InitializeSandbox(*parsed_command_line, | |
| 207 switches::kPpapiPluginProcess)) | |
| 208 LOG(WARNING) << "Failed to initialize sandbox"; | 205 LOG(WARNING) << "Failed to initialize sandbox"; |
| 206 } |
| 209 #endif | 207 #endif |
| 210 | 208 |
| 211 // Get the InitializeModule function (required). | 209 // Get the InitializeModule function (required). |
| 212 ppapi::proxy::Dispatcher::InitModuleFunc init_module = | 210 ppapi::proxy::Dispatcher::InitModuleFunc init_module = |
| 213 reinterpret_cast<ppapi::proxy::Dispatcher::InitModuleFunc>( | 211 reinterpret_cast<ppapi::proxy::Dispatcher::InitModuleFunc>( |
| 214 library.GetFunctionPointer("PPP_InitializeModule")); | 212 library.GetFunctionPointer("PPP_InitializeModule")); |
| 215 if (!init_module) { | 213 if (!init_module) { |
| 216 LOG(WARNING) << "No PPP_InitializeModule in plugin library"; | 214 LOG(WARNING) << "No PPP_InitializeModule in plugin library"; |
| 217 return; | 215 return; |
| 218 } | 216 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 #if defined(OS_POSIX) | 299 #if defined(OS_POSIX) |
| 302 // On POSIX, pass the renderer-side FD. | 300 // On POSIX, pass the renderer-side FD. |
| 303 handle->socket = base::FileDescriptor(::dup(dispatcher->GetRendererFD()), | 301 handle->socket = base::FileDescriptor(::dup(dispatcher->GetRendererFD()), |
| 304 true); | 302 true); |
| 305 #endif | 303 #endif |
| 306 | 304 |
| 307 // From here, the dispatcher will manage its own lifetime according to the | 305 // From here, the dispatcher will manage its own lifetime according to the |
| 308 // lifetime of the attached channel. | 306 // lifetime of the attached channel. |
| 309 return true; | 307 return true; |
| 310 } | 308 } |
| OLD | NEW |