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 "content/browser/utility_process_host_impl.h" | 5 #include "content/browser/utility_process_host_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "content/browser/browser_child_process_host_impl.h" | 12 #include "content/browser/browser_child_process_host_impl.h" |
13 #include "content/common/child_process_host_impl.h" | 13 #include "content/common/child_process_host_impl.h" |
14 #include "content/common/utility_messages.h" | 14 #include "content/common/utility_messages.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/content_browser_client.h" | 16 #include "content/public/browser/content_browser_client.h" |
17 #include "content/public/browser/utility_process_host_client.h" | 17 #include "content/public/browser/utility_process_host_client.h" |
18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
19 #include "ipc/ipc_switches.h" | 19 #include "ipc/ipc_switches.h" |
20 #include "ui/base/ui_base_switches.h" | 20 #include "ui/base/ui_base_switches.h" |
21 #include "webkit/plugins/plugin_switches.h" | 21 #include "webkit/plugins/plugin_switches.h" |
22 | 22 |
| 23 #if defined(OS_WIN) |
| 24 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 25 #endif |
| 26 |
23 namespace content { | 27 namespace content { |
24 | 28 |
| 29 #if defined(OS_WIN) |
| 30 // NOTE: changes to this class need to be reviewed by the security team. |
| 31 class UtilitySandboxedProcessLauncherDelegate |
| 32 : public SandboxedProcessLauncherDelegate { |
| 33 public: |
| 34 explicit UtilitySandboxedProcessLauncherDelegate( |
| 35 const base::FilePath& exposed_dir) : exposed_dir_(exposed_dir) {} |
| 36 virtual ~UtilitySandboxedProcessLauncherDelegate() {} |
| 37 |
| 38 virtual void PreSandbox(bool* disable_default_policy, |
| 39 base::FilePath* exposed_dir) OVERRIDE { |
| 40 *exposed_dir = exposed_dir_; |
| 41 } |
| 42 |
| 43 private: |
| 44 base::FilePath exposed_dir_; |
| 45 }; |
| 46 #endif |
| 47 |
25 UtilityProcessHost* UtilityProcessHost::Create( | 48 UtilityProcessHost* UtilityProcessHost::Create( |
26 UtilityProcessHostClient* client, | 49 UtilityProcessHostClient* client, |
27 base::SequencedTaskRunner* client_task_runner) { | 50 base::SequencedTaskRunner* client_task_runner) { |
28 return new UtilityProcessHostImpl(client, client_task_runner); | 51 return new UtilityProcessHostImpl(client, client_task_runner); |
29 } | 52 } |
30 | 53 |
31 UtilityProcessHostImpl::UtilityProcessHostImpl( | 54 UtilityProcessHostImpl::UtilityProcessHostImpl( |
32 UtilityProcessHostClient* client, | 55 UtilityProcessHostClient* client, |
33 base::SequencedTaskRunner* client_task_runner) | 56 base::SequencedTaskRunner* client_task_runner) |
34 : client_(client), | 57 : client_(client), |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 #endif | 186 #endif |
164 | 187 |
165 bool use_zygote = false; | 188 bool use_zygote = false; |
166 | 189 |
167 #if defined(OS_LINUX) | 190 #if defined(OS_LINUX) |
168 use_zygote = !no_sandbox_ && use_linux_zygote_; | 191 use_zygote = !no_sandbox_ && use_linux_zygote_; |
169 #endif | 192 #endif |
170 | 193 |
171 process_->Launch( | 194 process_->Launch( |
172 #if defined(OS_WIN) | 195 #if defined(OS_WIN) |
173 exposed_dir_, | 196 new UtilitySandboxedProcessLauncherDelegate(exposed_dir_), |
174 #elif defined(OS_POSIX) | 197 #elif defined(OS_POSIX) |
175 use_zygote, | 198 use_zygote, |
176 env_, | 199 env_, |
177 #endif | 200 #endif |
178 cmd_line); | 201 cmd_line); |
179 | 202 |
180 return true; | 203 return true; |
181 } | 204 } |
182 | 205 |
183 bool UtilityProcessHostImpl::OnMessageReceived(const IPC::Message& message) { | 206 bool UtilityProcessHostImpl::OnMessageReceived(const IPC::Message& message) { |
184 client_task_runner_->PostTask( | 207 client_task_runner_->PostTask( |
185 FROM_HERE, | 208 FROM_HERE, |
186 base::Bind(base::IgnoreResult( | 209 base::Bind(base::IgnoreResult( |
187 &UtilityProcessHostClient::OnMessageReceived), client_.get(), | 210 &UtilityProcessHostClient::OnMessageReceived), client_.get(), |
188 message)); | 211 message)); |
189 return true; | 212 return true; |
190 } | 213 } |
191 | 214 |
192 void UtilityProcessHostImpl::OnProcessCrashed(int exit_code) { | 215 void UtilityProcessHostImpl::OnProcessCrashed(int exit_code) { |
193 client_task_runner_->PostTask( | 216 client_task_runner_->PostTask( |
194 FROM_HERE, | 217 FROM_HERE, |
195 base::Bind(&UtilityProcessHostClient::OnProcessCrashed, client_.get(), | 218 base::Bind(&UtilityProcessHostClient::OnProcessCrashed, client_.get(), |
196 exit_code)); | 219 exit_code)); |
197 } | 220 } |
198 | 221 |
199 } // namespace content | 222 } // namespace content |
OLD | NEW |