OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/renderer_host/pepper/pepper_renderer_connection.h" | 5 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" |
6 | 6 |
7 #include "content/browser/browser_child_process_host_impl.h" | 7 #include "content/browser/browser_child_process_host_impl.h" |
8 #include "content/browser/ppapi_plugin_process_host.h" | 8 #include "content/browser/ppapi_plugin_process_host.h" |
9 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" | 9 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" |
10 #include "content/common/pepper_renderer_instance_data.h" | 10 #include "content/common/pepper_renderer_instance_data.h" |
11 #include "content/common/view_messages.h" | 11 #include "content/common/view_messages.h" |
12 #include "content/browser/renderer_host/pepper/pepper_file_ref_host.h" | 12 #include "content/browser/renderer_host/pepper/pepper_file_ref_host.h" |
13 #include "content/public/browser/content_browser_client.h" | 13 #include "content/public/browser/content_browser_client.h" |
14 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
15 #include "ipc/ipc_message_macros.h" | 15 #include "ipc/ipc_message_macros.h" |
16 #include "ppapi/host/resource_host.h" | 16 #include "ppapi/host/resource_host.h" |
17 #include "ppapi/proxy/ppapi_message_utils.h" | 17 #include "ppapi/proxy/ppapi_message_utils.h" |
18 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
| 19 #include "ppapi/proxy/ppapi_message_utils.h" |
19 #include "ppapi/proxy/resource_message_params.h" | 20 #include "ppapi/proxy/resource_message_params.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 PepperRendererConnection::PepperRendererConnection(int render_process_id) | 24 PepperRendererConnection::PepperRendererConnection(int render_process_id) |
24 : render_process_id_(render_process_id) { | 25 : render_process_id_(render_process_id) { |
25 // Only give the renderer permission for stable APIs. | 26 // Only give the renderer permission for stable APIs. |
26 in_process_host_.reset(new BrowserPpapiHostImpl(this, | 27 in_process_host_.reset(new BrowserPpapiHostImpl(this, |
27 ppapi::PpapiPermissions(), | 28 ppapi::PpapiPermissions(), |
28 "", | 29 "", |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 67 |
67 bool PepperRendererConnection::OnMessageReceived(const IPC::Message& msg, | 68 bool PepperRendererConnection::OnMessageReceived(const IPC::Message& msg, |
68 bool* message_was_ok) { | 69 bool* message_was_ok) { |
69 if (in_process_host_->GetPpapiHost()->OnMessageReceived(msg)) | 70 if (in_process_host_->GetPpapiHost()->OnMessageReceived(msg)) |
70 return true; | 71 return true; |
71 | 72 |
72 bool handled = true; | 73 bool handled = true; |
73 IPC_BEGIN_MESSAGE_MAP_EX(PepperRendererConnection, msg, *message_was_ok) | 74 IPC_BEGIN_MESSAGE_MAP_EX(PepperRendererConnection, msg, *message_was_ok) |
74 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHost, | 75 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHost, |
75 OnMsgCreateResourceHostsFromHost) | 76 OnMsgCreateResourceHostsFromHost) |
76 IPC_MESSAGE_HANDLER(PpapiHostMsg_FileRef_GetInfoForRenderer, | |
77 OnMsgFileRefGetInfoForRenderer) | |
78 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateInProcessInstance, | 77 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateInProcessInstance, |
79 OnMsgDidCreateInProcessInstance) | 78 OnMsgDidCreateInProcessInstance) |
80 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteInProcessInstance, | 79 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteInProcessInstance, |
81 OnMsgDidDeleteInProcessInstance) | 80 OnMsgDidDeleteInProcessInstance) |
82 IPC_MESSAGE_UNHANDLED(handled = false) | 81 IPC_MESSAGE_UNHANDLED(handled = false) |
83 IPC_END_MESSAGE_MAP_EX() | 82 IPC_END_MESSAGE_MAP_EX() |
84 | 83 |
85 return handled; | 84 return handled; |
86 } | 85 } |
87 | 86 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 pending_resource_host_ids[i] = | 121 pending_resource_host_ids[i] = |
123 host->GetPpapiHost()->AddPendingResourceHost(resource_host.Pass()); | 122 host->GetPpapiHost()->AddPendingResourceHost(resource_host.Pass()); |
124 } | 123 } |
125 } | 124 } |
126 } | 125 } |
127 | 126 |
128 Send(new PpapiHostMsg_CreateResourceHostsFromHostReply( | 127 Send(new PpapiHostMsg_CreateResourceHostsFromHostReply( |
129 routing_id, params.sequence(), pending_resource_host_ids)); | 128 routing_id, params.sequence(), pending_resource_host_ids)); |
130 } | 129 } |
131 | 130 |
132 void PepperRendererConnection::OnMsgFileRefGetInfoForRenderer( | |
133 int routing_id, | |
134 int child_process_id, | |
135 int32_t sequence, | |
136 const std::vector<PP_Resource>& resources) { | |
137 std::vector<PP_Resource> out_resources; | |
138 std::vector<PP_FileSystemType> fs_types; | |
139 std::vector<std::string> file_system_url_specs; | |
140 std::vector<base::FilePath> external_paths; | |
141 | |
142 BrowserPpapiHostImpl* host = GetHostForChildProcess(child_process_id); | |
143 if (host) { | |
144 for (size_t i = 0; i < resources.size(); ++i) { | |
145 ppapi::host::ResourceHost* resource_host = | |
146 host->GetPpapiHost()->GetResourceHost(resources[i]); | |
147 if (resource_host && resource_host->IsFileRefHost()) { | |
148 PepperFileRefHost* file_ref_host = | |
149 static_cast<PepperFileRefHost*>(resource_host); | |
150 out_resources.push_back(resources[i]); | |
151 fs_types.push_back(file_ref_host->GetFileSystemType()); | |
152 file_system_url_specs.push_back(file_ref_host->GetFileSystemURLSpec()); | |
153 external_paths.push_back(file_ref_host->GetExternalPath()); | |
154 } | |
155 } | |
156 } | |
157 Send(new PpapiHostMsg_FileRef_GetInfoForRendererReply( | |
158 routing_id, | |
159 sequence, | |
160 out_resources, | |
161 fs_types, | |
162 file_system_url_specs, | |
163 external_paths)); | |
164 } | |
165 | |
166 void PepperRendererConnection::OnMsgDidCreateInProcessInstance( | 131 void PepperRendererConnection::OnMsgDidCreateInProcessInstance( |
167 PP_Instance instance, | 132 PP_Instance instance, |
168 const PepperRendererInstanceData& instance_data) { | 133 const PepperRendererInstanceData& instance_data) { |
169 PepperRendererInstanceData data = instance_data; | 134 PepperRendererInstanceData data = instance_data; |
170 data.render_process_id = render_process_id_; | 135 data.render_process_id = render_process_id_; |
171 in_process_host_->AddInstance(instance, data); | 136 in_process_host_->AddInstance(instance, data); |
172 } | 137 } |
173 | 138 |
174 void PepperRendererConnection::OnMsgDidDeleteInProcessInstance( | 139 void PepperRendererConnection::OnMsgDidDeleteInProcessInstance( |
175 PP_Instance instance) { | 140 PP_Instance instance) { |
176 in_process_host_->DeleteInstance(instance); | 141 in_process_host_->DeleteInstance(instance); |
177 } | 142 } |
178 | 143 |
179 } // namespace content | 144 } // namespace content |
OLD | NEW |