Commit 2ff9f81d authored by Michael Kaply's avatar Michael Kaply
Browse files

Bug 1542371 - Add basic support for ExtensionSettings policy. r=Felipe

Differential Revision: https://phabricator.services.mozilla.com/D26376

--HG--
extra : moz-landing-system : lando
parent fdb93637
......@@ -298,11 +298,26 @@ EnterprisePoliciesManager.prototype = {
}
return null;
},
setExtensionSettings(extensionSettings) {
ExtensionSettings = extensionSettings;
},
getExtensionSettings(extensionID) {
let settings = null;
if (extensionID in ExtensionSettings) {
settings = ExtensionSettings[extensionID];
} else if ("*" in ExtensionSettings) {
settings = ExtensionSettings["*"];
}
return settings;
},
};
let DisallowedFeatures = {};
let SupportMenu = null;
let ExtensionPolicies = null;
let ExtensionSettings = null;
/**
* areEnterpriseOnlyPoliciesAllowed
......
......@@ -577,6 +577,12 @@ var Policies = {
},
},
"ExtensionSettings": {
onBeforeAddons(manager, param) {
manager.setExtensionSettings(param);
},
},
"ExtensionUpdate": {
onBeforeAddons(manager, param) {
if (!param) {
......
......@@ -313,6 +313,20 @@
}
},
"ExtensionSettings": {
"type": "object",
"patternProperties": {
"^.*$": {
"type": "object",
"properties": {
"blocked_install_message": {
"type": "string"
}
}
}
}
},
"ExtensionUpdate": {
"type": "boolean"
},
......
......@@ -54,6 +54,7 @@ skip-if = (verify && debug && (os == 'mac'))
[browser_policy_display_bookmarks.js]
[browser_policy_display_menu.js]
[browser_policy_extensions.js]
[browser_policy_extensionsettings.js]
[browser_policy_locale.js]
[browser_policy_override_postupdatepage.js]
[browser_policy_permissions.js]
......
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function test_extensionsettings() {
await setupPolicyEngineWithJson({
"policies": {
"ExtensionSettings": {
"extension1@mozilla.com": {
"blocked_install_message": "Extension1 error message.",
},
"*": {
"blocked_install_message": "Generic error message.",
},
},
},
});
let extensionSettings = Services.policies.getExtensionSettings("extension1@mozilla.com");
is(extensionSettings.blocked_install_message, "Extension1 error message.", "Should have extension specific message.");
extensionSettings = Services.policies.getExtensionSettings("extension2@mozilla.com");
is(extensionSettings.blocked_install_message, "Generic error message.", "Should have generic message.");
});
......@@ -37,4 +37,15 @@ interface nsIEnterprisePolicies : nsISupports
* @returns A JS object that contains the storage or null if unavailable.
*/
jsval getExtensionPolicy(in ACString extensionID);
/**
* Retrieves the ExtensionSettings policy for the given extensionID.
*
* If there is no policy for the extension, it returns the global policy.
*
* If there is no global policy, it returns null.
*
* @returns A JS object that settings or null if unavailable.
*/
jsval getExtensionSettings(in ACString extensionID);
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment