| 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 "chrome/browser/nacl_host/nacl_broker_host_win.h" | 5 #include "components/nacl/browser/nacl_broker_host_win.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "ipc/ipc_switches.h" | 10 #include "ipc/ipc_switches.h" |
| 11 #include "chrome/browser/nacl_host/nacl_broker_service_win.h" | 11 #include "components/nacl/browser/nacl_broker_service_win.h" |
| 12 #include "components/nacl/browser/nacl_browser.h" | 12 #include "components/nacl/browser/nacl_browser.h" |
| 13 #include "components/nacl/common/nacl_cmd_line.h" | 13 #include "components/nacl/common/nacl_cmd_line.h" |
| 14 #include "components/nacl/common/nacl_messages.h" | 14 #include "components/nacl/common/nacl_messages.h" |
| 15 #include "components/nacl/common/nacl_process_type.h" | 15 #include "components/nacl/common/nacl_process_type.h" |
| 16 #include "components/nacl/common/nacl_switches.h" | 16 #include "components/nacl/common/nacl_switches.h" |
| 17 #include "content/public/browser/browser_child_process_host.h" | 17 #include "content/public/browser/browser_child_process_host.h" |
| 18 #include "content/public/browser/child_process_data.h" | 18 #include "content/public/browser/child_process_data.h" |
| 19 #include "content/public/common/child_process_host.h" | 19 #include "content/public/common/child_process_host.h" |
| 20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 21 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 21 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 // NOTE: changes to this class need to be reviewed by the security team. | 24 // NOTE: changes to this class need to be reviewed by the security team. |
| 25 class NaClBrokerSandboxedProcessLauncherDelegate | 25 class NaClBrokerSandboxedProcessLauncherDelegate |
| 26 : public content::SandboxedProcessLauncherDelegate { | 26 : public content::SandboxedProcessLauncherDelegate { |
| 27 public: | 27 public: |
| 28 NaClBrokerSandboxedProcessLauncherDelegate() {} | 28 NaClBrokerSandboxedProcessLauncherDelegate() {} |
| 29 virtual ~NaClBrokerSandboxedProcessLauncherDelegate() {} | 29 virtual ~NaClBrokerSandboxedProcessLauncherDelegate() {} |
| 30 | 30 |
| 31 virtual void ShouldSandbox(bool* in_sandbox) OVERRIDE { | 31 virtual void ShouldSandbox(bool* in_sandbox) OVERRIDE { |
| 32 *in_sandbox = false; | 32 *in_sandbox = false; |
| 33 } | 33 } |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 DISALLOW_COPY_AND_ASSIGN(NaClBrokerSandboxedProcessLauncherDelegate); | 36 DISALLOW_COPY_AND_ASSIGN(NaClBrokerSandboxedProcessLauncherDelegate); |
| 37 }; | 37 }; |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 namespace nacl { |
| 41 |
| 40 NaClBrokerHost::NaClBrokerHost() : is_terminating_(false) { | 42 NaClBrokerHost::NaClBrokerHost() : is_terminating_(false) { |
| 41 process_.reset(content::BrowserChildProcessHost::Create( | 43 process_.reset(content::BrowserChildProcessHost::Create( |
| 42 PROCESS_TYPE_NACL_BROKER, this)); | 44 PROCESS_TYPE_NACL_BROKER, this)); |
| 43 } | 45 } |
| 44 | 46 |
| 45 NaClBrokerHost::~NaClBrokerHost() { | 47 NaClBrokerHost::~NaClBrokerHost() { |
| 46 } | 48 } |
| 47 | 49 |
| 48 bool NaClBrokerHost::Init() { | 50 bool NaClBrokerHost::Init() { |
| 49 // Create the channel that will be used for communicating with the broker. | 51 // Create the channel that will be used for communicating with the broker. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 80 return handled; | 82 return handled; |
| 81 } | 83 } |
| 82 | 84 |
| 83 bool NaClBrokerHost::LaunchLoader(const std::string& loader_channel_id) { | 85 bool NaClBrokerHost::LaunchLoader(const std::string& loader_channel_id) { |
| 84 return process_->Send( | 86 return process_->Send( |
| 85 new NaClProcessMsg_LaunchLoaderThroughBroker(loader_channel_id)); | 87 new NaClProcessMsg_LaunchLoaderThroughBroker(loader_channel_id)); |
| 86 } | 88 } |
| 87 | 89 |
| 88 void NaClBrokerHost::OnLoaderLaunched(const std::string& loader_channel_id, | 90 void NaClBrokerHost::OnLoaderLaunched(const std::string& loader_channel_id, |
| 89 base::ProcessHandle handle) { | 91 base::ProcessHandle handle) { |
| 90 NaClBrokerService::GetInstance()->OnLoaderLaunched(loader_channel_id, handle); | 92 nacl::NaClBrokerService::GetInstance()->OnLoaderLaunched( |
| 93 loader_channel_id, handle); |
| 91 } | 94 } |
| 92 | 95 |
| 93 bool NaClBrokerHost::LaunchDebugExceptionHandler( | 96 bool NaClBrokerHost::LaunchDebugExceptionHandler( |
| 94 int32 pid, base::ProcessHandle process_handle, | 97 int32 pid, base::ProcessHandle process_handle, |
| 95 const std::string& startup_info) { | 98 const std::string& startup_info) { |
| 96 base::ProcessHandle broker_process = process_->GetData().handle; | 99 base::ProcessHandle broker_process = process_->GetData().handle; |
| 97 base::ProcessHandle handle_in_broker_process; | 100 base::ProcessHandle handle_in_broker_process; |
| 98 if (!DuplicateHandle(::GetCurrentProcess(), process_handle, | 101 if (!DuplicateHandle(::GetCurrentProcess(), process_handle, |
| 99 broker_process, &handle_in_broker_process, | 102 broker_process, &handle_in_broker_process, |
| 100 0, /* bInheritHandle= */ FALSE, DUPLICATE_SAME_ACCESS)) | 103 0, /* bInheritHandle= */ FALSE, DUPLICATE_SAME_ACCESS)) |
| 101 return false; | 104 return false; |
| 102 return process_->Send(new NaClProcessMsg_LaunchDebugExceptionHandler( | 105 return process_->Send(new NaClProcessMsg_LaunchDebugExceptionHandler( |
| 103 pid, handle_in_broker_process, startup_info)); | 106 pid, handle_in_broker_process, startup_info)); |
| 104 } | 107 } |
| 105 | 108 |
| 106 void NaClBrokerHost::OnDebugExceptionHandlerLaunched(int32 pid, bool success) { | 109 void NaClBrokerHost::OnDebugExceptionHandlerLaunched(int32 pid, bool success) { |
| 107 NaClBrokerService::GetInstance()->OnDebugExceptionHandlerLaunched(pid, | 110 nacl::NaClBrokerService::GetInstance()->OnDebugExceptionHandlerLaunched(pid, |
| 108 success); | 111 success); |
| 109 } | 112 } |
| 110 | 113 |
| 111 void NaClBrokerHost::StopBroker() { | 114 void NaClBrokerHost::StopBroker() { |
| 112 is_terminating_ = true; | 115 is_terminating_ = true; |
| 113 process_->Send(new NaClProcessMsg_StopBroker()); | 116 process_->Send(new NaClProcessMsg_StopBroker()); |
| 114 } | 117 } |
| 118 |
| 119 } // namespace nacl |
| OLD | NEW |