| 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 "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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #elif defined(OS_MACOSX) | 38 #elif defined(OS_MACOSX) |
| 39 #include "content/common/sandbox_init_mac.h" | 39 #include "content/common/sandbox_init_mac.h" |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 43 extern sandbox::TargetServices* g_target_services; | 43 extern sandbox::TargetServices* g_target_services; |
| 44 #else | 44 #else |
| 45 extern void* g_target_services; | 45 extern void* g_target_services; |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 namespace content { |
| 49 |
| 48 typedef int32_t (*InitializeBrokerFunc) | 50 typedef int32_t (*InitializeBrokerFunc) |
| 49 (PP_ConnectInstance_Func* connect_instance_func); | 51 (PP_ConnectInstance_Func* connect_instance_func); |
| 50 | 52 |
| 51 PpapiThread::PpapiThread(const CommandLine& command_line, bool is_broker) | 53 PpapiThread::PpapiThread(const CommandLine& command_line, bool is_broker) |
| 52 : is_broker_(is_broker), | 54 : is_broker_(is_broker), |
| 53 get_plugin_interface_(NULL), | 55 get_plugin_interface_(NULL), |
| 54 connect_instance_func_(NULL), | 56 connect_instance_func_(NULL), |
| 55 local_pp_module_( | 57 local_pp_module_( |
| 56 base::RandInt(0, std::numeric_limits<PP_Module>::max())), | 58 base::RandInt(0, std::numeric_limits<PP_Module>::max())), |
| 57 next_plugin_dispatcher_id_(1) { | 59 next_plugin_dispatcher_id_(1) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 const IPC::SyncChannel& channel, | 150 const IPC::SyncChannel& channel, |
| 149 bool should_close_source) { | 151 bool should_close_source) { |
| 150 #if defined(OS_WIN) | 152 #if defined(OS_WIN) |
| 151 if (peer_handle_.IsValid()) { | 153 if (peer_handle_.IsValid()) { |
| 152 DCHECK(is_broker_); | 154 DCHECK(is_broker_); |
| 153 return IPC::GetFileHandleForProcess(handle, peer_handle_, | 155 return IPC::GetFileHandleForProcess(handle, peer_handle_, |
| 154 should_close_source); | 156 should_close_source); |
| 155 } | 157 } |
| 156 #endif | 158 #endif |
| 157 | 159 |
| 158 return content::BrokerGetFileHandleForProcess(handle, channel.peer_pid(), | 160 return BrokerGetFileHandleForProcess(handle, channel.peer_pid(), |
| 159 should_close_source); | 161 should_close_source); |
| 160 } | 162 } |
| 161 | 163 |
| 162 std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() { | 164 std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() { |
| 163 return &globally_seen_instance_ids_; | 165 return &globally_seen_instance_ids_; |
| 164 } | 166 } |
| 165 | 167 |
| 166 bool PpapiThread::SendToBrowser(IPC::Message* msg) { | 168 bool PpapiThread::SendToBrowser(IPC::Message* msg) { |
| 167 if (MessageLoop::current() == message_loop()) | 169 if (MessageLoop::current() == message_loop()) |
| 168 return ChildThread::Send(msg); | 170 return ChildThread::Send(msg); |
| 169 | 171 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 180 } | 182 } |
| 181 | 183 |
| 182 void PpapiThread::PreCacheFont(const void* logfontw) { | 184 void PpapiThread::PreCacheFont(const void* logfontw) { |
| 183 #if defined(OS_WIN) | 185 #if defined(OS_WIN) |
| 184 Send(new ChildProcessHostMsg_PreCacheFont( | 186 Send(new ChildProcessHostMsg_PreCacheFont( |
| 185 *static_cast<const LOGFONTW*>(logfontw))); | 187 *static_cast<const LOGFONTW*>(logfontw))); |
| 186 #endif | 188 #endif |
| 187 } | 189 } |
| 188 | 190 |
| 189 void PpapiThread::SetActiveURL(const std::string& url) { | 191 void PpapiThread::SetActiveURL(const std::string& url) { |
| 190 content::GetContentClient()->SetActiveURL(GURL(url)); | 192 GetContentClient()->SetActiveURL(GURL(url)); |
| 191 } | 193 } |
| 192 | 194 |
| 193 uint32 PpapiThread::Register(ppapi::proxy::PluginDispatcher* plugin_dispatcher)
{ | 195 uint32 PpapiThread::Register(ppapi::proxy::PluginDispatcher* plugin_dispatcher)
{ |
| 194 if (!plugin_dispatcher || | 196 if (!plugin_dispatcher || |
| 195 plugin_dispatchers_.size() >= std::numeric_limits<uint32>::max()) { | 197 plugin_dispatchers_.size() >= std::numeric_limits<uint32>::max()) { |
| 196 return 0; | 198 return 0; |
| 197 } | 199 } |
| 198 | 200 |
| 199 uint32 id = 0; | 201 uint32 id = 0; |
| 200 do { | 202 do { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 271 } |
| 270 if (!connect_instance_func_) { | 272 if (!connect_instance_func_) { |
| 271 LOG(WARNING) << "InitBroker did not provide PP_ConnectInstance_Func"; | 273 LOG(WARNING) << "InitBroker did not provide PP_ConnectInstance_Func"; |
| 272 return; | 274 return; |
| 273 } | 275 } |
| 274 } else { | 276 } else { |
| 275 #if defined(OS_MACOSX) | 277 #if defined(OS_MACOSX) |
| 276 // We need to do this after getting |PPP_GetInterface()| (or presumably | 278 // We need to do this after getting |PPP_GetInterface()| (or presumably |
| 277 // doing something nontrivial with the library), else the sandbox | 279 // doing something nontrivial with the library), else the sandbox |
| 278 // intercedes. | 280 // intercedes. |
| 279 if (!content::InitializeSandbox()) { | 281 if (!InitializeSandbox()) { |
| 280 LOG(WARNING) << "Failed to initialize sandbox"; | 282 LOG(WARNING) << "Failed to initialize sandbox"; |
| 281 } | 283 } |
| 282 #endif | 284 #endif |
| 283 | 285 |
| 284 // Get the InitializeModule function (required for non-broker code). | 286 // Get the InitializeModule function (required for non-broker code). |
| 285 PP_InitializeModule_Func init_module = | 287 PP_InitializeModule_Func init_module = |
| 286 reinterpret_cast<PP_InitializeModule_Func>( | 288 reinterpret_cast<PP_InitializeModule_Func>( |
| 287 library.GetFunctionPointer("PPP_InitializeModule")); | 289 library.GetFunctionPointer("PPP_InitializeModule")); |
| 288 if (!init_module) { | 290 if (!init_module) { |
| 289 LOG(WARNING) << "No PPP_InitializeModule in plugin library"; | 291 LOG(WARNING) << "No PPP_InitializeModule in plugin library"; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 // lifetime of the attached channel. | 394 // lifetime of the attached channel. |
| 393 return true; | 395 return true; |
| 394 } | 396 } |
| 395 | 397 |
| 396 void PpapiThread::SavePluginName(const FilePath& path) { | 398 void PpapiThread::SavePluginName(const FilePath& path) { |
| 397 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( | 399 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( |
| 398 path.BaseName().AsUTF8Unsafe()); | 400 path.BaseName().AsUTF8Unsafe()); |
| 399 | 401 |
| 400 // plugin() is NULL when in-process. Which is fine, because this is | 402 // plugin() is NULL when in-process. Which is fine, because this is |
| 401 // just a hook for setting the process name. | 403 // just a hook for setting the process name. |
| 402 if (content::GetContentClient()->plugin()) { | 404 if (GetContentClient()->plugin()) { |
| 403 content::GetContentClient()->plugin()->PluginProcessStarted( | 405 GetContentClient()->plugin()->PluginProcessStarted( |
| 404 path.BaseName().RemoveExtension().LossyDisplayName()); | 406 path.BaseName().RemoveExtension().LossyDisplayName()); |
| 405 } | 407 } |
| 406 } | 408 } |
| 409 |
| 410 } // namespace content |
| OLD | NEW |