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