Bug 1471854 - Make print.always_print_silent a static pref. r=jwatt
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 10 Jun 2020 13:41:17 +0000
changeset 598941 28d20aef861dcee68ebe0a7497b4574b176c1d42
parent 598940 09465d16c95d81035203219d041cee56c94c2dfe
child 598942 3a6ed2262ba4a316645d1b9450f1fa7631faba19
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1471854 - Make print.always_print_silent a static pref. r=jwatt So that it shows up in about:config (and also it's faster that way). Differential Revision: https://phabricator.services.mozilla.com/D79117
--- a/layout/printing/nsPrintJob.cpp
+++ b/layout/printing/nsPrintJob.cpp
@@ -12,16 +12,17 @@
 #include "nsQueryObject.h"
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/ComputedStyleInlines.h"
 #include "mozilla/dom/BrowsingContext.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/dom/CustomEvent.h"
 #include "mozilla/dom/ScriptSettings.h"
+#include "mozilla/StaticPrefs_print.h"
 #include "mozilla/Telemetry.h"
 #include "nsIBrowserChild.h"
 #include "nsIOService.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIStringBundle.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDocShell.h"
 #include "nsIURI.h"
@@ -715,22 +716,21 @@ nsresult nsPrintJob::DoCommonPrint(bool 
   nsScriptSuppressor scriptSuppressor(this);
   // If printing via parent we still call ShowPrintDialog even for print preview
   // because we use that to retrieve the print settings from the printer.
   // The dialog is not shown, but this means we don't need to access the printer
   // driver from the child, which causes sandboxing issues.
   if (!aIsPrintPreview || printingViaParent) {
-    bool printSilently;
+    bool printSilently = false;
-    // Check prefs for a default setting as to whether we should print silently
-    printSilently =
-        Preferences::GetBool("print.always_print_silent", printSilently);
+    if (StaticPrefs::print_always_print_silent()) {
+      printSilently = true;
+    }
     // Ask dialog to be Print Shown via the Plugable Printing Dialog Service
     // This service is for the Print Dialog and the Print Progress Dialog
     // If printing silently or you can't get the service continue on
     // If printing via the parent then we need to confirm that the pref is set
     // and get a remote print job, but the parent won't display a prompt.
     if (!printSilently || printingViaParent) {
       nsCOMPtr<nsIPrintingPromptService> printPromptService(
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -8251,16 +8251,22 @@
 # Variation fonts can't always be embedded in certain output formats
 # such as PDF. To work around this, draw the variation fonts using
 # paths instead of using font embedding.
 - name: print.font-variations-as-paths
   type: RelaxedAtomicBool
   value: true
   mirror: always
+# Whether we always print silently (without a print dialog).
+- name: print.always_print_silent
+  type: RelaxedAtomicBool
+  value: false
+  mirror: always
 # Prefs starting with "privacy."
 - name: privacy.file_unique_origin
   type: bool
   value: true
   mirror: always
--- a/toolkit/components/printingui/ipc/PrintingParent.cpp
+++ b/toolkit/components/printingui/ipc/PrintingParent.cpp
@@ -13,16 +13,17 @@
 #include "nsIPrintingPromptService.h"
 #include "nsIPrintSettingsService.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIWebProgressListener.h"
 #include "PrintingParent.h"
 #include "PrintProgressDialogParent.h"
 #include "PrintSettingsDialogParent.h"
 #include "mozilla/layout/RemotePrintJobParent.h"
+#include "mozilla/StaticPrefs_print.h"
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::layout;
 namespace mozilla {
 namespace embedding {
 mozilla::ipc::IPCResult PrintingParent::RecvShowProgress(
@@ -137,17 +138,17 @@ nsresult PrintingParent::ShowPrintDialog
   mPrintSettingsSvc->InitPrintSettingsFromPrinter(printerName, settings);
   // If this is for print preview or we are printing silently then we just need
   // to initialize the print settings with anything specific from the printer.
   if (isPrintPreview || printSilently ||
-      Preferences::GetBool("print.always_print_silent", printSilently)) {
+      StaticPrefs::print_always_print_silent()) {
     mPrintSettingsSvc->InitPrintSettingsFromPrinter(printerName, settings);
   } else {
     rv = pps->ShowPrintDialog(parentWin, settings);
     NS_ENSURE_SUCCESS(rv, rv);
   if (isPrintPreview) {