Bug 1448198 - Make the DisplayBookmarksBar and DisplayMenuBar policies support both true and false params. r=bytesized
MozReview-Commit-ID: 7hMINn856WO
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -229,37 +229,35 @@ var Policies = {
if (param) {
manager.disallowFeature("SysAddonUpdate");
}
}
},
"DisplayBookmarksToolbar": {
onBeforeUIStartup(manager, param) {
- if (param) {
- // This policy is meant to change the default behavior, not to force it.
- // If this policy was alreay applied and the user chose to re-hide the
- // bookmarks toolbar, do not show it again.
- runOnce("displayBookmarksToolbar", () => {
- gXulStore.setValue(BROWSER_DOCUMENT_URL, "PersonalToolbar", "collapsed", "false");
- });
- }
+ let value = (!param).toString();
+ // This policy is meant to change the default behavior, not to force it.
+ // If this policy was alreay applied and the user chose to re-hide the
+ // bookmarks toolbar, do not show it again.
+ runOncePerModification("displayBookmarksToolbar", value, () => {
+ gXulStore.setValue(BROWSER_DOCUMENT_URL, "PersonalToolbar", "collapsed", value);
+ });
}
},
"DisplayMenuBar": {
onBeforeUIStartup(manager, param) {
- if (param) {
+ let value = (!param).toString();
// This policy is meant to change the default behavior, not to force it.
// If this policy was alreay applied and the user chose to re-hide the
// menu bar, do not show it again.
- runOnce("displayMenuBar", () => {
- gXulStore.setValue(BROWSER_DOCUMENT_URL, "toolbar-menubar", "autohide", "false");
- });
- }
+ runOncePerModification("displayMenuBar", value, () => {
+ gXulStore.setValue(BROWSER_DOCUMENT_URL, "toolbar-menubar", "autohide", value);
+ });
}
},
"DontCheckDefaultBrowser": {
onBeforeUIStartup(manager, param) {
setAndLockPref("browser.shell.checkDefaultBrowser", false);
}
},
@@ -452,16 +450,17 @@ function addAllowDenyPermissions(permiss
*
* Helper function to run a callback only once per policy.
*
* @param {string} actionName
* A given name which will be used to track if this callback has run.
* @param {Functon} callback
* The callback to run only once.
*/
+ // eslint-disable-next-line no-unused-vars
function runOnce(actionName, callback) {
let prefName = `browser.policies.runonce.${actionName}`;
if (Services.prefs.getBoolPref(prefName, false)) {
log.debug(`Not running action ${actionName} again because it has already run.`);
return;
}
Services.prefs.setBoolPref(prefName, true);
callback();