Bug 1088070 - Instantiate print settings from the content process instead of the parent. r=Mossop.

This commit is contained in:
Mike Conley
2015-02-06 14:17:43 -05:00
parent 02a5669793
commit b4f1082842
2 changed files with 23 additions and 20 deletions

View File

@@ -383,7 +383,7 @@ let Printing = {
let data = message.data;
switch(message.name) {
case "Printing:Preview:Enter": {
this.enterPrintPreview(objects.printSettings, objects.contentWindow);
this.enterPrintPreview(objects.contentWindow);
break;
}
@@ -403,19 +403,31 @@ let Printing = {
}
case "Printing:Print": {
this.print(objects.printSettings, objects.contentWindow);
this.print(objects.contentWindow);
break;
}
}
},
enterPrintPreview(printSettings, contentWindow) {
// Bug 1088070 - we should instantiate nsIPrintSettings here in the
// content script instead of passing it down as a CPOW.
if (Cu.isCrossProcessWrapper(printSettings)) {
printSettings = null;
}
getPrintSettings() {
let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"]
.getService(Ci.nsIPrintSettingsService);
let printSettings = PSSVC.globalPrintSettings;
if (!printSettings.printerName) {
printSettings.printerName = PSSVC.defaultPrinterName;
}
// First get any defaults from the printer
PSSVC.initPrintSettingsFromPrinter(printSettings.printerName,
printSettings);
// now augment them with any values from last time
PSSVC.initPrintSettingsFromPrefs(printSettings, true,
printSettings.kInitSaveAll);
return printSettings;
},
enterPrintPreview(contentWindow) {
// 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).
@@ -438,6 +450,7 @@ let Printing = {
addEventListener("printPreviewUpdate", onPrintPreviewReady);
try {
let printSettings = this.getPrintSettings();
docShell.printPreview.printPreview(printSettings, contentWindow, this);
} catch(error) {
// This might fail if we, for example, attempt to print a XUL document.
@@ -451,13 +464,8 @@ let Printing = {
docShell.printPreview.exitPrintPreview();
},
print(printSettings, contentWindow) {
// Bug 1088070 - we should instantiate nsIPrintSettings here in the
// content script instead of passing it down as a CPOW.
if (Cu.isCrossProcessWrapper(printSettings)) {
printSettings = null;
}
print(contentWindow) {
let printSettings = this.getPrintSettings();
let rv = Cr.NS_OK;
try {
let print = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)