OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_process_host.h" | 5 #include "components/nacl/browser/nacl_process_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/base_switches.h" | 11 #include "base/base_switches.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/process/launch.h" | 18 #include "base/process/launch.h" |
19 #include "base/process/process_iterator.h" | 19 #include "base/process/process_iterator.h" |
20 #include "base/rand_util.h" | 20 #include "base/rand_util.h" |
21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
26 #include "base/threading/sequenced_worker_pool.h" | 26 #include "base/threading/sequenced_worker_pool.h" |
27 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
28 #include "build/build_config.h" | 28 #include "build/build_config.h" |
29 #include "components/nacl/browser/nacl_browser.h" | 29 #include "components/nacl/browser/nacl_browser.h" |
| 30 #include "components/nacl/browser/nacl_browser_delegate.h" |
30 #include "components/nacl/browser/nacl_host_message_filter.h" | 31 #include "components/nacl/browser/nacl_host_message_filter.h" |
31 #include "components/nacl/common/nacl_cmd_line.h" | 32 #include "components/nacl/common/nacl_cmd_line.h" |
32 #include "components/nacl/common/nacl_host_messages.h" | 33 #include "components/nacl/common/nacl_host_messages.h" |
33 #include "components/nacl/common/nacl_messages.h" | 34 #include "components/nacl/common/nacl_messages.h" |
34 #include "components/nacl/common/nacl_process_type.h" | 35 #include "components/nacl/common/nacl_process_type.h" |
35 #include "components/nacl/common/nacl_switches.h" | 36 #include "components/nacl/common/nacl_switches.h" |
36 #include "content/public/browser/browser_child_process_host.h" | 37 #include "content/public/browser/browser_child_process_host.h" |
37 #include "content/public/browser/browser_ppapi_host.h" | 38 #include "content/public/browser/browser_ppapi_host.h" |
38 #include "content/public/browser/child_process_data.h" | 39 #include "content/public/browser/child_process_data.h" |
39 #include "content/public/browser/plugin_service.h" | 40 #include "content/public/browser/plugin_service.h" |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 424 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
424 nacl_browser->EnsureAllResourcesAvailable(); | 425 nacl_browser->EnsureAllResourcesAvailable(); |
425 if (!nacl_browser->IsOk()) { | 426 if (!nacl_browser->IsOk()) { |
426 SendErrorToRenderer("could not find all the resources needed" | 427 SendErrorToRenderer("could not find all the resources needed" |
427 " to launch the process"); | 428 " to launch the process"); |
428 delete this; | 429 delete this; |
429 return; | 430 return; |
430 } | 431 } |
431 | 432 |
432 if (uses_nonsfi_mode_) { | 433 if (uses_nonsfi_mode_) { |
| 434 bool nonsfi_mode_forced_by_command_line = false; |
| 435 bool nonsfi_mode_allowed = false; |
433 #if defined(OS_LINUX) | 436 #if defined(OS_LINUX) |
434 const bool kNonSFIModeSupported = true; | 437 nonsfi_mode_forced_by_command_line = |
435 #else | 438 cmd->HasSwitch(switches::kEnableNaClNonSfiMode); |
436 const bool kNonSFIModeSupported = false; | 439 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 440 nonsfi_mode_allowed = NaClBrowser::GetDelegate()->IsNonSfiModeAllowed( |
| 441 nacl_host_message_filter->profile_directory(), manifest_url_); |
437 #endif | 442 #endif |
438 if (!kNonSFIModeSupported || | 443 #endif |
439 !cmd->HasSwitch(switches::kEnableNaClNonSfiMode)) { | 444 bool nonsfi_mode_enabled = |
440 SendErrorToRenderer("NaCl non-SFI mode works only on Linux with" | 445 nonsfi_mode_forced_by_command_line || nonsfi_mode_allowed; |
441 " --enable-nacl-nonsfi-mode specified"); | 446 |
| 447 if (!nonsfi_mode_enabled) { |
| 448 SendErrorToRenderer( |
| 449 "NaCl non-SFI mode is not available for this platform" |
| 450 " and NaCl module."); |
442 delete this; | 451 delete this; |
443 return; | 452 return; |
444 } | 453 } |
445 } | 454 } |
446 | 455 |
447 // Rather than creating a socket pair in the renderer, and passing | 456 // Rather than creating a socket pair in the renderer, and passing |
448 // one side through the browser to sel_ldr, socket pairs are created | 457 // one side through the browser to sel_ldr, socket pairs are created |
449 // in the browser and then passed to the renderer and sel_ldr. | 458 // in the browser and then passed to the renderer and sel_ldr. |
450 // | 459 // |
451 // This is mainly for the benefit of Windows, where sockets cannot | 460 // This is mainly for the benefit of Windows, where sockets cannot |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 process_handle.Take(), info, | 1119 process_handle.Take(), info, |
1111 base::MessageLoopProxy::current(), | 1120 base::MessageLoopProxy::current(), |
1112 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1121 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1113 weak_factory_.GetWeakPtr())); | 1122 weak_factory_.GetWeakPtr())); |
1114 return true; | 1123 return true; |
1115 } | 1124 } |
1116 } | 1125 } |
1117 #endif | 1126 #endif |
1118 | 1127 |
1119 } // namespace nacl | 1128 } // namespace nacl |
OLD | NEW |