OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" |
| 6 |
| 7 #include "content/browser/browser_child_process_host_impl.h" |
| 8 #include "content/browser/ppapi_plugin_process_host.h" |
| 9 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" |
| 10 #include "content/public/browser/content_browser_client.h" |
| 11 #include "content/public/common/content_client.h" |
| 12 #include "ipc/ipc_message_macros.h" |
| 13 #include "ppapi/host/resource_host.h" |
| 14 #include "ppapi/proxy/ppapi_messages.h" |
| 15 #include "ppapi/proxy/resource_message_params.h" |
| 16 |
| 17 namespace content { |
| 18 |
| 19 PepperRendererConnection::PepperRendererConnection() { |
| 20 } |
| 21 |
| 22 PepperRendererConnection::~PepperRendererConnection() { |
| 23 } |
| 24 |
| 25 bool PepperRendererConnection::OnMessageReceived(const IPC::Message& msg, |
| 26 bool* message_was_ok) { |
| 27 bool handled = true; |
| 28 IPC_BEGIN_MESSAGE_MAP_EX(PepperRendererConnection, msg, *message_was_ok) |
| 29 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostFromHost, |
| 30 OnMsgCreateResourceHostFromHost) |
| 31 IPC_MESSAGE_UNHANDLED(handled = false) |
| 32 IPC_END_MESSAGE_MAP_EX() |
| 33 |
| 34 return handled; |
| 35 } |
| 36 |
| 37 void PepperRendererConnection::OnMsgCreateResourceHostFromHost( |
| 38 int child_process_id, |
| 39 const ppapi::proxy::ResourceMessageCallParams& params, |
| 40 PP_Instance instance, |
| 41 const IPC::Message& nested_msg) { |
| 42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 43 BrowserPpapiHostImpl* host = NULL; |
| 44 |
| 45 // Find the plugin which this message refers to. Check NaCl plugins first. |
| 46 host = static_cast<BrowserPpapiHostImpl*>( |
| 47 GetContentClient()->browser()->GetExternalBrowserPpapiHost( |
| 48 child_process_id)); |
| 49 |
| 50 if (!host) { |
| 51 // Check trusted pepper plugins. |
| 52 for (PpapiPluginProcessHostIterator iter; !iter.Done(); ++iter) { |
| 53 if (iter->process() && |
| 54 iter->process()->GetData().id == child_process_id) { |
| 55 // Found the plugin. |
| 56 host = iter->host_impl(); |
| 57 break; |
| 58 } |
| 59 } |
| 60 } |
| 61 |
| 62 int pending_resource_host_id; |
| 63 if (!host) { |
| 64 DLOG(ERROR) << "Invalid plugin process ID."; |
| 65 pending_resource_host_id = 0; |
| 66 } else { |
| 67 scoped_ptr<ppapi::host::ResourceHost> resource_host = |
| 68 host->GetPpapiHost()->CreateResourceHost(params, |
| 69 instance, |
| 70 nested_msg); |
| 71 pending_resource_host_id = |
| 72 host->GetPpapiHost()->AddPendingResourceHost(resource_host.Pass()); |
| 73 } |
| 74 |
| 75 Send(new PpapiHostMsg_CreateResourceHostFromHostReply( |
| 76 params.sequence(), pending_resource_host_id)); |
| 77 } |
| 78 |
| 79 } // namespace content |
OLD | NEW |