None draft
authorKris Maglione <maglione.k@gmail.com>
Fri, 26 Jun 2020 23:34:54 +0000
changeset 3008949 ce7acabdf162cdb208246b898c046c761552b089
parent 3008948 06dc78e6c57c7ef13c70d69f73602fde4e7d8d6f
child 3008950 6b82c18f2d733d53ea7a3345a5525dfe1aae9d32
push id560888
push userreviewbot
push dateFri, 26 Jun 2020 23:35:16 +0000
treeherdertry@6b82c18f2d73 [default view] [failures only]
milestone79.0a1
None Differential Diff: PHID-DIFF-2eunmxyav24ksntautdp
browser/installer/package-manifest.in
toolkit/components/enterprisepolicies/EnterprisePolicies.js
toolkit/components/enterprisepolicies/EnterprisePolicies.jsm
toolkit/components/enterprisepolicies/EnterprisePolicies.manifest
toolkit/components/enterprisepolicies/EnterprisePoliciesContent.js
toolkit/components/enterprisepolicies/EnterprisePoliciesContent.jsm
toolkit/components/enterprisepolicies/EnterprisePoliciesParent.jsm
toolkit/components/enterprisepolicies/components.conf
toolkit/components/enterprisepolicies/moz.build
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -164,19 +164,16 @@
 @BINPATH@/AccessibleHandler.dll
 @BINPATH@/AccessibleMarshal.dll
 @BINPATH@/IA2Marshal.dll
 #endif
 #endif
 
 ; JavaScript components
 @RESPATH@/browser/components/BrowserComponents.manifest
-@RESPATH@/components/EnterprisePolicies.js
-@RESPATH@/components/EnterprisePoliciesContent.js
-@RESPATH@/components/EnterprisePolicies.manifest
 @RESPATH@/components/toolkitsearch.manifest
 @RESPATH@/components/extensions.manifest
 #ifdef MOZ_UPDATER
 @RESPATH@/components/nsUpdateService.manifest
 #endif
 @RESPATH@/components/ProcessSingleton.manifest
 @RESPATH@/components/HandlerService.manifest
 @RESPATH@/components/HandlerService.js
new file mode 100644
--- /dev/null
+++ b/toolkit/components/enterprisepolicies/EnterprisePolicies.jsm
@@ -0,0 +1,20 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var EXPORTED_SYMBOLS = ["EnterprisePolicies"];
+
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
+function EnterprisePolicies() {
+  if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_DEFAULT) {
+    const { EnterprisePoliciesManager } = ChromeUtils.import(
+      "resource://gre/modules/EnterprisePoliciesParent.jsm"
+    );
+    return new EnterprisePoliciesManager();
+  }
+  const { EnterprisePoliciesManagerContent } = ChromeUtils.import(
+    "resource://gre/modules/EnterprisePoliciesParent.jsm"
+  );
+  return new EnterprisePoliciesManagerContent();
+}
deleted file mode 100644
--- a/toolkit/components/enterprisepolicies/EnterprisePolicies.manifest
+++ /dev/null
@@ -1,5 +0,0 @@
-component {ea4e1414-779b-458b-9d1f-d18e8efbc145} EnterprisePolicies.js process=main
-contract @mozilla.org/enterprisepolicies;1 {ea4e1414-779b-458b-9d1f-d18e8efbc145} process=main
-
-component {dc6358f8-d167-4566-bf5b-4350b5e6a7a2} EnterprisePoliciesContent.js process=content
-contract @mozilla.org/enterprisepolicies;1 {dc6358f8-d167-4566-bf5b-4350b5e6a7a2} process=content
rename from toolkit/components/enterprisepolicies/EnterprisePoliciesContent.js
rename to toolkit/components/enterprisepolicies/EnterprisePoliciesContent.jsm
--- a/toolkit/components/enterprisepolicies/EnterprisePoliciesContent.js
+++ b/toolkit/components/enterprisepolicies/EnterprisePoliciesContent.jsm
@@ -1,36 +1,27 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-const { XPCOMUtils } = ChromeUtils.import(
-  "resource://gre/modules/XPCOMUtils.jsm"
-);
+var EXPORTED_SYMBOLS = ["EnterprisePoliciesManagerContent"];
+
 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-function EnterprisePoliciesManagerContent() {}
-
-EnterprisePoliciesManagerContent.prototype = {
-  classID: Components.ID("{dc6358f8-d167-4566-bf5b-4350b5e6a7a2}"),
-  QueryInterface: ChromeUtils.generateQI([Ci.nsIEnterprisePolicies]),
-  _xpcom_factory: XPCOMUtils.generateSingletonFactory(
-    EnterprisePoliciesManagerContent
-  ),
-
+class EnterprisePoliciesManagerContent {
   get status() {
     return (
       Services.cpmm.sharedData.get("EnterprisePolicies:Status") ||
       Ci.nsIEnterprisePolicies.INACTIVE
     );
-  },
+  }
 
   isAllowed(feature) {
     let disallowedFeatures = Services.cpmm.sharedData.get(
       "EnterprisePolicies:DisallowedFeatures"
     );
     return !(disallowedFeatures && disallowedFeatures.has(feature));
-  },
-};
+  }
+}
 
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([
-  EnterprisePoliciesManagerContent,
-]);
+EnterprisePoliciesManagerContent.prototype.QueryInterface = ChromeUtils.generateQI(
+  [Ci.nsIEnterprisePolicies]
+);
rename from toolkit/components/enterprisepolicies/EnterprisePolicies.js
rename to toolkit/components/enterprisepolicies/EnterprisePoliciesParent.jsm
--- a/toolkit/components/enterprisepolicies/EnterprisePolicies.js
+++ b/toolkit/components/enterprisepolicies/EnterprisePoliciesParent.jsm
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+var EXPORTED_SYMBOLS = ["EnterprisePoliciesManager"];
+
 const { XPCOMUtils } = ChromeUtils.import(
   "resource://gre/modules/XPCOMUtils.jsm"
 );
 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const { AppConstants } = ChromeUtils.import(
   "resource://gre/modules/AppConstants.jsm"
 );
 
@@ -75,25 +77,21 @@ function isEmptyObject(obj) {
 function EnterprisePoliciesManager() {
   Services.obs.addObserver(this, "profile-after-change", true);
   Services.obs.addObserver(this, "final-ui-startup", true);
   Services.obs.addObserver(this, "sessionstore-windows-restored", true);
   Services.obs.addObserver(this, "EnterprisePolicies:Restart", true);
 }
 
 EnterprisePoliciesManager.prototype = {
-  classID: Components.ID("{ea4e1414-779b-458b-9d1f-d18e8efbc145}"),
   QueryInterface: ChromeUtils.generateQI([
     Ci.nsIObserver,
     Ci.nsISupportsWeakReference,
     Ci.nsIEnterprisePolicies,
   ]),
-  _xpcom_factory: XPCOMUtils.generateSingletonFactory(
-    EnterprisePoliciesManager
-  ),
 
   _initialize() {
     let provider = this._chooseProvider();
 
     if (!provider) {
       this.status = Ci.nsIEnterprisePolicies.INACTIVE;
       return;
     }
@@ -622,11 +620,8 @@ class macOSPoliciesProvider {
   get policies() {
     return this._policies;
   }
 
   get failed() {
     return this._failed;
   }
 }
-
-var components = [EnterprisePoliciesManager];
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
new file mode 100644
--- /dev/null
+++ b/toolkit/components/enterprisepolicies/components.conf
@@ -0,0 +1,14 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+Classes = [
+    {
+        'cid': '{49e8d8ef-a713-492a-a3d2-5c9dad4ce2e5}',
+        'contract_ids': ['@mozilla.org/enterprisepolicies;1'],
+        'jsm': 'resource://gre/modules/EnterprisePolicies.jsm',
+        'constructor': 'EnterprisePolicies',
+    },
+]
--- a/toolkit/components/enterprisepolicies/moz.build
+++ b/toolkit/components/enterprisepolicies/moz.build
@@ -13,20 +13,24 @@ XPIDL_SOURCES += [
 
 XPIDL_MODULE = 'enterprisepolicies'
 
 TEST_DIRS += [
     'tests'
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != "android":
-    EXTRA_COMPONENTS += [
-        'EnterprisePolicies.js',
-        'EnterprisePolicies.manifest',
-        'EnterprisePoliciesContent.js',
+    EXTRA_JS_MODULES += [
+        'EnterprisePolicies.jsm',
+        'EnterprisePoliciesContent.jsm',
+        'EnterprisePoliciesParent.jsm',
+    ]
+
+    XPCOM_MANIFESTS += [
+        'components.conf',
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     EXTRA_JS_MODULES.policies += [
         'WindowsGPOParser.jsm',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':