fix: bail early if no printers on the network (#22418)

This commit is contained in:
Shelley Vohr 2020-03-04 02:20:31 +00:00 committed by GitHub
parent efc11563e8
commit e8c628ecdf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -1766,6 +1766,14 @@ void WebContents::OnGetDefaultPrinter(
base::string16 printer_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);
auto* print_view_manager =