| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/nacl/nacl_main_platform_delegate.h" | 5 #include "components/nacl/loader/nacl_main_platform_delegate.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/native_library.h" | 10 #include "base/native_library.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "components/nacl/common/nacl_delegate.h" |
| 12 #include "components/nacl/common/nacl_switches.h" |
| 12 #include "sandbox/win/src/sandbox.h" | 13 #include "sandbox/win/src/sandbox.h" |
| 13 | 14 |
| 14 NaClMainPlatformDelegate::NaClMainPlatformDelegate( | 15 NaClMainPlatformDelegate::NaClMainPlatformDelegate( |
| 15 const content::MainFunctionParams& parameters) | 16 const content::MainFunctionParams& parameters) |
| 16 : parameters_(parameters), sandbox_test_module_(NULL) { | 17 : parameters_(parameters), sandbox_test_module_(NULL) { |
| 17 } | 18 } |
| 18 | 19 |
| 19 NaClMainPlatformDelegate::~NaClMainPlatformDelegate() { | 20 NaClMainPlatformDelegate::~NaClMainPlatformDelegate() { |
| 20 } | 21 } |
| 21 | 22 |
| 22 void NaClMainPlatformDelegate::PlatformInitialize() { | 23 void NaClMainPlatformDelegate::PlatformInitialize() { |
| 23 // Be mindful of what resources you acquire here. They can be used by | 24 // Be mindful of what resources you acquire here. They can be used by |
| 24 // malicious code if the renderer gets compromised. | 25 // malicious code if the renderer gets compromised. |
| 25 } | 26 } |
| 26 | 27 |
| 27 void NaClMainPlatformDelegate::PlatformUninitialize() { | 28 void NaClMainPlatformDelegate::PlatformUninitialize() { |
| 28 } | 29 } |
| 29 | 30 |
| 30 void NaClMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { | 31 void NaClMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { |
| 31 const CommandLine& command_line = parameters_.command_line; | 32 const CommandLine& command_line = parameters_.command_line; |
| 32 | 33 |
| 33 DVLOG(1) << "Started NaClLdr with " << command_line.GetCommandLineString(); | 34 DVLOG(1) << "Started NaClLdr with " << command_line.GetCommandLineString(); |
| 34 | 35 |
| 35 sandbox::TargetServices* target_services = | 36 sandbox::TargetServices* target_services = |
| 36 parameters_.sandbox_info->target_services; | 37 parameters_.sandbox_info->target_services; |
| 37 | 38 |
| 38 if (target_services && !no_sandbox) { | 39 if (target_services && !no_sandbox) { |
| 39 base::FilePath test_dll_name = | 40 base::FilePath test_dll_name = command_line.GetSwitchValuePath( |
| 40 command_line.GetSwitchValuePath(switches::kTestNaClSandbox); | 41 switches::kTestNaClSandbox); |
| 41 if (!test_dll_name.empty()) { | 42 if (!test_dll_name.empty()) { |
| 42 // At this point, hack on the suffix according to with bitness | 43 // At this point, hack on the suffix according to with bitness |
| 43 // of your windows process. | 44 // of your windows process. |
| 44 #if defined(_WIN64) | 45 #if defined(_WIN64) |
| 45 DVLOG(1) << "Using 64-bit test dll\n"; | 46 DVLOG(1) << "Using 64-bit test dll\n"; |
| 46 test_dll_name = test_dll_name.InsertBeforeExtension(L"64"); | 47 test_dll_name = test_dll_name.InsertBeforeExtension(L"64"); |
| 47 test_dll_name = test_dll_name.ReplaceExtension(L"dll"); | 48 test_dll_name = test_dll_name.ReplaceExtension(L"dll"); |
| 48 #else | 49 #else |
| 49 DVLOG(1) << "Using 32-bit test dll\n"; | 50 DVLOG(1) << "Using 32-bit test dll\n"; |
| 50 test_dll_name = test_dll_name.ReplaceExtension(L"dll"); | 51 test_dll_name = test_dll_name.ReplaceExtension(L"dll"); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 result = (*run_security_tests)(); | 86 result = (*run_security_tests)(); |
| 86 } else { | 87 } else { |
| 87 VLOG(1) << "Failed to get NaCl sandbox test function"; | 88 VLOG(1) << "Failed to get NaCl sandbox test function"; |
| 88 result = false; | 89 result = false; |
| 89 } | 90 } |
| 90 base::UnloadNativeLibrary(sandbox_test_module_); | 91 base::UnloadNativeLibrary(sandbox_test_module_); |
| 91 sandbox_test_module_ = NULL; | 92 sandbox_test_module_ = NULL; |
| 92 } | 93 } |
| 93 return result; | 94 return result; |
| 94 } | 95 } |
| OLD | NEW |