diff --git a/browser/components/enterprisepolicies/EnterprisePolicies.js b/browser/components/enterprisepolicies/EnterprisePolicies.js index 07df44426c5e..223f7e5b572d 100644 --- a/browser/components/enterprisepolicies/EnterprisePolicies.js +++ b/browser/components/enterprisepolicies/EnterprisePolicies.js @@ -195,16 +195,16 @@ EnterprisePoliciesManager.prototype = { DisallowedFeatures = {}; + Services.ppmm.sharedData.delete("EnterprisePolicies:Status"); + Services.ppmm.sharedData.delete("EnterprisePolicies:DisallowedFeatures"); + this._status = Ci.nsIEnterprisePolicies.UNINITIALIZED; for (let timing of Object.keys(this._callbacks)) { this._callbacks[timing] = []; } - delete Services.ppmm.initialProcessData.policies; - Services.ppmm.broadcastAsyncMessage("EnterprisePolicies:Restart", null); let { PromiseUtils } = ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm", {}); - // Simulate the startup process. This step-by-step is a bit ugly but it // tries to emulate the same behavior as of a normal startup. @@ -259,21 +259,13 @@ EnterprisePoliciesManager.prototype = { }, disallowFeature(feature, neededOnContentProcess = false) { - DisallowedFeatures[feature] = true; + DisallowedFeatures[feature] = neededOnContentProcess; // NOTE: For optimization purposes, only features marked as needed // on content process will be passed onto the child processes. if (neededOnContentProcess) { - Services.ppmm.initialProcessData.policies - .disallowedFeatures.push(feature); - - if (Services.ppmm.childCount > 1) { - // If there has been a content process already initialized, let's - // broadcast the newly disallowed feature. - Services.ppmm.broadcastAsyncMessage( - "EnterprisePolicies:DisallowFeature", {feature} - ); - } + Services.ppmm.sharedData.set("EnterprisePolicies:DisallowedFeatures", + new Set(Object.keys(DisallowedFeatures).filter(key => DisallowedFeatures[key]))); } }, @@ -286,10 +278,7 @@ EnterprisePoliciesManager.prototype = { set status(val) { this._status = val; if (val != Ci.nsIEnterprisePolicies.INACTIVE) { - Services.ppmm.initialProcessData.policies = { - status: val, - disallowedFeatures: [], - }; + Services.ppmm.sharedData.set("EnterprisePolicies:Status", val); } return val; }, diff --git a/browser/components/enterprisepolicies/EnterprisePoliciesContent.js b/browser/components/enterprisepolicies/EnterprisePoliciesContent.js index 74e714af4854..8e79fe65d1d8 100644 --- a/browser/components/enterprisepolicies/EnterprisePoliciesContent.js +++ b/browser/components/enterprisepolicies/EnterprisePoliciesContent.js @@ -36,16 +36,6 @@ const EnterprisePoliciesFactory = { function EnterprisePoliciesManagerContent() { - let policies = Services.cpmm.initialProcessData.policies; - if (policies) { - this._status = policies.status; - // make a copy of the array so that we can keep adding to it - // in a way that is not confusing. - this._disallowedFeatures = policies.disallowedFeatures.slice(); - } - - Services.cpmm.addMessageListener("EnterprisePolicies:DisallowFeature", this); - Services.cpmm.addMessageListener("EnterprisePolicies:Restart", this); } EnterprisePoliciesManagerContent.prototype = { @@ -56,28 +46,15 @@ EnterprisePoliciesManagerContent.prototype = { // redefine the default factory for XPCOMUtils _xpcom_factory: EnterprisePoliciesFactory, - _status: Ci.nsIEnterprisePolicies.INACTIVE, - - _disallowedFeatures: [], - - receiveMessage({name, data}) { - switch (name) { - case "EnterprisePolicies:DisallowFeature": - this._disallowedFeatures.push(data.feature); - break; - - case "EnterprisePolicies:Restart": - this._disallowedFeatures = []; - break; - } - }, get status() { - return this._status; + return Services.cpmm.sharedData.get("EnterprisePolicies:Status") || + Ci.nsIEnterprisePolicies.INACTIVE; }, isAllowed(feature) { - return !this._disallowedFeatures.includes(feature); + let disallowedFeatures = Services.cpmm.sharedData.get("EnterprisePolicies:DisallowedFeatures"); + return !(disallowedFeatures && disallowedFeatures.has(feature)); }, getActivePolicies() { diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policies_basic_tests.js b/browser/components/enterprisepolicies/tests/browser/browser_policies_basic_tests.js index 7a3c92268be3..a18562f49930 100644 --- a/browser/components/enterprisepolicies/tests/browser/browser_policies_basic_tests.js +++ b/browser/components/enterprisepolicies/tests/browser/browser_policies_basic_tests.js @@ -4,12 +4,6 @@ "use strict"; add_task(async function test_simple_policies() { - await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() { - // Initialize the service in the content process, in case it hasn't - // already started. - Services.policies; - }); - let { Policies } = ChromeUtils.import("resource:///modules/policies/Policies.jsm", {}); let policy0Ran = false, policy1Ran = false, policy2Ran = false, policy3Ran = false;