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