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/renderer/ppb_nacl_private.h" | 5 #include "components/nacl/renderer/ppb_nacl_private.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <numeric> | 9 #include <numeric> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/containers/scoped_ptr_hash_map.h" | 17 #include "base/containers/scoped_ptr_hash_map.h" |
18 #include "base/cpu.h" | 18 #include "base/cpu.h" |
19 #include "base/files/file.h" | 19 #include "base/files/file.h" |
20 #include "base/json/json_reader.h" | 20 #include "base/json/json_reader.h" |
21 #include "base/lazy_instance.h" | 21 #include "base/lazy_instance.h" |
22 #include "base/location.h" | 22 #include "base/location.h" |
23 #include "base/logging.h" | 23 #include "base/logging.h" |
24 #include "base/macros.h" | 24 #include "base/macros.h" |
25 #include "base/process/process_handle.h" | |
25 #include "base/single_thread_task_runner.h" | 26 #include "base/single_thread_task_runner.h" |
26 #include "base/strings/string_split.h" | 27 #include "base/strings/string_split.h" |
27 #include "base/strings/string_util.h" | 28 #include "base/strings/string_util.h" |
28 #include "base/thread_task_runner_handle.h" | 29 #include "base/thread_task_runner_handle.h" |
29 #include "build/build_config.h" | 30 #include "build/build_config.h" |
30 #include "components/nacl/common/nacl_host_messages.h" | 31 #include "components/nacl/common/nacl_host_messages.h" |
31 #include "components/nacl/common/nacl_messages.h" | 32 #include "components/nacl/common/nacl_messages.h" |
32 #include "components/nacl/common/nacl_nonsfi_util.h" | 33 #include "components/nacl/common/nacl_nonsfi_util.h" |
33 #include "components/nacl/common/nacl_switches.h" | 34 #include "components/nacl/common/nacl_switches.h" |
34 #include "components/nacl/common/nacl_types.h" | 35 #include "components/nacl/common/nacl_types.h" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 } | 465 } |
465 } | 466 } |
466 } | 467 } |
467 | 468 |
468 IPC::PlatformFileForTransit nexe_for_transit = | 469 IPC::PlatformFileForTransit nexe_for_transit = |
469 IPC::InvalidPlatformFileForTransit(); | 470 IPC::InvalidPlatformFileForTransit(); |
470 #if defined(OS_POSIX) | 471 #if defined(OS_POSIX) |
471 if (nexe_file_info->handle != PP_kInvalidFileHandle) | 472 if (nexe_file_info->handle != PP_kInvalidFileHandle) |
472 nexe_for_transit = base::FileDescriptor(nexe_file_info->handle, true); | 473 nexe_for_transit = base::FileDescriptor(nexe_file_info->handle, true); |
473 #elif defined(OS_WIN) | 474 #elif defined(OS_WIN) |
474 // Duplicate the handle on the browser side instead of the renderer. | 475 // Duplicate the handle on the browser side instead of the renderer. |
Mark Seaborn
2016/03/29 19:24:09
This comment doesn't apply any more, since you're
erikchen
2016/03/29 20:57:42
Removed the comment. Yes, the new path is secure.
| |
475 // This is because BrokerGetFileForProcess isn't part of content/public, and | 476 // This is because BrokerGetFileForProcess isn't part of content/public, and |
476 // it's simpler to do the duplication in the browser anyway. | 477 // it's simpler to do the duplication in the browser anyway. |
477 nexe_for_transit = nexe_file_info->handle; | 478 nexe_for_transit = IPC::PlatformFileForTransit(nexe_file_info->handle, |
479 base::GetCurrentProcId()); | |
478 #else | 480 #else |
479 # error Unsupported target platform. | 481 # error Unsupported target platform. |
480 #endif | 482 #endif |
481 | 483 |
482 std::string error_message_string; | 484 std::string error_message_string; |
483 NaClLaunchResult launch_result; | 485 NaClLaunchResult launch_result; |
484 if (!sender->Send(new NaClHostMsg_LaunchNaCl( | 486 if (!sender->Send(new NaClHostMsg_LaunchNaCl( |
485 NaClLaunchParams( | 487 NaClLaunchParams( |
486 instance_info.url.spec(), | 488 instance_info.url.spec(), |
487 nexe_for_transit, | 489 nexe_for_transit, |
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1767 // Mark the request as requesting a PNaCl bitcode file, | 1769 // Mark the request as requesting a PNaCl bitcode file, |
1768 // so that component updater can detect this user action. | 1770 // so that component updater can detect this user action. |
1769 url_request.addHTTPHeaderField( | 1771 url_request.addHTTPHeaderField( |
1770 blink::WebString::fromUTF8("Accept"), | 1772 blink::WebString::fromUTF8("Accept"), |
1771 blink::WebString::fromUTF8("application/x-pnacl, */*")); | 1773 blink::WebString::fromUTF8("application/x-pnacl, */*")); |
1772 url_request.setRequestContext(blink::WebURLRequest::RequestContextObject); | 1774 url_request.setRequestContext(blink::WebURLRequest::RequestContextObject); |
1773 downloader->Load(url_request); | 1775 downloader->Load(url_request); |
1774 } | 1776 } |
1775 | 1777 |
1776 } // namespace nacl | 1778 } // namespace nacl |
OLD | NEW |