refactor: move GetPrinterList off WebContents (#26518)

This commit is contained in:
Jeremy Rose 2020-11-17 14:14:09 -08:00 committed by GitHub
parent dbe0f06c3d
commit a303813d15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 89 additions and 37 deletions

View file

@ -123,6 +123,7 @@ const defaultPrintingSetting = {
// JavaScript implementations of WebContents.
const binding = process._linkedBinding('electron_browser_web_contents');
const printing = process._linkedBinding('electron_browser_printing');
const { WebContents } = binding as { WebContents: { prototype: Electron.WebContents } };
WebContents.prototype.send = function (channel, ...args) {
@ -416,8 +417,10 @@ WebContents.prototype.print = function (options = {}, callback) {
};
WebContents.prototype.getPrinters = function () {
if (this._getPrinters) {
return this._getPrinters();
// TODO(nornagon): this API has nothing to do with WebContents and should be
// moved.
if (printing.getPrinterList) {
return printing.getPrinterList();
} else {
console.error('Error: Printing feature is disabled.');
return [];