Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: content/browser/utility_process_host_impl.cc

Issue 98603007: Launches a privileged utility process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mostly test cleanup. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 225
216 if (is_mdns_enabled_) 226 if (is_mdns_enabled_)
217 cmd_line->AppendSwitch(switches::kUtilityProcessEnableMDns); 227 cmd_line->AppendSwitch(switches::kUtilityProcessEnableMDns);
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
235 #if defined(OS_WIN)
236 // If launching elevated in windows, launch there and return.
237 if (run_elevated_) {
238 process_->LaunchElevated(cmd_line);
239 return true;
240 }
241 #endif
242
225 process_->Launch( 243 process_->Launch(
226 #if defined(OS_WIN) 244 #if defined(OS_WIN)
227 new UtilitySandboxedProcessLauncherDelegate(exposed_dir_), 245 new UtilitySandboxedProcessLauncherDelegate(exposed_dir_),
228 #elif defined(OS_POSIX) 246 #elif defined(OS_POSIX)
229 use_zygote, 247 use_zygote,
230 env_, 248 env_,
231 #endif 249 #endif
232 cmd_line); 250 cmd_line);
233 } 251 }
234 252
(...skipping 10 matching lines...) Expand all
245 } 263 }
246 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698