Bug 1551609. Make printUtils.js consistent about internal/external naming. r=mconley
authorJonathan Watt <jwatt@jwatt.org>
Mon, 29 Apr 2019 19:15:48 +0100
changeset 474115 8e07958a53a27c09737a770979a19874bbb38161
parent 474114 4a51777a5592e666753a6b0c84a4900f5cfe1913
child 474116 b1523c5d75ba8b3bd05103c6252f1356e0c238ad
push id36023
push userncsoregi@mozilla.com
push dateThu, 16 May 2019 21:56:43 +0000
treeherdermozilla-central@786f094a30ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1551609
milestone68.0a1
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 1551609. Make printUtils.js consistent about internal/external naming. r=mconley Differential Revision: https://phabricator.services.mozilla.com/D31096
browser/components/extensions/parent/ext-tabs.js
browser/components/extensions/test/browser/browser_ext_tabs_printPreview.js
toolkit/components/printing/content/printUtils.js
--- a/browser/components/extensions/parent/ext-tabs.js
+++ b/browser/components/extensions/parent/ext-tabs.js
@@ -1095,17 +1095,17 @@ this.tabs = class extends ExtensionAPI {
         printPreview() {
           let activeTab = getTabOrActive(null);
           let {
             PrintUtils,
             PrintPreviewListener,
           } = activeTab.ownerGlobal;
 
           return new Promise((resolve, reject) => {
-            let ppBrowser = PrintUtils._shouldSimplify ?
+            let ppBrowser = PrintUtils.shouldSimplify ?
               PrintPreviewListener.getSimplifiedPrintPreviewBrowser() :
               PrintPreviewListener.getPrintPreviewBrowser();
 
             let mm = ppBrowser.messageManager;
 
             let onEntered = (message) => {
               mm.removeMessageListener("Printing:Preview:Entered", onEntered);
               if (message.data.failed) {
--- a/browser/components/extensions/test/browser/browser_ext_tabs_printPreview.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_printPreview.js
@@ -16,17 +16,17 @@ add_task(async function testPrintPreview
       browser.test.notifyPass("tabs.printPreview");
     },
   });
 
   await extension.startup();
   await extension.awaitFinish("tabs.printPreview");
   await extension.unload();
 
-  let ppTab = PrintUtils._shouldSimplify ?
+  let ppTab = PrintUtils.shouldSimplify ?
       PrintPreviewListener._simplifiedPrintPreviewTab :
       PrintPreviewListener._printPreviewTab;
 
   let ppToolbar = document.getElementById("print-preview-toolbar");
 
   is(window.gInPrintPreviewMode, true, "window in print preview mode");
 
   isnot(ppTab, null, "print preview tab created");
--- a/toolkit/components/printing/content/printUtils.js
+++ b/toolkit/components/printing/content/printUtils.js
@@ -66,19 +66,19 @@ var gPrintSettingsAreGlobal = false;
 var gSavePrintSettings = false;
 var gFocusedElement = null;
 
 var PrintUtils = {
   init() {
     window.messageManager.addMessageListener("Printing:Error", this);
   },
 
-  get bundle() {
-    delete this.bundle;
-    return this.bundle = Services.strings.createBundle("chrome://global/locale/printing.properties");
+  get _bundle() {
+    delete this._bundle;
+    return this._bundle = Services.strings.createBundle("chrome://global/locale/printing.properties");
   },
 
   /**
    * Shows the page setup dialog, and saves any settings changed in
    * that dialog if print.save_print_settings is set to true.
    *
    * @return true on success, false on failure
    */
@@ -96,17 +96,17 @@ var PrintUtils = {
       }
     } catch (e) {
       dump("showPageSetup " + e + "\n");
       return false;
     }
     return true;
   },
 
-  getDefaultPrinterName() {
+  _getDefaultPrinterName() {
     try {
       let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"]
                     .getService(Ci.nsIPrintSettingsService);
 
       return PSSVC.defaultPrinterName;
     } catch (e) {
       Cu.reportError(e);
     }
@@ -119,17 +119,17 @@ var PrintUtils = {
    *
    * @param aWindowID
    *        The outer window ID of the nsIDOMWindow to print.
    * @param aBrowser
    *        The <xul:browser> that the nsIDOMWindow for aWindowID belongs to.
    */
   printWindow(aWindowID, aBrowser) {
     let mm = aBrowser.messageManager;
-    let defaultPrinterName = this.getDefaultPrinterName();
+    let defaultPrinterName = this._getDefaultPrinterName();
     mm.sendAsyncMessage("Printing:Print", {
       windowID: aWindowID,
       simplifiedMode: this._shouldSimplify,
       defaultPrinterName,
     });
   },
 
   /**
@@ -239,17 +239,17 @@ var PrintUtils = {
   _listener: null,
   _closeHandlerPP: null,
   _webProgressPP: null,
   _sourceBrowser: null,
   _originalTitle: "",
   _originalURL: "",
   _shouldSimplify: false,
 
-  displayPrintingError(nsresult, isPrinting) {
+  _displayPrintingError(nsresult, isPrinting) {
     // The nsresults from a printing error are mapped to strings that have
     // similar names to the errors themselves. For example, for error
     // NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE, the name of the string
     // for the error message is: PERR_GFX_PRINTER_NO_PRINTER_AVAILABLE. What's
     // more, if we're in the process of doing a print preview, it's possible
     // that there are strings specific for print preview for these errors -
     // if so, the names of those strings have _PP as a suffix. It's possible
     // that no print preview specific strings exist, in which case it is fine
@@ -282,37 +282,37 @@ var PrintUtils = {
     }
 
     let msg, title;
 
     if (!isPrinting) {
       // Try first with _PP suffix.
       let ppMsgName = msgName + "_PP";
       try {
-        msg = this.bundle.GetStringFromName(ppMsgName);
+        msg = this._bundle.GetStringFromName(ppMsgName);
       } catch (e) {
         // We allow localizers to not have the print preview error string,
         // and just fall back to the printing error string.
       }
     }
 
     if (!msg) {
-      msg = this.bundle.GetStringFromName(msgName);
+      msg = this._bundle.GetStringFromName(msgName);
     }
 
-    title = this.bundle.GetStringFromName(isPrinting ? "print_error_dialog_title"
-                                                     : "printpreview_error_dialog_title");
+    title = this._bundle.GetStringFromName(isPrinting ? "print_error_dialog_title"
+                                                      : "printpreview_error_dialog_title");
 
     Services.prompt.alert(window, title, msg);
   },
 
   receiveMessage(aMessage) {
     if (aMessage.name == "Printing:Error") {
-      this.displayPrintingError(aMessage.data.nsresult,
-                                aMessage.data.isPrinting);
+      this._displayPrintingError(aMessage.data.nsresult,
+                                 aMessage.data.isPrinting);
       return undefined;
     }
 
     // If we got here, then the message we've received must involve
     // updating the print progress UI.
     if (!this._webProgressPP.value) {
       // We somehow didn't get a nsIWebProgressListener to be updated...
       // I guess there's nothing to do.
@@ -351,17 +351,17 @@ var PrintUtils = {
         return listener.onStateChange(null, null,
                                       data.stateFlags,
                                       data.status);
       }
     }
     return undefined;
   },
 
-  setPrinterDefaultsForSelectedPrinter(aPSSVC, aPrintSettings) {
+  _setPrinterDefaultsForSelectedPrinter(aPSSVC, aPrintSettings) {
     if (!aPrintSettings.printerName)
       aPrintSettings.printerName = aPSSVC.defaultPrinterName;
 
     // First get any defaults from the printer
     aPSSVC.initPrintSettingsFromPrinter(aPrintSettings.printerName, aPrintSettings);
     // now augment them with any values from last time
     aPSSVC.initPrintSettingsFromPrefs(aPrintSettings, true, aPrintSettings.kInitSaveAll);
   },
@@ -371,17 +371,17 @@ var PrintUtils = {
     gSavePrintSettings = Services.prefs.getBoolPref("print.save_print_settings");
 
     var printSettings;
     try {
       var PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"]
                     .getService(Ci.nsIPrintSettingsService);
       if (gPrintSettingsAreGlobal) {
         printSettings = PSSVC.globalPrintSettings;
-        this.setPrinterDefaultsForSelectedPrinter(PSSVC, printSettings);
+        this._setPrinterDefaultsForSelectedPrinter(PSSVC, printSettings);
       } else {
         printSettings = PSSVC.newPrintSettings;
       }
     } catch (e) {
       dump("getPrintSettings: " + e + "\n");
     }
     return printSettings;
   },
@@ -398,16 +398,20 @@ var PrintUtils = {
       // delay the print preview to show the content of the progress dialog
       setTimeout(function() { PrintUtils.enterPrintPreview(); }, 0);
     },
 
     QueryInterface: ChromeUtils.generateQI(["nsIObserver",
                                             "nsISupportsWeakReference"]),
   },
 
+  get shouldSimplify() {
+    return this._shouldSimplify;
+  },
+
   setSimplifiedMode(shouldSimplify) {
     this._shouldSimplify = shouldSimplify;
   },
 
   /**
   * Currently, we create a new print preview browser to host the simplified
   * cloned-document when Simplify Page option is used on preview. To accomplish
   * this, we need to keep track of what browser should be presented, based on
@@ -438,17 +442,17 @@ var PrintUtils = {
     let oldPPBrowser = null;
     let changingPrintPreviewBrowsers = false;
     if (this._currentPPBrowser && ppBrowser != this._currentPPBrowser) {
       changingPrintPreviewBrowsers = true;
       oldPPBrowser = this._currentPPBrowser;
     }
     this._currentPPBrowser = ppBrowser;
     let mm = ppBrowser.messageManager;
-    let defaultPrinterName = this.getDefaultPrinterName();
+    let defaultPrinterName = this._getDefaultPrinterName();
 
     let sendEnterPreviewMessage = function(browser, simplified) {
       mm.sendAsyncMessage("Printing:Preview:Enter", {
         windowID: browser.outerWindowID,
         simplifiedMode: simplified,
         changingBrowsers: changingPrintPreviewBrowsers,
         defaultPrinterName,
       });