mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: check WebContents in OnGetDefaultPrinter (#22041)
This commit is contained in:
@@ -1745,6 +1745,14 @@ void WebContents::OnGetDefaultPrinter(
|
||||
base::string16 device_name,
|
||||
bool silent,
|
||||
base::string16 default_printer) {
|
||||
// The content::WebContents might be already deleted at this point, and the
|
||||
// PrintViewManagerBasic class does not do null check.
|
||||
if (!web_contents()) {
|
||||
if (print_callback)
|
||||
std::move(print_callback).Run(false, "failed");
|
||||
return;
|
||||
}
|
||||
|
||||
base::string16 printer_name =
|
||||
device_name.empty() ? default_printer : device_name;
|
||||
print_settings.SetStringKey(printing::kSettingDeviceName, printer_name);
|
||||
|
||||
Reference in New Issue
Block a user