Chromium Code Reviews| 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/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| 11 #include "content/common/child_process.h" | 11 #include "content/common/child_process.h" |
| 12 #include "content/ppapi_plugin/broker_process_dispatcher.h" | 12 #include "content/ppapi_plugin/broker_process_dispatcher.h" |
| 13 #include "content/ppapi_plugin/plugin_process_dispatcher.h" | 13 #include "content/ppapi_plugin/plugin_process_dispatcher.h" |
| 14 #include "ipc/ipc_channel_handle.h" | 14 #include "ipc/ipc_channel_handle.h" |
| 15 #include "ipc/ipc_sync_channel.h" | 15 #include "ipc/ipc_sync_channel.h" |
| 16 #include "ppapi/c/pp_errors.h" | 16 #include "ppapi/c/pp_errors.h" |
| 17 #include "ppapi/c/ppp.h" | 17 #include "ppapi/c/ppp.h" |
| 18 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
| 19 | 19 |
| 20 #if defined(OS_WIN) | |
| 21 #include "sandbox/src/sandbox.h" | |
| 22 #endif | |
| 23 | |
| 24 #if defined(OS_WIN) | |
| 25 extern sandbox::TargetServices* g_target_services; | |
| 26 #else | |
| 27 extern void* g_target_services = 0; | |
|
brettw
2011/05/06 04:30:52
Don't initialize extern.
| |
| 28 #endif | |
| 29 | |
| 20 typedef int32_t (*InitializeBrokerFunc) | 30 typedef int32_t (*InitializeBrokerFunc) |
| 21 (PP_ConnectInstance_Func* connect_instance_func); | 31 (PP_ConnectInstance_Func* connect_instance_func); |
| 22 | 32 |
| 23 PpapiThread::PpapiThread(bool is_broker) | 33 PpapiThread::PpapiThread(bool is_broker) |
| 24 : is_broker_(is_broker), | 34 : is_broker_(is_broker), |
| 25 get_plugin_interface_(NULL), | 35 get_plugin_interface_(NULL), |
| 26 connect_instance_func_(NULL), | 36 connect_instance_func_(NULL), |
| 27 local_pp_module_( | 37 local_pp_module_( |
| 28 base::RandInt(0, std::numeric_limits<PP_Module>::max())) { | 38 base::RandInt(0, std::numeric_limits<PP_Module>::max())) { |
| 29 } | 39 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 base::WaitableEvent* PpapiThread::GetShutdownEvent() { | 75 base::WaitableEvent* PpapiThread::GetShutdownEvent() { |
| 66 return ChildProcess::current()->GetShutDownEvent(); | 76 return ChildProcess::current()->GetShutDownEvent(); |
| 67 } | 77 } |
| 68 | 78 |
| 69 std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() { | 79 std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() { |
| 70 return &globally_seen_instance_ids_; | 80 return &globally_seen_instance_ids_; |
| 71 } | 81 } |
| 72 | 82 |
| 73 void PpapiThread::OnMsgLoadPlugin(const FilePath& path) { | 83 void PpapiThread::OnMsgLoadPlugin(const FilePath& path) { |
| 74 base::ScopedNativeLibrary library(base::LoadNativeLibrary(path, NULL)); | 84 base::ScopedNativeLibrary library(base::LoadNativeLibrary(path, NULL)); |
| 75 if (!library.is_valid()) | 85 |
| 86 #if defined(OS_WIN) | |
| 87 // Once we lower the token the sandbox is locked down and no new modules | |
| 88 // can be loaded. TODO(cpu): consider changing to the loading style of | |
| 89 // regular plugins. | |
| 90 if (g_target_services) | |
| 91 g_target_services->LowerToken(); | |
| 92 #endif | |
| 93 | |
| 94 if (!library.is_valid()) { | |
| 95 LOG(ERROR) << "Failed to load pepper module"; | |
| 76 return; | 96 return; |
| 97 } | |
| 77 | 98 |
| 78 if (is_broker_) { | 99 if (is_broker_) { |
| 79 // Get the InitializeBroker function (required). | 100 // Get the InitializeBroker function (required). |
| 80 InitializeBrokerFunc init_broker = | 101 InitializeBrokerFunc init_broker = |
| 81 reinterpret_cast<InitializeBrokerFunc>( | 102 reinterpret_cast<InitializeBrokerFunc>( |
| 82 library.GetFunctionPointer("PPP_InitializeBroker")); | 103 library.GetFunctionPointer("PPP_InitializeBroker")); |
| 83 if (!init_broker) { | 104 if (!init_broker) { |
| 84 LOG(WARNING) << "No PPP_InitializeBroker in plugin library"; | 105 LOG(WARNING) << "No PPP_InitializeBroker in plugin library"; |
| 85 return; | 106 return; |
| 86 } | 107 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 #if defined(OS_POSIX) | 194 #if defined(OS_POSIX) |
| 174 // On POSIX, pass the renderer-side FD. | 195 // On POSIX, pass the renderer-side FD. |
| 175 handle->socket = base::FileDescriptor(::dup(dispatcher->GetRendererFD()), | 196 handle->socket = base::FileDescriptor(::dup(dispatcher->GetRendererFD()), |
| 176 true); | 197 true); |
| 177 #endif | 198 #endif |
| 178 | 199 |
| 179 // From here, the dispatcher will manage its own lifetime according to the | 200 // From here, the dispatcher will manage its own lifetime according to the |
| 180 // lifetime of the attached channel. | 201 // lifetime of the attached channel. |
| 181 return true; | 202 return true; |
| 182 } | 203 } |
| OLD | NEW |