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 BrowserPpapiHostImpl* host = NULL; | |
43 | |
44 // Find the plugin which this message refers to. Check NaCl plugins first. | |
45 host = static_cast<BrowserPpapiHostImpl*>( | |
46 GetContentClient()->browser()->GetExternalBrowserPpapiHost( | |
47 child_process_id)); | |
48 | |
49 if (!host) { | |
50 // Check trusted pepper plugins. | |
51 for (PpapiPluginProcessHostIterator iter; !iter.Done(); ++iter) { | |
52 if (iter->process() && | |
53 iter->process()->GetData().id == child_process_id) { | |
54 // Found the plugin. | |
55 host = iter->host_impl(); | |
56 return; | |
yzshen1
2013/05/29 17:57:21
Do you mean 'break'?
raymes
2013/06/04 04:11:11
Done.
| |
57 } | |
58 } | |
59 } | |
60 | |
61 int pending_resource_host_id; | |
62 if (!host) { | |
63 NOTREACHED(); | |
teravest
2013/05/29 16:57:13
One late comment, from https://sites.google.com/a/
raymes
2013/06/04 04:11:11
Done.
| |
64 pending_resource_host_id = 0; | |
65 } else { | |
66 scoped_ptr<ppapi::host::ResourceHost> resource_host = | |
67 host->GetPpapiHost()->CreateResourceHost(params, | |
68 instance, | |
69 nested_msg); | |
70 pending_resource_host_id = | |
71 host->GetPpapiHost()->AddPendingResourceHost(resource_host.Pass()); | |
72 } | |
73 | |
74 Send(new PpapiHostMsg_CreateResourceHostFromHostReply( | |
75 params.sequence(), pending_resource_host_id)); | |
76 } | |
77 | |
78 } // namespace content | |
OLD | NEW |