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" | |
20 #include "ppapi/proxy/resource_message_params.h" | 19 #include "ppapi/proxy/resource_message_params.h" |
21 | 20 |
22 namespace content { | 21 namespace content { |
23 | 22 |
24 PepperRendererConnection::PepperRendererConnection(int render_process_id) | 23 PepperRendererConnection::PepperRendererConnection(int render_process_id) |
25 : render_process_id_(render_process_id) { | 24 : render_process_id_(render_process_id) { |
26 // Only give the renderer permission for stable APIs. | 25 // Only give the renderer permission for stable APIs. |
27 in_process_host_.reset(new BrowserPpapiHostImpl(this, | 26 in_process_host_.reset(new BrowserPpapiHostImpl(this, |
28 ppapi::PpapiPermissions(), | 27 ppapi::PpapiPermissions(), |
29 "", | 28 "", |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 66 |
68 bool PepperRendererConnection::OnMessageReceived(const IPC::Message& msg, | 67 bool PepperRendererConnection::OnMessageReceived(const IPC::Message& msg, |
69 bool* message_was_ok) { | 68 bool* message_was_ok) { |
70 if (in_process_host_->GetPpapiHost()->OnMessageReceived(msg)) | 69 if (in_process_host_->GetPpapiHost()->OnMessageReceived(msg)) |
71 return true; | 70 return true; |
72 | 71 |
73 bool handled = true; | 72 bool handled = true; |
74 IPC_BEGIN_MESSAGE_MAP_EX(PepperRendererConnection, msg, *message_was_ok) | 73 IPC_BEGIN_MESSAGE_MAP_EX(PepperRendererConnection, msg, *message_was_ok) |
75 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHost, | 74 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHost, |
76 OnMsgCreateResourceHostsFromHost) | 75 OnMsgCreateResourceHostsFromHost) |
| 76 IPC_MESSAGE_HANDLER(PpapiHostMsg_FileRef_GetInfoForRenderer, |
| 77 OnMsgFileRefGetInfoForRenderer) |
77 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateInProcessInstance, | 78 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateInProcessInstance, |
78 OnMsgDidCreateInProcessInstance) | 79 OnMsgDidCreateInProcessInstance) |
79 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteInProcessInstance, | 80 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteInProcessInstance, |
80 OnMsgDidDeleteInProcessInstance) | 81 OnMsgDidDeleteInProcessInstance) |
81 IPC_MESSAGE_UNHANDLED(handled = false) | 82 IPC_MESSAGE_UNHANDLED(handled = false) |
82 IPC_END_MESSAGE_MAP_EX() | 83 IPC_END_MESSAGE_MAP_EX() |
83 | 84 |
84 return handled; | 85 return handled; |
85 } | 86 } |
86 | 87 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 pending_resource_host_ids[i] = | 122 pending_resource_host_ids[i] = |
122 host->GetPpapiHost()->AddPendingResourceHost(resource_host.Pass()); | 123 host->GetPpapiHost()->AddPendingResourceHost(resource_host.Pass()); |
123 } | 124 } |
124 } | 125 } |
125 } | 126 } |
126 | 127 |
127 Send(new PpapiHostMsg_CreateResourceHostsFromHostReply( | 128 Send(new PpapiHostMsg_CreateResourceHostsFromHostReply( |
128 routing_id, params.sequence(), pending_resource_host_ids)); | 129 routing_id, params.sequence(), pending_resource_host_ids)); |
129 } | 130 } |
130 | 131 |
| 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 |
131 void PepperRendererConnection::OnMsgDidCreateInProcessInstance( | 166 void PepperRendererConnection::OnMsgDidCreateInProcessInstance( |
132 PP_Instance instance, | 167 PP_Instance instance, |
133 const PepperRendererInstanceData& instance_data) { | 168 const PepperRendererInstanceData& instance_data) { |
134 PepperRendererInstanceData data = instance_data; | 169 PepperRendererInstanceData data = instance_data; |
135 data.render_process_id = render_process_id_; | 170 data.render_process_id = render_process_id_; |
136 in_process_host_->AddInstance(instance, data); | 171 in_process_host_->AddInstance(instance, data); |
137 } | 172 } |
138 | 173 |
139 void PepperRendererConnection::OnMsgDidDeleteInProcessInstance( | 174 void PepperRendererConnection::OnMsgDidDeleteInProcessInstance( |
140 PP_Instance instance) { | 175 PP_Instance instance) { |
141 in_process_host_->DeleteInstance(instance); | 176 in_process_host_->DeleteInstance(instance); |
142 } | 177 } |
143 | 178 |
144 } // namespace content | 179 } // namespace content |
OLD | NEW |