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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 66 } |
67 | 67 |
68 UtilityProcessHostImpl::UtilityProcessHostImpl( | 68 UtilityProcessHostImpl::UtilityProcessHostImpl( |
69 UtilityProcessHostClient* client, | 69 UtilityProcessHostClient* client, |
70 base::SequencedTaskRunner* client_task_runner) | 70 base::SequencedTaskRunner* client_task_runner) |
71 : client_(client), | 71 : client_(client), |
72 client_task_runner_(client_task_runner), | 72 client_task_runner_(client_task_runner), |
73 is_batch_mode_(false), | 73 is_batch_mode_(false), |
74 is_mdns_enabled_(false), | 74 is_mdns_enabled_(false), |
75 no_sandbox_(false), | 75 no_sandbox_(false), |
| 76 #if defined(OS_WIN) |
| 77 run_elevated_(false), |
| 78 #endif |
76 #if defined(OS_LINUX) | 79 #if defined(OS_LINUX) |
77 child_flags_(ChildProcessHost::CHILD_ALLOW_SELF), | 80 child_flags_(ChildProcessHost::CHILD_ALLOW_SELF), |
78 #else | 81 #else |
79 child_flags_(ChildProcessHost::CHILD_NORMAL), | 82 child_flags_(ChildProcessHost::CHILD_NORMAL), |
80 #endif | 83 #endif |
81 use_linux_zygote_(false), | 84 use_linux_zygote_(false), |
82 started_(false) { | 85 started_(false) { |
83 } | 86 } |
84 | 87 |
85 UtilityProcessHostImpl::~UtilityProcessHostImpl() { | 88 UtilityProcessHostImpl::~UtilityProcessHostImpl() { |
(...skipping 27 matching lines...) Expand all Loading... |
113 } | 116 } |
114 | 117 |
115 void UtilityProcessHostImpl::EnableMDns() { | 118 void UtilityProcessHostImpl::EnableMDns() { |
116 is_mdns_enabled_ = true; | 119 is_mdns_enabled_ = true; |
117 } | 120 } |
118 | 121 |
119 void UtilityProcessHostImpl::DisableSandbox() { | 122 void UtilityProcessHostImpl::DisableSandbox() { |
120 no_sandbox_ = true; | 123 no_sandbox_ = true; |
121 } | 124 } |
122 | 125 |
| 126 #if defined(OS_WIN) |
| 127 void UtilityProcessHostImpl::ElevatePrivileges() { |
| 128 no_sandbox_ = true; |
| 129 run_elevated_ = true; |
| 130 } |
| 131 #endif |
| 132 |
123 void UtilityProcessHostImpl::EnableZygote() { | 133 void UtilityProcessHostImpl::EnableZygote() { |
124 use_linux_zygote_ = true; | 134 use_linux_zygote_ = true; |
125 } | 135 } |
126 | 136 |
127 const ChildProcessData& UtilityProcessHostImpl::GetData() { | 137 const ChildProcessData& UtilityProcessHostImpl::GetData() { |
128 return process_->GetData(); | 138 return process_->GetData(); |
129 } | 139 } |
130 | 140 |
131 #if defined(OS_POSIX) | 141 #if defined(OS_POSIX) |
132 | 142 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 228 |
219 bool use_zygote = false; | 229 bool use_zygote = false; |
220 | 230 |
221 #if defined(OS_LINUX) | 231 #if defined(OS_LINUX) |
222 use_zygote = !no_sandbox_ && use_linux_zygote_; | 232 use_zygote = !no_sandbox_ && use_linux_zygote_; |
223 #endif | 233 #endif |
224 | 234 |
225 process_->Launch( | 235 process_->Launch( |
226 #if defined(OS_WIN) | 236 #if defined(OS_WIN) |
227 new UtilitySandboxedProcessLauncherDelegate(exposed_dir_), | 237 new UtilitySandboxedProcessLauncherDelegate(exposed_dir_), |
| 238 run_elevated_, |
228 #elif defined(OS_POSIX) | 239 #elif defined(OS_POSIX) |
229 use_zygote, | 240 use_zygote, |
230 env_, | 241 env_, |
231 #endif | 242 #endif |
232 cmd_line); | 243 cmd_line); |
233 } | 244 } |
234 | 245 |
235 return true; | 246 return true; |
236 } | 247 } |
237 | 248 |
238 bool UtilityProcessHostImpl::OnMessageReceived(const IPC::Message& message) { | 249 bool UtilityProcessHostImpl::OnMessageReceived(const IPC::Message& message) { |
239 client_task_runner_->PostTask( | 250 client_task_runner_->PostTask( |
240 FROM_HERE, | 251 FROM_HERE, |
241 base::Bind(base::IgnoreResult( | 252 base::Bind(base::IgnoreResult( |
242 &UtilityProcessHostClient::OnMessageReceived), client_.get(), | 253 &UtilityProcessHostClient::OnMessageReceived), client_.get(), |
243 message)); | 254 message)); |
244 return true; | 255 return true; |
245 } | 256 } |
246 | 257 |
| 258 void UtilityProcessHostImpl::OnProcessLaunchFailed() { |
| 259 client_task_runner_->PostTask( |
| 260 FROM_HERE, |
| 261 base::Bind(&UtilityProcessHostClient::OnProcessLaunchFailed, |
| 262 client_.get())); |
| 263 } |
| 264 |
247 void UtilityProcessHostImpl::OnProcessCrashed(int exit_code) { | 265 void UtilityProcessHostImpl::OnProcessCrashed(int exit_code) { |
248 client_task_runner_->PostTask( | 266 client_task_runner_->PostTask( |
249 FROM_HERE, | 267 FROM_HERE, |
250 base::Bind(&UtilityProcessHostClient::OnProcessCrashed, client_.get(), | 268 base::Bind(&UtilityProcessHostClient::OnProcessCrashed, client_.get(), |
251 exit_code)); | 269 exit_code)); |
252 } | 270 } |
253 | 271 |
254 } // namespace content | 272 } // namespace content |
OLD | NEW |