Bug 1464542: Part 3a - Modernize enterprise policy registration. r=mkaply
Aside from making registration somewhat more efficient, this allows us to make the services available on the new C++-implemented JS Services object, which requires services to use the new static component registration system. Differential Revision: https://phabricator.services.mozilla.com/D81418
This commit is contained in:
@@ -173,9 +173,6 @@
|
||||
|
||||
; 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
|
||||
|
||||
22
toolkit/components/enterprisepolicies/EnterprisePolicies.jsm
Normal file
22
toolkit/components/enterprisepolicies/EnterprisePolicies.jsm
Normal file
@@ -0,0 +1,22 @@
|
||||
/* 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"];
|
||||
|
||||
function EnterprisePolicies() {
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
const appinfo = Cc["@mozilla.org/xre/app-info;1"].getService(
|
||||
Ci.nsIXULRuntime
|
||||
);
|
||||
if (appinfo.processType == appinfo.PROCESS_TYPE_DEFAULT) {
|
||||
const { EnterprisePoliciesManager } = ChromeUtils.import(
|
||||
"resource://gre/modules/EnterprisePoliciesParent.jsm"
|
||||
);
|
||||
return new EnterprisePoliciesManager();
|
||||
}
|
||||
const { EnterprisePoliciesManagerContent } = ChromeUtils.import(
|
||||
"resource://gre/modules/EnterprisePoliciesContent.jsm"
|
||||
);
|
||||
return new EnterprisePoliciesManagerContent();
|
||||
}
|
||||
@@ -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
|
||||
@@ -2,35 +2,26 @@
|
||||
* 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]
|
||||
);
|
||||
@@ -2,6 +2,8 @@
|
||||
* 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"
|
||||
);
|
||||
@@ -80,15 +82,11 @@ function EnterprisePoliciesManager() {
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -631,6 +629,3 @@ class macOSPoliciesProvider {
|
||||
return this._failed;
|
||||
}
|
||||
}
|
||||
|
||||
var components = [EnterprisePoliciesManager];
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
|
||||
14
toolkit/components/enterprisepolicies/components.conf
Normal file
14
toolkit/components/enterprisepolicies/components.conf
Normal file
@@ -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',
|
||||
},
|
||||
]
|
||||
@@ -18,10 +18,14 @@ TEST_DIRS += [
|
||||
]
|
||||
|
||||
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':
|
||||
|
||||
Reference in New Issue
Block a user