Bug 1498032 - Part 0. Move the removeUnknownPolicies function into macOSPoliciesParser.jsm. r=spohl
authorFelipe Gomes <felipc@gmail.com>
Thu, 11 Oct 2018 19:07:50 +0000
changeset 499232 31eac8d65771c51c5e1a099e1a57dadcc98fc57a
parent 499231 71892e0c54f9f321fea9d02519522d278e014349
child 499233 c58e52e69803f3892fd1812694b6da1918906c35
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1498032
milestone64.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 1498032 - Part 0. Move the removeUnknownPolicies function into macOSPoliciesParser.jsm. r=spohl This just simplifies things a bit for the next patch Differential Revision: https://phabricator.services.mozilla.com/D8301
browser/components/enterprisepolicies/EnterprisePolicies.js
browser/components/enterprisepolicies/macOSPoliciesParser.jsm
--- a/browser/components/enterprisepolicies/EnterprisePolicies.js
+++ b/browser/components/enterprisepolicies/EnterprisePolicies.js
@@ -437,28 +437,16 @@ class macOSPoliciesProvider {
   constructor() {
     this._policies = null;
     let prefReader = Cc["@mozilla.org/mac-preferences-reader;1"]
                        .createInstance(Ci.nsIMacPreferencesReader);
     if (!prefReader.policiesEnabled()) {
       return;
     }
     this._policies = macOSPoliciesParser.readPolicies(prefReader);
-    this._removeUnknownPolicies();
-  }
-
-  _removeUnknownPolicies() {
-    let { schema } = ChromeUtils.import("resource:///modules/policies/schema.jsm", {});
-
-    for (let policyName of Object.keys(this._policies)) {
-      if (!schema.properties.hasOwnProperty(policyName)) {
-        log.debug(`Removing unknown policy: ${policyName}`);
-        delete this._policies[policyName];
-      }
-    }
   }
 
   get hasPolicies() {
     return this._policies !== null;
   }
 
   get policies() {
     return this._policies;
--- a/browser/components/enterprisepolicies/macOSPoliciesParser.jsm
+++ b/browser/components/enterprisepolicies/macOSPoliciesParser.jsm
@@ -23,17 +23,33 @@ var EXPORTED_SYMBOLS = ["macOSPoliciesPa
 
 var macOSPoliciesParser = {
   readPolicies(reader) {
     let nativePolicies = reader.readPreferences();
     if (!nativePolicies) {
       return null;
     }
 
+    nativePolicies = this.removeUnknownPolicies(nativePolicies);
+
     // Need an extra check here so we don't
     // JSON.stringify if we aren't in debug mode
     if (log.maxLogLevel == "debug") {
       log.debug(JSON.stringify(nativePolicies, null, 2));
     }
 
     return nativePolicies;
   },
+
+  removeUnknownPolicies(policies) {
+    let { schema } = ChromeUtils.import("resource:///modules/policies/schema.jsm", {});
+
+    for (let policyName of Object.keys(policies)) {
+      if (!schema.properties.hasOwnProperty(policyName)) {
+        log.debug(`Removing unknown policy: ${policyName}`);
+        delete policies[policyName];
+      }
+    }
+
+    return policies;
+  },
+
 };