Bug 1174857 - Propagate safemode to the child process. r=billm
☠☠ backed out by b4060e527bd2 ☠ ☠
authorBenoit Girard <b56girard@gmail.com>
Tue, 16 Jun 2015 17:16:51 -0400
changeset 267456 b8601df335c1ac8e5974bd0c1e9b5ce07a83c542
parent 267455 dbb334e7ebebae1408c0d03f2baad227a340e7aa
child 267457 291d1ba8961cc96228539a40b0a59942094dd338
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1174857
milestone41.0a1
Bug 1174857 - Propagate safemode to the child process. r=billm
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsAppRunner.h
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -63,16 +63,17 @@
 #elif defined(XP_MACOSX)
 #include "mozilla/Sandbox.h"
 #endif
 #endif
 
 #include "mozilla/unused.h"
 
 #include "mozInlineSpellChecker.h"
+#include "nsAppRunner.h"
 #include "nsIConsoleListener.h"
 #include "nsICycleCollectorListener.h"
 #include "nsIDragService.h"
 #include "nsIIPCBackgroundChildCreateCallback.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIMemoryReporter.h"
 #include "nsIMemoryInfoDumper.h"
 #include "nsIMutable.h"
@@ -795,27 +796,33 @@ ContentChild::InitXPCOM()
     }
 
     mConsoleListener = new ConsoleListener(this);
     if (NS_FAILED(svc->RegisterListener(mConsoleListener)))
         NS_WARNING("Couldn't register console listener for child process");
 
     bool isOffline, isLangRTL;
     bool isConnected;
+    bool isSafeMode;
     ClipboardCapabilities clipboardCaps;
     DomainPolicyClone domainPolicy;
     OwningSerializedStructuredCloneBuffer initialData;
 
     SendGetXPCOMProcessAttributes(&isOffline, &isConnected,
                                   &isLangRTL, &mAvailableDictionaries,
-                                  &clipboardCaps, &domainPolicy, &initialData);
+                                  &clipboardCaps, &domainPolicy, &initialData,
+                                  &isSafeMode);
     RecvSetOffline(isOffline);
     RecvSetConnectivity(isConnected);
     RecvBidiKeyboardNotify(isLangRTL);
 
+    if (isSafeMode) {
+      mozilla::startup::SetSafeMode();
+    }
+
     // Create the CPOW manager as soon as possible.
     SendPJavaScriptConstructor();
 
     if (domainPolicy.active()) {
         nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
         MOZ_ASSERT(ssm);
         ssm->ActivateDomainPolicyInternal(getter_AddRefs(mPolicy));
         if (!mPolicy) {
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -3213,17 +3213,18 @@ ContentParent::RecvGetProcessAttributes(
 
 bool
 ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline,
                                              bool* aIsConnected,
                                              bool* aIsLangRTL,
                                              InfallibleTArray<nsString>* dictionaries,
                                              ClipboardCapabilities* clipboardCaps,
                                              DomainPolicyClone* domainPolicy,
-                                             OwningSerializedStructuredCloneBuffer* initialData)
+                                             OwningSerializedStructuredCloneBuffer* initialData,
+                                             bool* aIsSafeMode)
 {
     nsCOMPtr<nsIIOService> io(do_GetIOService());
     MOZ_ASSERT(io, "No IO service?");
     DebugOnly<nsresult> rv = io->GetOffline(aIsOffline);
     MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed getting offline?");
 
     rv = io->GetConnectivity(aIsConnected);
     MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed getting connectivity?");
@@ -3268,16 +3269,18 @@ ContentParent::RecvGetXPCOMProcessAttrib
         JSAutoStructuredCloneBuffer buffer;
         if (!buffer.write(jsapi.cx(), init)) {
             return false;
         }
 
         buffer.steal(&initialData->data, &initialData->dataLength);
     }
 
+    *aIsSafeMode = mozilla::startup::IsSafeMode();
+
     return true;
 }
 
 mozilla::jsipc::PJavaScriptParent *
 ContentParent::AllocPJavaScriptParent()
 {
     MOZ_ASSERT(!ManagedPJavaScriptParent().Length());
     return nsIContentParent::AllocPJavaScriptParent();
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -549,17 +549,18 @@ private:
                                           bool* aIsForApp,
                                           bool* aIsForBrowser) override;
     virtual bool RecvGetXPCOMProcessAttributes(bool* aIsOffline,
                                                bool* aIsConnected,
                                                bool* aIsLangRTL,
                                                InfallibleTArray<nsString>* dictionaries,
                                                ClipboardCapabilities* clipboardCaps,
                                                DomainPolicyClone* domainPolicy,
-                                               OwningSerializedStructuredCloneBuffer* initialData) override;
+                                               OwningSerializedStructuredCloneBuffer* initialData,
+                                               bool* aIsSafeMode) override;
 
     virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) override;
 
     virtual bool DeallocPRemoteSpellcheckEngineParent(PRemoteSpellcheckEngineParent*) override;
     virtual PBrowserParent* AllocPBrowserParent(const TabId& aTabId,
                                                 const IPCTabContext& aContext,
                                                 const uint32_t& aChromeFlags,
                                                 const ContentParentId& aCpId,
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -666,17 +666,18 @@ parent:
      * Keep the return values in sync with PBrowser()!
      */
     sync GetProcessAttributes()
         returns (ContentParentId cpId, bool isForApp, bool isForBrowser);
     sync GetXPCOMProcessAttributes()
         returns (bool isOffline, bool isConnected, bool isLangRTL, nsString[] dictionaries,
                  ClipboardCapabilities clipboardCaps,
                  DomainPolicyClone domainPolicy,
-                 OwningSerializedStructuredCloneBuffer initialData);
+                 OwningSerializedStructuredCloneBuffer initialData,
+                 bool isSafeMode);
 
     sync CreateChildProcess(IPCTabContext context,
                             ProcessPriority priority,
                             TabId openerTabId)
         returns (ContentParentId cpId, bool isForApp, bool isForBrowser, TabId tabId);
     sync BridgeToChildProcess(ContentParentId cpId);
 
     async CreateGMPService();
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -4530,16 +4530,22 @@ XRE_GetProcessType()
 }
 
 bool
 XRE_IsParentProcess()
 {
   return XRE_GetProcessType() == GeckoProcessType_Default;
 }
 
+void
+mozilla::startup::SetSafeMode()
+{
+  gSafeMode = true;
+}
+
 #ifdef E10S_TESTING_ONLY
 static void
 LogE10sBlockedReason(const char *reason) {
   gBrowserTabsRemoteDisabledReason.Assign(NS_ConvertASCIItoUTF16(reason));
 
   nsAutoString msg(NS_LITERAL_STRING("==================\nE10s has been blocked from running because:\n"));
   msg.Append(gBrowserTabsRemoteDisabledReason);
   msg.AppendLiteral("\n==================\n");
--- a/toolkit/xre/nsAppRunner.h
+++ b/toolkit/xre/nsAppRunner.h
@@ -107,16 +107,19 @@ BOOL
 WriteStatusApplied(LPCWSTR updateDirPath);
 #endif
 
 #define NS_NATIVEAPPSUPPORT_CONTRACTID "@mozilla.org/toolkit/native-app-support;1"
 
 namespace mozilla {
 namespace startup {
 extern GeckoProcessType sChildProcessType;
+
+void SetSafeMode();
+bool IsSafeMode() { return gSafeMode; }
 }
 }
 
 /**
  * Set up platform specific error handling such as suppressing DLL load dialog
  * and the JIT debugger on Windows, and install unix signal handlers.
  */
 void SetupErrorHandling(const char* progname);