fix: check WebContents in OnGetDefaultPrinter (#22041)

This commit is contained in:
Cheng Zhao 2020-02-06 00:48:51 +09:00 committed by GitHub
parent 76d05ce21f
commit dee324f79a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);