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 "components/nacl/browser/nacl_broker_service_win.h" |
11 #include "chrome/browser/nacl_host/nacl_broker_service_win.h" | |
12 #include "components/nacl/browser/nacl_browser.h" | 11 #include "components/nacl/browser/nacl_browser.h" |
13 #include "components/nacl/common/nacl_cmd_line.h" | 12 #include "components/nacl/common/nacl_cmd_line.h" |
14 #include "components/nacl/common/nacl_messages.h" | 13 #include "components/nacl/common/nacl_messages.h" |
15 #include "components/nacl/common/nacl_process_type.h" | 14 #include "components/nacl/common/nacl_process_type.h" |
16 #include "components/nacl/common/nacl_switches.h" | 15 #include "components/nacl/common/nacl_switches.h" |
17 #include "content/public/browser/browser_child_process_host.h" | 16 #include "content/public/browser/browser_child_process_host.h" |
18 #include "content/public/browser/child_process_data.h" | 17 #include "content/public/browser/child_process_data.h" |
19 #include "content/public/common/child_process_host.h" | 18 #include "content/public/common/child_process_host.h" |
20 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
21 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 20 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 21 #include "ipc/ipc_switches.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. |
50 std::string channel_id = process_->GetHost()->CreateChannel(); | 52 std::string channel_id = process_->GetHost()->CreateChannel(); |
51 if (channel_id.empty()) | 53 if (channel_id.empty()) |
52 return false; | 54 return false; |
53 | 55 |
54 // Create the path to the nacl broker/loader executable. | 56 // Create the path to the nacl broker/loader executable. |
55 base::FilePath nacl_path; | 57 base::FilePath nacl_path; |
56 if (!nacl::NaClBrowser::GetInstance()->GetNaCl64ExePath(&nacl_path)) | 58 if (!NaClBrowser::GetInstance()->GetNaCl64ExePath(&nacl_path)) |
57 return false; | 59 return false; |
58 | 60 |
59 CommandLine* cmd_line = new CommandLine(nacl_path); | 61 CommandLine* cmd_line = new CommandLine(nacl_path); |
60 nacl::CopyNaClCommandLineArguments(cmd_line); | 62 CopyNaClCommandLineArguments(cmd_line); |
61 | 63 |
62 cmd_line->AppendSwitchASCII(switches::kProcessType, | 64 cmd_line->AppendSwitchASCII(switches::kProcessType, |
63 switches::kNaClBrokerProcess); | 65 switches::kNaClBrokerProcess); |
64 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 66 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
65 if (nacl::NaClBrowser::GetDelegate()->DialogsAreSuppressed()) | 67 if (NaClBrowser::GetDelegate()->DialogsAreSuppressed()) |
66 cmd_line->AppendSwitch(switches::kNoErrorDialogs); | 68 cmd_line->AppendSwitch(switches::kNoErrorDialogs); |
67 | 69 |
68 process_->Launch(new NaClBrokerSandboxedProcessLauncherDelegate, cmd_line); | 70 process_->Launch(new NaClBrokerSandboxedProcessLauncherDelegate, cmd_line); |
69 return true; | 71 return true; |
70 } | 72 } |
71 | 73 |
72 bool NaClBrokerHost::OnMessageReceived(const IPC::Message& msg) { | 74 bool NaClBrokerHost::OnMessageReceived(const IPC::Message& msg) { |
73 bool handled = true; | 75 bool handled = true; |
74 IPC_BEGIN_MESSAGE_MAP(NaClBrokerHost, msg) | 76 IPC_BEGIN_MESSAGE_MAP(NaClBrokerHost, msg) |
75 IPC_MESSAGE_HANDLER(NaClProcessMsg_LoaderLaunched, OnLoaderLaunched) | 77 IPC_MESSAGE_HANDLER(NaClProcessMsg_LoaderLaunched, OnLoaderLaunched) |
(...skipping 29 matching lines...) Expand all Loading... |
105 | 107 |
106 void NaClBrokerHost::OnDebugExceptionHandlerLaunched(int32 pid, bool success) { | 108 void NaClBrokerHost::OnDebugExceptionHandlerLaunched(int32 pid, bool success) { |
107 NaClBrokerService::GetInstance()->OnDebugExceptionHandlerLaunched(pid, | 109 NaClBrokerService::GetInstance()->OnDebugExceptionHandlerLaunched(pid, |
108 success); | 110 success); |
109 } | 111 } |
110 | 112 |
111 void NaClBrokerHost::StopBroker() { | 113 void NaClBrokerHost::StopBroker() { |
112 is_terminating_ = true; | 114 is_terminating_ = true; |
113 process_->Send(new NaClProcessMsg_StopBroker()); | 115 process_->Send(new NaClProcessMsg_StopBroker()); |
114 } | 116 } |
| 117 |
| 118 } // namespace nacl |
OLD | NEW |