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 "components/nacl/browser/nacl_host_message_filter.h" | 5 #include "components/nacl/browser/nacl_host_message_filter.h" |
6 | 6 |
7 #include "base/sys_info.h" | 7 #include "base/sys_info.h" |
8 #include "components/nacl/browser/nacl_browser.h" | 8 #include "components/nacl/browser/nacl_browser.h" |
9 #include "components/nacl/browser/nacl_file_host.h" | 9 #include "components/nacl/browser/nacl_file_host.h" |
10 #include "components/nacl/browser/nacl_process_host.h" | 10 #include "components/nacl/browser/nacl_process_host.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_GetReadonlyPnaclFD, | 91 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_GetReadonlyPnaclFD, |
92 OnGetReadonlyPnaclFd) | 92 OnGetReadonlyPnaclFd) |
93 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_NaClCreateTemporaryFile, | 93 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_NaClCreateTemporaryFile, |
94 OnNaClCreateTemporaryFile) | 94 OnNaClCreateTemporaryFile) |
95 IPC_MESSAGE_HANDLER(NaClHostMsg_NexeTempFileRequest, | 95 IPC_MESSAGE_HANDLER(NaClHostMsg_NexeTempFileRequest, |
96 OnGetNexeFd) | 96 OnGetNexeFd) |
97 IPC_MESSAGE_HANDLER(NaClHostMsg_ReportTranslationFinished, | 97 IPC_MESSAGE_HANDLER(NaClHostMsg_ReportTranslationFinished, |
98 OnTranslationFinished) | 98 OnTranslationFinished) |
99 IPC_MESSAGE_HANDLER(NaClHostMsg_MissingArchError, | 99 IPC_MESSAGE_HANDLER(NaClHostMsg_MissingArchError, |
100 OnMissingArchError) | 100 OnMissingArchError) |
101 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_OpenNaClExecutable, | 101 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_OpenNaClResources, |
102 OnOpenNaClExecutable) | 102 OnOpenNaClResources) |
103 IPC_MESSAGE_HANDLER(NaClHostMsg_NaClGetNumProcessors, | 103 IPC_MESSAGE_HANDLER(NaClHostMsg_NaClGetNumProcessors, |
104 OnNaClGetNumProcessors) | 104 OnNaClGetNumProcessors) |
105 IPC_MESSAGE_HANDLER(NaClHostMsg_NaClDebugEnabledForURL, | 105 IPC_MESSAGE_HANDLER(NaClHostMsg_NaClDebugEnabledForURL, |
106 OnNaClDebugEnabledForURL) | 106 OnNaClDebugEnabledForURL) |
107 #endif | 107 #endif |
108 IPC_MESSAGE_UNHANDLED(handled = false) | 108 IPC_MESSAGE_UNHANDLED(handled = false) |
109 IPC_END_MESSAGE_MAP() | 109 IPC_END_MESSAGE_MAP() |
110 | 110 |
111 return handled; | 111 return handled; |
112 } | 112 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 void NaClHostMessageFilter::LaunchNaClContinuation( | 145 void NaClHostMessageFilter::LaunchNaClContinuation( |
146 const nacl::NaClLaunchParams& launch_params, | 146 const nacl::NaClLaunchParams& launch_params, |
147 IPC::Message* reply_msg, | 147 IPC::Message* reply_msg, |
148 ppapi::PpapiPermissions permissions) { | 148 ppapi::PpapiPermissions permissions) { |
149 NaClFileToken nexe_token = { | 149 NaClFileToken nexe_token = { |
150 launch_params.nexe_token_lo, // lo | 150 launch_params.nexe_token_lo, // lo |
151 launch_params.nexe_token_hi // hi | 151 launch_params.nexe_token_hi // hi |
152 }; | 152 }; |
153 | 153 |
154 base::PlatformFile nexe_file; | 154 base::PlatformFile nexe_file; |
155 scoped_ptr<nacl::ResourceFileInfo[]> resource_files_info; | |
155 #if defined(OS_WIN) | 156 #if defined(OS_WIN) |
156 // Duplicate the nexe file handle from the renderer process into the browser | 157 // Duplicate the nexe file handle from the renderer process into the browser |
157 // process. | 158 // process. |
158 if (!::DuplicateHandle(PeerHandle(), | 159 if (!::DuplicateHandle(PeerHandle(), |
159 launch_params.nexe_file, | 160 launch_params.nexe_file, |
160 base::GetCurrentProcessHandle(), | 161 base::GetCurrentProcessHandle(), |
161 &nexe_file, | 162 &nexe_file, |
162 0, // Unused, given DUPLICATE_SAME_ACCESS. | 163 0, // Unused, given DUPLICATE_SAME_ACCESS. |
163 FALSE, | 164 FALSE, |
164 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { | 165 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { |
165 NaClHostMsg_LaunchNaCl::WriteReplyParams( | 166 NaClHostMsg_LaunchNaCl::WriteReplyParams( |
166 reply_msg, | 167 reply_msg, |
167 NaClLaunchResult(), | 168 NaClLaunchResult(), |
168 std::string("Failed to duplicate nexe file handle")); | 169 std::string("Failed to duplicate nexe file handle")); |
169 Send(reply_msg); | 170 Send(reply_msg); |
170 return; | 171 return; |
171 } | 172 } |
173 // TODO(yusukes): Support pre-opening resource files. | |
Mark Seaborn
2015/02/09 04:48:34
Nit: Add "on Windows"?
Yusuke Sato
2015/02/11 05:54:20
Done.
| |
172 #elif defined(OS_POSIX) | 174 #elif defined(OS_POSIX) |
173 nexe_file = | 175 nexe_file = |
174 IPC::PlatformFileForTransitToPlatformFile(launch_params.nexe_file); | 176 IPC::PlatformFileForTransitToPlatformFile(launch_params.nexe_file); |
177 resource_files_info.reset(new nacl::ResourceFileInfo[ | |
178 launch_params.resource_files_info.size()]); | |
179 for (size_t i = 0; i < launch_params.resource_files_info.size(); ++i) { | |
180 base::File file(IPC::PlatformFileForTransitToPlatformFile( | |
181 launch_params.resource_files_info[i].file_info.file)); | |
182 NaClFileToken token = { | |
183 launch_params.resource_files_info[i].file_info.file_token_lo, | |
184 launch_params.resource_files_info[i].file_info.file_token_hi | |
185 }; | |
186 resource_files_info[i] = nacl::ResourceFileInfo( | |
187 file.Pass(), token, launch_params.resource_files_info[i].file_key); | |
188 } | |
175 #else | 189 #else |
176 #error Unsupported platform. | 190 #error Unsupported platform. |
177 #endif | 191 #endif |
178 | 192 |
179 NaClProcessHost* host = new NaClProcessHost( | 193 NaClProcessHost* host = new NaClProcessHost( |
180 GURL(launch_params.manifest_url), | 194 GURL(launch_params.manifest_url), |
181 base::File(nexe_file), | 195 base::File(nexe_file), |
182 nexe_token, | 196 nexe_token, |
197 resource_files_info.Pass(), | |
198 launch_params.resource_files_info.size(), | |
183 permissions, | 199 permissions, |
184 launch_params.render_view_id, | 200 launch_params.render_view_id, |
185 launch_params.permission_bits, | 201 launch_params.permission_bits, |
186 launch_params.uses_nonsfi_mode, | 202 launch_params.uses_nonsfi_mode, |
187 off_the_record_, | 203 off_the_record_, |
188 launch_params.process_type, | 204 launch_params.process_type, |
189 profile_directory_); | 205 profile_directory_); |
190 GURL manifest_url(launch_params.manifest_url); | 206 GURL manifest_url(launch_params.manifest_url); |
191 base::FilePath manifest_path; | 207 base::FilePath manifest_path; |
192 // We're calling MapUrlToLocalFilePath with the non-blocking API | 208 // We're calling MapUrlToLocalFilePath with the non-blocking API |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 void NaClHostMessageFilter::OnTranslationFinished(int instance, bool success) { | 293 void NaClHostMessageFilter::OnTranslationFinished(int instance, bool success) { |
278 pnacl::PnaclHost::GetInstance()->TranslationFinished( | 294 pnacl::PnaclHost::GetInstance()->TranslationFinished( |
279 render_process_id_, instance, success); | 295 render_process_id_, instance, success); |
280 } | 296 } |
281 | 297 |
282 void NaClHostMessageFilter::OnMissingArchError(int render_view_id) { | 298 void NaClHostMessageFilter::OnMissingArchError(int render_view_id) { |
283 nacl::NaClBrowser::GetDelegate()-> | 299 nacl::NaClBrowser::GetDelegate()-> |
284 ShowMissingArchInfobar(render_process_id_, render_view_id); | 300 ShowMissingArchInfobar(render_process_id_, render_view_id); |
285 } | 301 } |
286 | 302 |
287 void NaClHostMessageFilter::OnOpenNaClExecutable( | 303 void NaClHostMessageFilter::OnOpenNaClResources( |
288 int render_view_id, | 304 int render_view_id, |
289 const GURL& file_url, | 305 const std::vector<GURL>& resource_urls, |
290 bool enable_validation_caching, | 306 bool enable_validation_caching, |
291 IPC::Message* reply_msg) { | 307 IPC::Message* reply_msg) { |
292 nacl_file_host::OpenNaClExecutable(this, | 308 nacl_file_host::OpenNaClResources(this, |
293 render_view_id, | 309 render_view_id, |
294 file_url, | 310 resource_urls, |
295 enable_validation_caching, | 311 enable_validation_caching, |
296 reply_msg); | 312 reply_msg); |
297 } | 313 } |
298 | 314 |
299 void NaClHostMessageFilter::OnNaClDebugEnabledForURL(const GURL& nmf_url, | 315 void NaClHostMessageFilter::OnNaClDebugEnabledForURL(const GURL& nmf_url, |
300 bool* should_debug) { | 316 bool* should_debug) { |
301 *should_debug = | 317 *should_debug = |
302 nacl::NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(nmf_url); | 318 nacl::NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(nmf_url); |
303 } | 319 } |
304 | 320 |
305 } // namespace nacl | 321 } // namespace nacl |
OLD | NEW |