Bug 1332522 - Part 1 - Send the remote type to the child before enabling the content sandbox; r=bobowen
Call SendRemoteType() before calling SendSetProcessSandbox() so the
child can use the remote type value when setting up the sandbox.
MozReview-Commit-ID: 28Xeyn9cqDf
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -1047,18 +1047,16 @@ ContentParent::Init()
}
Preferences::AddStrongObserver(this, "");
if (obs) {
nsAutoString cpId;
cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
obs->NotifyObservers(static_cast<nsIObserver*>(this), "ipc:content-created", cpId.get());
}
- Unused << SendRemoteType(mRemoteType);
-
#ifdef ACCESSIBILITY
// If accessibility is running in chrome process then start it in content
// process.
if (nsIPresShell::IsAccessibilityActive()) {
#if defined(XP_WIN)
if (IsVistaOrLater()) {
Unused <<
SendActivateA11y(a11y::AccessibleWrap::GetContentProcessIdFor(ChildID()));
@@ -1818,16 +1816,21 @@ ContentParent::InitInternal(ProcessPrior
// Sending all information to content process.
Unused << SendAppInfo(version, buildID, name, UAName, ID, vendor);
}
// Initialize the message manager (and load delayed scripts) now that we
// have established communications with the child.
mMessageManager->InitWithCallback(this);
+ // Send the child its remote type. On Mac, this needs to be sent prior
+ // to the message we send to enable the Sandbox (SendStartProcessSandbox)
+ // because different remote types require different sandbox privileges.
+ Unused << SendRemoteType(mRemoteType);
+
// Set the subprocess's priority. We do this early on because we're likely
// /lowering/ the process's CPU and memory priority, which it has inherited
// from this process.
//
// This call can cause us to send IPC messages to the child process, so it
// must come after the Open() call above.
ProcessPriorityManager::SetProcessPriority(this, aInitialPriority);