chore: remove deprecated webContents.getPrinters() (#39663)

This commit is contained in:
David Sanders 2023-09-05 01:16:41 -07:00 committed by GitHub
parent d76a35afe4
commit c96bb9958f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 51 deletions

View file

@ -41,25 +41,6 @@ struct Converter<printing::PrinterBasicInfo> {
namespace electron::api {
#if BUILDFLAG(ENABLE_PRINTING)
printing::PrinterList GetPrinterList(v8::Isolate* isolate) {
EmitWarning(node::Environment::GetCurrent(isolate),
"Deprecation Warning: getPrinters() is deprecated. "
"Use the asynchronous and non-blocking version, "
"getPrintersAsync(), instead.",
"electron");
printing::PrinterList printers;
auto print_backend = printing::PrintBackend::CreateInstance(
g_browser_process->GetApplicationLocale());
{
ScopedAllowBlockingForElectron allow_blocking;
printing::mojom::ResultCode code =
print_backend->EnumeratePrinters(printers);
if (code != printing::mojom::ResultCode::kSuccess)
LOG(INFO) << "Failed to enumerate printers";
}
return printers;
}
v8::Local<v8::Promise> GetPrinterListAsync(v8::Isolate* isolate) {
gin_helper::Promise<printing::PrinterList> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
@ -92,7 +73,6 @@ v8::Local<v8::Promise> GetPrinterListAsync(v8::Isolate* isolate) {
namespace {
#if BUILDFLAG(ENABLE_PRINTING)
using electron::api::GetPrinterList;
using electron::api::GetPrinterListAsync;
#endif
@ -103,7 +83,6 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate();
gin_helper::Dictionary dict(isolate, exports);
#if BUILDFLAG(ENABLE_PRINTING)
dict.SetMethod("getPrinterList", base::BindRepeating(&GetPrinterList));
dict.SetMethod("getPrinterListAsync",
base::BindRepeating(&GetPrinterListAsync));
#endif