build: allow use of BUILDFLAG directives from within JS code (#20328)

This commit is contained in:
Milan Burda 2020-05-11 01:06:07 +02:00 committed by GitHub
parent f9c04449f4
commit 392ea320cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 132 additions and 74 deletions

View file

@ -1,6 +1,5 @@
'use strict';
const features = process.electronBinding('features');
const { EventEmitter } = require('events');
const electron = require('electron');
const path = require('path');
@ -341,7 +340,7 @@ WebContents.prototype.printToPDF = function (options) {
printSettings.scaleFactor = Math.ceil(printSettings.scaleFactor) % 100;
// PrinterType enum from //printing/print_job_constants.h
printSettings.printerType = 2;
if (features.isPrintingEnabled()) {
if (this._printToPDF) {
return this._printToPDF(printSettings);
} else {
const error = new Error('Printing feature is disabled');
@ -375,7 +374,7 @@ WebContents.prototype.print = function (options = {}, callback) {
}
}
if (features.isPrintingEnabled()) {
if (this._print) {
if (callback) {
this._print(options, callback);
} else {
@ -387,7 +386,7 @@ WebContents.prototype.print = function (options = {}, callback) {
};
WebContents.prototype.getPrinters = function () {
if (features.isPrintingEnabled()) {
if (this._getPrinters) {
return this._getPrinters();
} else {
console.error('Error: Printing feature is disabled.');