From 495a19e156180610bde9d57b6b50861b076ee37c Mon Sep 17 00:00:00 2001 From: Benoit Girard Date: Tue, 16 Jun 2015 17:16:51 -0400 Subject: [PATCH] Bug 1174857 - Propagate safemode to the child process. r=billm --HG-- extra : rebase_source : 21e31bec462fa2966f5450ca2a69358219249186 --- dom/ipc/ContentChild.cpp | 9 ++++++++- dom/ipc/ContentParent.cpp | 5 ++++- dom/ipc/ContentParent.h | 3 ++- dom/ipc/PContent.ipdl | 3 ++- toolkit/xre/nsAppRunner.cpp | 6 ++++++ toolkit/xre/nsAppRunner.h | 3 +++ 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 69e149d723fd..21f965cb471a 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -68,6 +68,7 @@ #include "mozilla/unused.h" #include "mozInlineSpellChecker.h" +#include "nsAppRunner.h" #include "nsIConsoleListener.h" #include "nsICycleCollectorListener.h" #include "nsIDragService.h" @@ -800,17 +801,23 @@ ContentChild::InitXPCOM() 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(); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 1b80fa383e52..a3dd276d3659 100755 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -3218,7 +3218,8 @@ ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline, InfallibleTArray* dictionaries, ClipboardCapabilities* clipboardCaps, DomainPolicyClone* domainPolicy, - OwningSerializedStructuredCloneBuffer* initialData) + OwningSerializedStructuredCloneBuffer* initialData, + bool* aIsSafeMode) { nsCOMPtr io(do_GetIOService()); MOZ_ASSERT(io, "No IO service?"); @@ -3273,6 +3274,8 @@ ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline, buffer.steal(&initialData->data, &initialData->dataLength); } + *aIsSafeMode = mozilla::startup::IsSafeMode(); + return true; } diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 56410e89abd9..9bb8d0adb7fc 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -554,7 +554,8 @@ private: InfallibleTArray* dictionaries, ClipboardCapabilities* clipboardCaps, DomainPolicyClone* domainPolicy, - OwningSerializedStructuredCloneBuffer* initialData) override; + OwningSerializedStructuredCloneBuffer* initialData, + bool* aIsSafeMode) override; virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) override; diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 33cc91b49880..cb59f460855a 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -671,7 +671,8 @@ parent: 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, diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 03b8945d1275..25adbc5ee656 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -4535,6 +4535,12 @@ XRE_IsParentProcess() return XRE_GetProcessType() == GeckoProcessType_Default; } +void +mozilla::startup::SetSafeMode() +{ + gSafeMode = true; +} + #ifdef E10S_TESTING_ONLY static void LogE10sBlockedReason(const char *reason) { diff --git a/toolkit/xre/nsAppRunner.h b/toolkit/xre/nsAppRunner.h index 1295144c7008..d452e79c1480 100644 --- a/toolkit/xre/nsAppRunner.h +++ b/toolkit/xre/nsAppRunner.h @@ -112,6 +112,9 @@ WriteStatusApplied(LPCWSTR updateDirPath); namespace mozilla { namespace startup { extern GeckoProcessType sChildProcessType; + +void SetSafeMode(); +bool IsSafeMode() { return gSafeMode; } } }