fix: bail early if no printers on the network (#22418)
This commit is contained in:
parent
efc11563e8
commit
e8c628ecdf
2 changed files with 9 additions and 1 deletions
|
@ -1286,7 +1286,7 @@ Returns [`PrinterInfo[]`](structures/printer-info.md)
|
||||||
`A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height`.
|
`A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height`.
|
||||||
* `callback` Function (optional)
|
* `callback` Function (optional)
|
||||||
* `success` Boolean - Indicates success of the print call.
|
* `success` Boolean - Indicates success of the print call.
|
||||||
* `failureReason` String - Called back if the print fails; can be `cancelled` or `failed`.
|
* `failureReason` String - Error description called back if the print fails.
|
||||||
|
|
||||||
Prints window's web page. When `silent` is set to `true`, Electron will pick
|
Prints window's web page. When `silent` is set to `true`, Electron will pick
|
||||||
the system's default printer if `deviceName` is empty and the default settings for printing.
|
the system's default printer if `deviceName` is empty and the default settings for printing.
|
||||||
|
|
|
@ -1766,6 +1766,14 @@ void WebContents::OnGetDefaultPrinter(
|
||||||
|
|
||||||
base::string16 printer_name =
|
base::string16 printer_name =
|
||||||
device_name.empty() ? default_printer : device_name;
|
device_name.empty() ? default_printer : device_name;
|
||||||
|
|
||||||
|
// If there are no valid printers available on the network, we bail.
|
||||||
|
if (printer_name.empty() || !IsDeviceNameValid(printer_name)) {
|
||||||
|
if (print_callback)
|
||||||
|
std::move(print_callback).Run(false, "no valid printers available");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
print_settings.SetStringKey(printing::kSettingDeviceName, printer_name);
|
print_settings.SetStringKey(printing::kSettingDeviceName, printer_name);
|
||||||
|
|
||||||
auto* print_view_manager =
|
auto* print_view_manager =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue