зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1329216 - Pass default printer name to child. r=mconley
This commit is contained in:
Родитель
da565844f3
Коммит
94cad21ec7
|
@ -100,6 +100,19 @@ var PrintUtils = {
|
|||
return true;
|
||||
},
|
||||
|
||||
getDefaultPrinterName() {
|
||||
try {
|
||||
let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"]
|
||||
.getService(Ci.nsIPrintSettingsService);
|
||||
|
||||
return PSSVC.defaultPrinterName;
|
||||
} catch (e) {
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Starts the process of printing the contents of a window.
|
||||
*
|
||||
|
@ -110,9 +123,11 @@ var PrintUtils = {
|
|||
*/
|
||||
printWindow(aWindowID, aBrowser) {
|
||||
let mm = aBrowser.messageManager;
|
||||
let defaultPrinterName = this.getDefaultPrinterName();
|
||||
mm.sendAsyncMessage("Printing:Print", {
|
||||
windowID: aWindowID,
|
||||
simplifiedMode: this._shouldSimplify,
|
||||
defaultPrinterName,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -491,11 +506,13 @@ var PrintUtils = {
|
|||
// listener.
|
||||
let ppBrowser = this._listener.getPrintPreviewBrowser();
|
||||
let mm = ppBrowser.messageManager;
|
||||
let defaultPrinterName = this.getDefaultPrinterName();
|
||||
|
||||
let sendEnterPreviewMessage = function(browser, simplified) {
|
||||
mm.sendAsyncMessage("Printing:Preview:Enter", {
|
||||
windowID: browser.outerWindowID,
|
||||
simplifiedMode: simplified,
|
||||
defaultPrinterName,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -443,7 +443,7 @@ var Printing = {
|
|||
let data = message.data;
|
||||
switch (message.name) {
|
||||
case "Printing:Preview:Enter": {
|
||||
this.enterPrintPreview(Services.wm.getOuterWindowWithId(data.windowID), data.simplifiedMode);
|
||||
this.enterPrintPreview(Services.wm.getOuterWindowWithId(data.windowID), data.simplifiedMode, data.defaultPrinterName);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -468,20 +468,20 @@ var Printing = {
|
|||
}
|
||||
|
||||
case "Printing:Print": {
|
||||
this.print(Services.wm.getOuterWindowWithId(data.windowID), data.simplifiedMode);
|
||||
this.print(Services.wm.getOuterWindowWithId(data.windowID), data.simplifiedMode, data.defaultPrinterName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getPrintSettings() {
|
||||
getPrintSettings(defaultPrinterName) {
|
||||
try {
|
||||
let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"]
|
||||
.getService(Ci.nsIPrintSettingsService);
|
||||
|
||||
let printSettings = PSSVC.globalPrintSettings;
|
||||
if (!printSettings.printerName) {
|
||||
printSettings.printerName = PSSVC.defaultPrinterName;
|
||||
printSettings.printerName = defaultPrinterName;
|
||||
}
|
||||
// First get any defaults from the printer
|
||||
PSSVC.initPrintSettingsFromPrinter(printSettings.printerName,
|
||||
|
@ -620,7 +620,7 @@ var Printing = {
|
|||
});
|
||||
},
|
||||
|
||||
enterPrintPreview(contentWindow, simplifiedMode) {
|
||||
enterPrintPreview(contentWindow, simplifiedMode, defaultPrinterName) {
|
||||
// We'll call this whenever we've finished reflowing the document, or if
|
||||
// we errored out while attempting to print preview (in which case, we'll
|
||||
// notify the parent that we've failed).
|
||||
|
@ -643,7 +643,7 @@ var Printing = {
|
|||
addEventListener("printPreviewUpdate", onPrintPreviewReady);
|
||||
|
||||
try {
|
||||
let printSettings = this.getPrintSettings();
|
||||
let printSettings = this.getPrintSettings(defaultPrinterName);
|
||||
|
||||
// If we happen to be on simplified mode, we need to set docURL in order
|
||||
// to generate header/footer content correctly, since simplified tab has
|
||||
|
@ -664,8 +664,8 @@ var Printing = {
|
|||
docShell.printPreview.exitPrintPreview();
|
||||
},
|
||||
|
||||
print(contentWindow, simplifiedMode) {
|
||||
let printSettings = this.getPrintSettings();
|
||||
print(contentWindow, simplifiedMode, defaultPrinterName) {
|
||||
let printSettings = this.getPrintSettings(defaultPrinterName);
|
||||
|
||||
// If we happen to be on simplified mode, we need to set docURL in order
|
||||
// to generate header/footer content correctly, since simplified tab has
|
||||
|
|
Загрузка…
Ссылка в новой задаче