From 76125849c6b81a76162e413f220ac6493c1cba31 Mon Sep 17 00:00:00 2001 From: Aaron Klotz Date: Wed, 9 Jan 2019 23:35:25 +0000 Subject: [PATCH] Bug 1511080: Add launcher process pref and enable reflection to/from the registry; r=mhowell Depends on D15756 Differential Revision: https://phabricator.services.mozilla.com/D15757 --HG-- extra : moz-landing-system : lando --- browser/app/profile/firefox.js | 5 +++++ toolkit/xre/nsAppRunner.cpp | 39 ++++++++++++++++++++++++++++++++++ toolkit/xre/nsAppRunner.h | 4 ++++ 3 files changed, 48 insertions(+) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index c1e5007ab189..35a071e6b612 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1794,3 +1794,8 @@ pref("browser.engagement.recent_visited_origins.expiry", 86400); // 24 * 60 * 60 #ifdef NIGHTLY_BUILD pref("browser.aboutConfig.showWarning", true); #endif + +#if defined(XP_WIN) && defined(MOZ_LAUNCHER_PROCESS) +// Launcher process is disabled by default, will be selectively enabled via SHIELD +pref("browser.launcherProcess.enabled", false); +#endif // defined(XP_WIN) && defined(MOZ_LAUNCHER_PROCESS) diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 2a8cb5929b91..b1bedf4f5959 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -110,6 +110,10 @@ #include "mozilla/mscom/MainThreadRuntime.h" #include "mozilla/widget/AudioSession.h" +#if defined(MOZ_LAUNCHER_PROCESS) +#include "mozilla/LauncherRegistryInfo.h" +#endif + #ifndef PROCESS_DEP_ENABLE #define PROCESS_DEP_ENABLE 0x1 #endif @@ -1628,6 +1632,38 @@ static void RegisterApplicationRestartChanged(const char* aPref, void* aData) { ::UnregisterApplicationRestart(); } } + +#if defined(MOZ_LAUNCHER_PROCESS) + +static void OnLauncherPrefChanged(const char* aPref, void* aData) { + bool prefVal = + Preferences::GetBool(PREF_WIN_LAUNCHER_PROCESS_ENABLED, false); + + mozilla::LauncherRegistryInfo launcherRegInfo; + mozilla::LauncherVoidResult reflectResult = + launcherRegInfo.ReflectPrefToRegistry(prefVal); + MOZ_ASSERT(reflectResult.isOk()); +} + +static void SetupLauncherProcessPref() { + mozilla::LauncherRegistryInfo launcherRegInfo; + + mozilla::LauncherResult + enabledState = launcherRegInfo.IsEnabled(); + + if (enabledState.isOk()) { + Preferences::SetBool( + PREF_WIN_LAUNCHER_PROCESS_ENABLED, + enabledState.unwrap() != + mozilla::LauncherRegistryInfo::EnabledState::ForceDisabled); + } + + Preferences::RegisterCallback(&OnLauncherPrefChanged, + PREF_WIN_LAUNCHER_PROCESS_ENABLED); +} + +#endif // defined(MOZ_LAUNCHER_PROCESS) + #endif // XP_WIN // If aBlankCommandLine is true, then the application will be launched with a @@ -4230,6 +4266,9 @@ nsresult XREMain::XRE_mainRun() { #ifdef XP_WIN Preferences::RegisterCallbackAndCall(RegisterApplicationRestartChanged, PREF_WIN_REGISTER_APPLICATION_RESTART); +#if defined(MOZ_LAUNCHER_PROCESS) + SetupLauncherProcessPref(); +#endif // defined(MOZ_LAUNCHER_PROCESS) #endif #if defined(HAVE_DESKTOP_STARTUP_ID) && defined(MOZ_WIDGET_GTK) diff --git a/toolkit/xre/nsAppRunner.h b/toolkit/xre/nsAppRunner.h index 2d6e0f8e137f..09a1930c47e7 100644 --- a/toolkit/xre/nsAppRunner.h +++ b/toolkit/xre/nsAppRunner.h @@ -102,6 +102,10 @@ BOOL WinLaunchChild(const wchar_t* exePath, int argc, char** argv, #define PREF_WIN_REGISTER_APPLICATION_RESTART \ "toolkit.winRegisterApplicationRestart" + +#if defined(MOZ_LAUNCHER_PROCESS) +#define PREF_WIN_LAUNCHER_PROCESS_ENABLED "browser.launcherProcess.enabled" +#endif // defined(MOZ_LAUNCHER_PROCESS) #endif namespace mozilla {