Bug 1574963 - Add a policy for using legacy profiles on Windows. r=mossop
authorMichael Kaply <mozilla@kaply.com>
Thu, 03 Oct 2019 17:47:17 +0000
changeset 496212 eaa0c1e72e51139f37dd0486c15753b71e33c1fd
parent 496211 5921da6981097a5b1cb16335a0d7d22136239693
child 496213 f940e64a5ebe1520099f2a7b638a309a88301bd8
push id36647
push usernerli@mozilla.com
push dateFri, 04 Oct 2019 04:09:18 +0000
treeherdermozilla-central@678d4d2c3c4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1574963
milestone71.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 1574963 - Add a policy for using legacy profiles on Windows. r=mossop Differential Revision: https://phabricator.services.mozilla.com/D47841
browser/components/enterprisepolicies/Policies.jsm
browser/components/enterprisepolicies/schemas/policies-schema.json
toolkit/profile/nsToolkitProfileService.cpp
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -937,16 +937,20 @@ var Policies = {
             false
           );
           manager.disallowFeature("xpinstall");
         }
       }
     },
   },
 
+  LegacyProfiles: {
+    // Handled in nsToolkitProfileService.cpp (Windows only)
+  },
+
   LocalFileLinks: {
     onBeforeAddons(manager, param) {
       // If there are existing capabilities, lock them with the policy pref.
       let policyNames = Services.prefs
         .getCharPref("capability.policy.policynames", "")
         .split(" ");
       policyNames.push("localfilelinks_policy");
       setAndLockPref("capability.policy.policynames", policyNames.join(" "));
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -472,16 +472,20 @@
           }
         },
         "Default": {
           "type": "boolean"
         }
       }
     },
 
+    "LegacyProfiles": {
+      "type": "boolean"
+    },
+
     "LocalFileLinks": {
       "type": "array",
       "items": {
         "type": "string"
       }
     },
 
     "NetworkPrediction": {
--- a/toolkit/profile/nsToolkitProfileService.cpp
+++ b/toolkit/profile/nsToolkitProfileService.cpp
@@ -9,16 +9,17 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <prprf.h>
 #include <prtime.h>
 
 #ifdef XP_WIN
 #  include <windows.h>
 #  include <shlobj.h>
+#  include "mozilla/PolicyChecks.h"
 #endif
 #ifdef XP_UNIX
 #  include <unistd.h>
 #endif
 
 #include "nsToolkitProfileService.h"
 #include "CmdLineAndEnvUtils.h"
 #include "nsIFile.h"
@@ -1792,19 +1793,25 @@ bool nsToolkitProfileService::IsSnapEnvi
 }
 
 /**
  * In some situations dedicated profile support does not work well. This
  * includes a handful of linux distributions which always install different
  * application versions to different locations, some application sandboxing
  * systems as well as enterprise deployments. This environment variable provides
  * a way to opt out of dedicated profiles for these cases.
+ *
+ * For Windows, we provide a policy to accomplish the same thing.
  */
 bool nsToolkitProfileService::UseLegacyProfiles() {
-  return !!PR_GetEnv("MOZ_LEGACY_PROFILES");
+  bool legacyProfiles = !!PR_GetEnv("MOZ_LEGACY_PROFILES");
+#ifdef XP_WIN
+  legacyProfiles |= PolicyCheckBoolean(L"LegacyProfiles");
+#endif
+  return legacyProfiles;
 }
 
 struct FindInstallsClosure {
   nsINIParser* installData;
   nsTArray<nsCString>* installs;
 };
 
 static bool FindInstalls(const char* aSection, void* aClosure) {