refactor: printing implementation (#15143)

* refactor: basic printing

* move build files to chromium_src/BUILD.gn
* remove dependency on chrome prerender sources

* spec: move printing specs behind feature flag

* build: register pdf compositor service
This commit is contained in:
Robo 2018-11-09 09:12:34 +05:30 committed by Samuel Attard
parent 53642b2b17
commit 82322968a3
23 changed files with 780 additions and 1073 deletions

View file

@ -1,5 +1,6 @@
'use strict'
const features = process.atomBinding('features')
const { EventEmitter } = require('events')
const electron = require('electron')
const path = require('path')
@ -70,6 +71,7 @@ const defaultPrintingSetting = {
marginsType: 0,
isFirstRequest: false,
requestID: getNextId(),
previewUIID: 0,
previewModifiable: true,
printToPDF: true,
printWithCloudPrint: false,
@ -251,7 +253,27 @@ WebContents.prototype.printToPDF = function (options, callback) {
// Chromium expects this in a 0-100 range number, not as float
printingSetting.scaleFactor *= 100
this._printToPDF(printingSetting, callback)
if (features.isPrintingEnabled()) {
this._printToPDF(printingSetting, callback)
} else {
console.error('Error: Printing feature is disabled.')
}
}
WebContents.prototype.print = function (...args) {
if (features.isPrintingEnabled()) {
this._print(args)
} else {
console.error('Error: Printing feature is disabled.')
}
}
WebContents.prototype.getPrinters = function () {
if (features.isPrintingEnabled()) {
return this._getPrinters()
} else {
console.error('Error: Printing feature is disabled.')
}
}
WebContents.prototype.getZoomLevel = function (callback) {