зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1363291 - Handle save to file when printing pdf in non-e10s. r=brsun
MozReview-Commit-ID: CF9eRC3ZJWU --HG-- extra : rebase_source : cd52051e70d932c239c5c012e16b8ef42ad8f191
This commit is contained in:
Родитель
65821e18d9
Коммит
22a4f20aa8
|
@ -58,8 +58,7 @@ const POINT_PER_INCH = 72;
|
||||||
const POINT_PER_MILLIMETER = POINT_PER_INCH / 25.4;
|
const POINT_PER_MILLIMETER = POINT_PER_INCH / 25.4;
|
||||||
|
|
||||||
const PRINT_FILE_NAME = "print.pdf";
|
const PRINT_FILE_NAME = "print.pdf";
|
||||||
const PRINT_CONTENT_TEMP_KEY =
|
const PRINT_TEMP_KEY = "TmpD";
|
||||||
(Services.appinfo.OS == "Linux") ? "TmpD" : "ContentTmpD";
|
|
||||||
|
|
||||||
const PP_Bool = {
|
const PP_Bool = {
|
||||||
PP_FALSE: 0,
|
PP_FALSE: 0,
|
||||||
|
@ -5011,7 +5010,7 @@ dump(`callFromJSON: < ${JSON.stringify(call)}\n`);
|
||||||
let buffer = PP_Resource.lookup(bufferId);
|
let buffer = PP_Resource.lookup(bufferId);
|
||||||
|
|
||||||
// Save PDF to file
|
// Save PDF to file
|
||||||
let file = Services.dirsvc.get(PRINT_CONTENT_TEMP_KEY, Ci.nsIFile);
|
let file = Services.dirsvc.get(PRINT_TEMP_KEY, Ci.nsIFile);
|
||||||
file.append(PRINT_FILE_NAME);
|
file.append(PRINT_FILE_NAME);
|
||||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, PR_IRUSR | PR_IWUSR);
|
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, PR_IRUSR | PR_IWUSR);
|
||||||
let stream = Cc["@mozilla.org/network/file-output-stream;1"].
|
let stream = Cc["@mozilla.org/network/file-output-stream;1"].
|
||||||
|
@ -5033,7 +5032,7 @@ dump(`callFromJSON: < ${JSON.stringify(call)}\n`);
|
||||||
"PPP_Printing(Dev);0.6", "End", { instance }), true);
|
"PPP_Printing(Dev);0.6", "End", { instance }), true);
|
||||||
// We need permission for printing PDF file
|
// We need permission for printing PDF file
|
||||||
instance.mm.sendAsyncMessage("ppapipdf.js:printPDF", {
|
instance.mm.sendAsyncMessage("ppapipdf.js:printPDF", {
|
||||||
contentTempKey: PRINT_CONTENT_TEMP_KEY, fileName: PRINT_FILE_NAME });
|
filePath: file.path });
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,6 +13,7 @@ const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||||
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
|
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
|
||||||
"resource://gre/modules/NetUtil.jsm");
|
"resource://gre/modules/NetUtil.jsm");
|
||||||
|
@ -157,8 +158,7 @@ mm.addMessageListener("ppapipdf.js:getPrintSettings", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
mm.addMessageListener("ppapipdf.js:printPDF", ({ data }) => {
|
mm.addMessageListener("ppapipdf.js:printPDF", ({ data }) => {
|
||||||
let file = Services.dirsvc.get(data.contentTempKey, Ci.nsIFile);
|
let file = new FileUtils.File(data.filePath);
|
||||||
file.append(data.fileName);
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче