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

--HG--
extra : rebase_source : 1a70d9c3ed29d6587fbebd04b4daedc387254aaa
This commit is contained in:
Mike Conley 2015-02-06 14:17:43 -05:00
parent 1703a43dcf
commit a16ed32af3
2 changed files with 23 additions and 20 deletions

View File

@ -166,8 +166,6 @@ var PrintUtils = {
"to a browser.");
}
let printSettings = this.getPrintSettings();
let mm = aBrowser.messageManager;
mm.addMessageListener("Printing:Print:Done", function onPrintingDone(msg) {
@ -193,7 +191,6 @@ var PrintUtils = {
});
mm.sendAsyncMessage("Printing:Print", null, {
printSettings: printSettings,
contentWindow: aWindow,
});
},
@ -461,9 +458,7 @@ var PrintUtils = {
// listener.
let ppBrowser = this._listener.getPrintPreviewBrowser();
let mm = ppBrowser.messageManager;
let printSettings = this.getPrintSettings();
mm.sendAsyncMessage("Printing:Preview:Enter", null, {
printSettings: printSettings,
contentWindow: this._sourceBrowser.contentWindowAsCPOW,
});

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)