Bug 1530788: Ensure that the launcher process pref remains functional on Nightly; r=mhowell
authorAaron Klotz <aklotz@mozilla.com>
Tue, 26 Feb 2019 21:38:08 +0000
changeset 519374 86bed3fcf6f50e90e64cbde7b67659a267d6b955
parent 519373 be0aba20d1d170ceaf5333e3c25b1db23ec42c64
child 519375 5be3bd53aaade28dbe7c92f1c6174fd303fda3bf
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhowell
bugs1530788
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530788: Ensure that the launcher process pref remains functional on Nightly; r=mhowell Differential Revision: https://phabricator.services.mozilla.com/D21254
browser/app/profile/firefox.js
toolkit/xre/nsAppRunner.cpp
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1807,13 +1807,18 @@ pref("browser.discovery.enabled", true);
 pref("browser.discovery.containers.enabled", true);
 pref("browser.discovery.sites", "addons.mozilla.org");
 
 pref("browser.engagement.recent_visited_origins.expiry", 86400); // 24 * 60 * 60 (24 hours in seconds)
 
 pref("browser.aboutConfig.showWarning", true);
 
 #if defined(XP_WIN) && defined(MOZ_LAUNCHER_PROCESS)
+#if defined(NIGHTLY_BUILD)
+// Enable launcher process by default on Nightly
+pref("browser.launcherProcess.enabled", true);
+#else
 // Launcher process is disabled by default, will be selectively enabled via SHIELD
 pref("browser.launcherProcess.enabled", false);
+#endif  // defined(NIGHTLY_BUILD)
 #endif // defined(XP_WIN) && defined(MOZ_LAUNCHER_PROCESS)
 
 pref("browser.toolbars.keyboard_navigation", false);
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -1664,35 +1664,37 @@ static void RegisterApplicationRestartCh
     }
   } else if (wasRegistered) {
     ::UnregisterApplicationRestart();
   }
 }
 
 #  if defined(MOZ_LAUNCHER_PROCESS)
 
+static const char kShieldPrefName[] = "app.shield.optoutstudies.enabled";
+
 static void OnLauncherPrefChanged(const char* aPref, void* aData) {
-  bool prefVal = Preferences::GetBool(aPref, false);
+  bool prefVal = Preferences::GetBool(kShieldPrefName, false) &&
+                 Preferences::GetBool(PREF_WIN_LAUNCHER_PROCESS_ENABLED, false);
 
   mozilla::LauncherRegistryInfo launcherRegInfo;
   mozilla::LauncherVoidResult reflectResult =
       launcherRegInfo.ReflectPrefToRegistry(prefVal);
   MOZ_ASSERT(reflectResult.isOk());
 }
 
 static void SetupLauncherProcessPref() {
+  // In addition to the launcher pref itself, we also tie the launcher process
+  // state to the SHIELD opt-out pref.
+
 #    if defined(NIGHTLY_BUILD)
-  // On Nightly, tie launcher state to the SHIELD opt-out pref. Fire the
-  // callback immediately to ensure the pref is reflected to the registry.
-  // Also handle any future modification to SHIELD opt-out.
-  Preferences::RegisterCallbackAndCall(&OnLauncherPrefChanged,
-                                       "app.shield.optoutstudies.enabled");
-
-  // Now we fall-through to the remaining code that populates the launcher
-  // pref and the crash report annotations.
+  // On Nightly, fire the callback immediately to ensure the pref is reflected
+  // to the registry and we get immediate enablement of the launcher process
+  // for all users.
+  Preferences::RegisterCallbackAndCall(&OnLauncherPrefChanged, kShieldPrefName);
 #    endif  // defined(NIGHTLY_BUILD)
 
   mozilla::LauncherRegistryInfo launcherRegInfo;
 
   mozilla::LauncherResult<mozilla::LauncherRegistryInfo::EnabledState>
       enabledState = launcherRegInfo.IsEnabled();
 
   if (enabledState.isOk()) {
@@ -1701,20 +1703,22 @@ static void SetupLauncherProcessPref() {
         enabledState.unwrap() !=
             mozilla::LauncherRegistryInfo::EnabledState::ForceDisabled);
 
     CrashReporter::AnnotateCrashReport(
         CrashReporter::Annotation::LauncherProcessState,
         static_cast<uint32_t>(enabledState.unwrap()));
   }
 
-#    if !defined(NIGHTLY_BUILD)
-  // Only watch the launcher pref if we're not on nightly
   Preferences::RegisterCallback(&OnLauncherPrefChanged,
                                 PREF_WIN_LAUNCHER_PROCESS_ENABLED);
+#    if !defined(NIGHTLY_BUILD)
+  // We register for SHIELD notifications, but we don't fire the callback
+  // immediately in the non-Nightly case.
+  Preferences::RegisterCallback(&OnLauncherPrefChanged, kShieldPrefName);
 #    endif  // !defined(NIGHTLY_BUILD)
 }
 
 #  endif  // defined(MOZ_LAUNCHER_PROCESS)
 
 #endif  // XP_WIN
 
 // If aBlankCommandLine is true, then the application will be launched with a