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

Unified Diff: content/browser/child_process_launcher.cc

Issue 98603007: Launches a privileged utility process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolves review feedback. 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/child_process_launcher.cc
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index 721cd5a88ede6cc6eeb7907bdecbfd35b7a5ff6d..38fcfbb6cbde42f8e1b3e6b9b67b0c95bbb92886 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -71,6 +71,7 @@ class ChildProcessLauncher::Context
void Launch(
#if defined(OS_WIN)
SandboxedProcessLauncherDelegate* delegate,
+ bool launch_elevated,
#elif defined(OS_ANDROID)
int ipcfd,
#elif defined(OS_POSIX)
@@ -100,6 +101,7 @@ class ChildProcessLauncher::Context
child_process_id,
#if defined(OS_WIN)
delegate,
+ launch_elevated,
#elif defined(OS_ANDROID)
ipcfd,
#elif defined(OS_POSIX)
@@ -183,6 +185,7 @@ class ChildProcessLauncher::Context
int child_process_id,
#if defined(OS_WIN)
SandboxedProcessLauncherDelegate* delegate,
+ bool launch_elevated,
#elif defined(OS_ANDROID)
int ipcfd,
#elif defined(OS_POSIX)
@@ -195,8 +198,15 @@ class ChildProcessLauncher::Context
base::TimeTicks begin_launch_time = base::TimeTicks::Now();
#if defined(OS_WIN)
- scoped_ptr<SandboxedProcessLauncherDelegate> delegate_deleter(delegate);
- base::ProcessHandle handle = StartSandboxedProcess(delegate, cmd_line);
+ base::ProcessHandle handle = base::kNullProcessHandle;
+ if (launch_elevated) {
+ base::LaunchOptions options;
+ options.start_hidden = true;
+ base::LaunchElevatedProcess(*cmd_line, options, &handle);
+ } else {
+ scoped_ptr<SandboxedProcessLauncherDelegate> delegate_deleter(delegate);
+ handle = StartSandboxedProcess(delegate, cmd_line);
+ }
#elif defined(OS_ANDROID)
// Android WebView runs in single process, ensure that we never get here
// when running in single process mode.
@@ -207,7 +217,7 @@ class ChildProcessLauncher::Context
std::vector<FileDescriptorInfo> files_to_register;
files_to_register.push_back(
FileDescriptorInfo(kPrimaryIPCChannel,
- base::FileDescriptor(ipcfd, false)));
+ base::FileDescriptor(ipcfd, false)));
GetContentClient()->browser()->
GetAdditionalMappedFilesForChildProcess(*cmd_line, child_process_id,
@@ -228,7 +238,7 @@ class ChildProcessLauncher::Context
std::vector<FileDescriptorInfo> files_to_register;
files_to_register.push_back(
FileDescriptorInfo(kPrimaryIPCChannel,
- base::FileDescriptor(ipcfd, false)));
+ base::FileDescriptor(ipcfd, false)));
#if !defined(OS_MACOSX)
GetContentClient()->browser()->
@@ -330,7 +340,11 @@ class ChildProcessLauncher::Context
zygote_ = zygote;
#endif
if (client_) {
- client_->OnProcessLaunched();
+ if (handle) {
+ client_->OnProcessLaunched();
+ } else {
+ client_->OnProcessLaunchFailed();
+ }
} else {
Terminate();
}
@@ -413,6 +427,7 @@ class ChildProcessLauncher::Context
ChildProcessLauncher::ChildProcessLauncher(
#if defined(OS_WIN)
SandboxedProcessLauncherDelegate* delegate,
+ bool launch_elevated,
#elif defined(OS_POSIX)
bool use_zygote,
const base::EnvironmentMap& environ,
@@ -425,6 +440,7 @@ ChildProcessLauncher::ChildProcessLauncher(
context_->Launch(
#if defined(OS_WIN)
delegate,
+ launch_elevated,
#elif defined(OS_ANDROID)
ipcfd,
#elif defined(OS_POSIX)

Powered by Google App Engine
This is Rietveld 408576698