| 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" |
| 21 #include "ppapi/shared_impl/file_ref_detailed_info.h" |
| 20 | 22 |
| 21 namespace content { | 23 namespace content { |
| 22 | 24 |
| 23 PepperRendererConnection::PepperRendererConnection(int render_process_id) | 25 PepperRendererConnection::PepperRendererConnection(int render_process_id) |
| 24 : render_process_id_(render_process_id) { | 26 : render_process_id_(render_process_id) { |
| 25 // Only give the renderer permission for stable APIs. | 27 // Only give the renderer permission for stable APIs. |
| 26 in_process_host_.reset(new BrowserPpapiHostImpl(this, | 28 in_process_host_.reset(new BrowserPpapiHostImpl(this, |
| 27 ppapi::PpapiPermissions(), | 29 ppapi::PpapiPermissions(), |
| 28 "", | 30 "", |
| 29 base::FilePath(), | 31 base::FilePath(), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 bool* message_was_ok) { | 71 bool* message_was_ok) { |
| 70 if (in_process_host_->GetPpapiHost()->OnMessageReceived(msg)) | 72 if (in_process_host_->GetPpapiHost()->OnMessageReceived(msg)) |
| 71 return true; | 73 return true; |
| 72 | 74 |
| 73 bool handled = true; | 75 bool handled = true; |
| 74 IPC_BEGIN_MESSAGE_MAP_EX(PepperRendererConnection, msg, *message_was_ok) | 76 IPC_BEGIN_MESSAGE_MAP_EX(PepperRendererConnection, msg, *message_was_ok) |
| 75 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostFromHost, | 77 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostFromHost, |
| 76 OnMsgCreateResourceHostFromHost) | 78 OnMsgCreateResourceHostFromHost) |
| 77 IPC_MESSAGE_HANDLER(PpapiHostMsg_FileRef_GetInfoForRenderer, | 79 IPC_MESSAGE_HANDLER(PpapiHostMsg_FileRef_GetInfoForRenderer, |
| 78 OnMsgFileRefGetInfoForRenderer) | 80 OnMsgFileRefGetInfoForRenderer) |
| 81 IPC_MESSAGE_HANDLER(PpapiHostMsg_FileRef_SyncGetInfoForRenderer, |
| 82 OnMsgFileRefSyncGetInfoForRenderer) |
| 79 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateInProcessInstance, | 83 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateInProcessInstance, |
| 80 OnMsgDidCreateInProcessInstance) | 84 OnMsgDidCreateInProcessInstance) |
| 81 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteInProcessInstance, | 85 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteInProcessInstance, |
| 82 OnMsgDidDeleteInProcessInstance) | 86 OnMsgDidDeleteInProcessInstance) |
| 83 IPC_MESSAGE_UNHANDLED(handled = false) | 87 IPC_MESSAGE_UNHANDLED(handled = false) |
| 84 IPC_END_MESSAGE_MAP_EX() | 88 IPC_END_MESSAGE_MAP_EX() |
| 85 | 89 |
| 86 return handled; | 90 return handled; |
| 87 } | 91 } |
| 88 | 92 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 129 |
| 126 Send(new PpapiHostMsg_CreateResourceHostFromHostReply( | 130 Send(new PpapiHostMsg_CreateResourceHostFromHostReply( |
| 127 routing_id, params.sequence(), pending_resource_host_id)); | 131 routing_id, params.sequence(), pending_resource_host_id)); |
| 128 } | 132 } |
| 129 | 133 |
| 130 void PepperRendererConnection::OnMsgFileRefGetInfoForRenderer( | 134 void PepperRendererConnection::OnMsgFileRefGetInfoForRenderer( |
| 131 int routing_id, | 135 int routing_id, |
| 132 int child_process_id, | 136 int child_process_id, |
| 133 int32_t sequence, | 137 int32_t sequence, |
| 134 const std::vector<PP_Resource>& resources) { | 138 const std::vector<PP_Resource>& resources) { |
| 135 std::vector<PP_Resource> out_resources; | 139 std::vector<ppapi::FileRefDetailedInfo> infos; |
| 136 std::vector<PP_FileSystemType> fs_types; | 140 OnMsgFileRefSyncGetInfoForRenderer(child_process_id, resources, &infos); |
| 137 std::vector<std::string> file_system_url_specs; | 141 Send(new PpapiHostMsg_FileRef_GetInfoForRendererReply( |
| 138 std::vector<base::FilePath> external_paths; | 142 routing_id, |
| 143 sequence, |
| 144 infos)); |
| 145 } |
| 139 | 146 |
| 147 void PepperRendererConnection::OnMsgFileRefSyncGetInfoForRenderer( |
| 148 int child_process_id, |
| 149 const std::vector<PP_Resource>& resources, |
| 150 std::vector<ppapi::FileRefDetailedInfo>* out_infos) { |
| 140 BrowserPpapiHostImpl* host = GetHostForChildProcess(child_process_id); | 151 BrowserPpapiHostImpl* host = GetHostForChildProcess(child_process_id); |
| 152 |
| 141 if (host) { | 153 if (host) { |
| 142 for (size_t i = 0; i < resources.size(); ++i) { | 154 for (size_t i = 0; i < resources.size(); ++i) { |
| 143 ppapi::host::ResourceHost* resource_host = | 155 ppapi::host::ResourceHost* resource_host = |
| 144 host->GetPpapiHost()->GetResourceHost(resources[i]); | 156 host->GetPpapiHost()->GetResourceHost(resources[i]); |
| 145 if (resource_host && resource_host->IsFileRefHost()) { | 157 if (resource_host && resource_host->IsFileRefHost()) { |
| 146 PepperFileRefHost* file_ref_host = | 158 PepperFileRefHost* file_ref_host = |
| 147 static_cast<PepperFileRefHost*>(resource_host); | 159 static_cast<PepperFileRefHost*>(resource_host); |
| 148 out_resources.push_back(resources[i]); | 160 ppapi::FileRefDetailedInfo info; |
| 149 fs_types.push_back(file_ref_host->GetFileSystemType()); | 161 info.resource = resources[i]; |
| 150 file_system_url_specs.push_back(file_ref_host->GetFileSystemURLSpec()); | 162 info.file_system_type = file_ref_host->GetFileSystemType(); |
| 151 external_paths.push_back(file_ref_host->GetExternalPath()); | 163 info.file_system_url_spec = file_ref_host->GetFileSystemURLSpec(); |
| 164 info.external_path = file_ref_host->GetExternalPath(); |
| 165 out_infos->push_back(info); |
| 152 } | 166 } |
| 153 } | 167 } |
| 154 } | 168 } |
| 155 Send(new PpapiHostMsg_FileRef_GetInfoForRendererReply( | |
| 156 routing_id, | |
| 157 sequence, | |
| 158 out_resources, | |
| 159 fs_types, | |
| 160 file_system_url_specs, | |
| 161 external_paths)); | |
| 162 } | 169 } |
| 163 | 170 |
| 164 void PepperRendererConnection::OnMsgDidCreateInProcessInstance( | 171 void PepperRendererConnection::OnMsgDidCreateInProcessInstance( |
| 165 PP_Instance instance, | 172 PP_Instance instance, |
| 166 const PepperRendererInstanceData& instance_data) { | 173 const PepperRendererInstanceData& instance_data) { |
| 167 PepperRendererInstanceData data = instance_data; | 174 PepperRendererInstanceData data = instance_data; |
| 168 data.render_process_id = render_process_id_; | 175 data.render_process_id = render_process_id_; |
| 169 in_process_host_->AddInstance(instance, data); | 176 in_process_host_->AddInstance(instance, data); |
| 170 } | 177 } |
| 171 | 178 |
| 172 void PepperRendererConnection::OnMsgDidDeleteInProcessInstance( | 179 void PepperRendererConnection::OnMsgDidDeleteInProcessInstance( |
| 173 PP_Instance instance) { | 180 PP_Instance instance) { |
| 174 in_process_host_->DeleteInstance(instance); | 181 in_process_host_->DeleteInstance(instance); |
| 175 } | 182 } |
| 176 | 183 |
| 177 } // namespace content | 184 } // namespace content |
| OLD | NEW |