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

Unified Diff: content/browser/child_process_launcher.cc

Issue 1893313003: [mojo] Use a pipe path to initialise Mojo in elevated utility processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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
« no previous file with comments | « content/browser/child_process_launcher.h ('k') | content/browser/utility_process_host_impl_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/child_process_launcher.cc
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index 6b88b049946b6e3165a108430f2bb2949814d283..36f0c5098c7207548f6ebf73ae41f2bf63daad27 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -25,6 +25,8 @@
#include "content/public/common/result_codes.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "mojo/edk/embedder/embedder.h"
+#include "mojo/edk/embedder/named_platform_channel_pair.h"
+#include "mojo/edk/embedder/platform_channel_pair.h"
#include "mojo/edk/embedder/scoped_platform_handle.h"
#if defined(OS_WIN)
@@ -142,9 +144,8 @@ void LaunchOnLauncherThread(const NotifyCallback& callback,
base::Process process;
#if defined(OS_WIN)
if (launch_elevated) {
- // TODO(rockot): We may want to support Mojo IPC to elevated processes as
- // well, but this isn't currently feasible without sharing a pipe path on
- // the command line as elevated process launch goes through ShellExecuteEx.
+ // When establishing a Mojo connection, the pipe path has already been added
+ // to the command line.
base::LaunchOptions options;
options.start_hidden = true;
process = base::LaunchElevatedProcess(*cmd_line, options);
@@ -454,8 +455,19 @@ void ChildProcessLauncher::Launch(
NotifyCallback reply_callback(base::Bind(&ChildProcessLauncher::DidLaunch,
weak_factory_.GetWeakPtr(),
terminate_child_on_shutdown_));
- mojo::edk::ScopedPlatformHandle client_handle =
- mojo_platform_channel_.PassClientHandle();
+ mojo::edk::ScopedPlatformHandle client_handle;
+#if defined(OS_WIN)
+ if (delegate->ShouldLaunchElevated()) {
+ mojo::edk::NamedPlatformChannelPair named_pair;
+ mojo_host_platform_handle_ = named_pair.PassServerHandle();
+ named_pair.PrepareToPassClientHandleToChildProcess(cmd_line);
+ } else
+#endif
+ {
+ mojo::edk::PlatformChannelPair channel_pair;
+ mojo_host_platform_handle_ = channel_pair.PassServerHandle();
+ client_handle = channel_pair.PassClientHandle();
+ }
BrowserThread::PostTask(
BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
base::Bind(&LaunchOnLauncherThread, reply_callback, client_thread_id_,
@@ -545,7 +557,7 @@ void ChildProcessLauncher::Notify(ZygoteHandle zygote,
if (process_.IsValid()) {
// Set up Mojo IPC to the new process.
mojo::edk::ChildProcessLaunched(process_.Handle(),
- mojo_platform_channel_.PassServerHandle());
+ std::move(mojo_host_platform_handle_));
}
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
« no previous file with comments | « content/browser/child_process_launcher.h ('k') | content/browser/utility_process_host_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698