Bug 1854298 - Implement PrintingEnabled policy r=emilio,mkaply,Gijs,fluent-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D188792
This commit is contained in:
Gregory Pappas
2023-10-03 21:48:34 +00:00
parent 63f21964ab
commit 7fd84857a4
8 changed files with 93 additions and 0 deletions

View File

@@ -586,6 +586,16 @@ XPCOMUtils.defineLazyPreferenceGetter(
}
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"gPrintEnabled",
"print.enabled",
false,
(aPref, aOldVal, aNewVal) => {
updatePrintCommands(aNewVal);
}
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"gScreenshotsComponentEnabled",
@@ -847,6 +857,19 @@ function UpdateBackForwardCommands(aWebNavigation) {
}
}
function updatePrintCommands(enabled) {
var printCommand = document.getElementById("cmd_print");
var printPreviewCommand = document.getElementById("cmd_printPreviewToggle");
if (enabled) {
printCommand.removeAttribute("disabled");
printPreviewCommand.removeAttribute("disabled");
} else {
printCommand.setAttribute("disabled", "true");
printPreviewCommand.setAttribute("disabled", "true");
}
}
/**
* Click-and-Hold implementation for the Back and Forward buttons
* XXXmano: should this live in toolbarbutton.js?
@@ -1643,6 +1666,8 @@ var gBrowserInit = {
updateFxaToolbarMenu(gFxaToolbarEnabled, true);
updatePrintCommands(gPrintEnabled);
gUnifiedExtensions.init();
// Setting the focus will cause a style flush, it's preferable to call anything