fix: check WebContents in OnGetDefaultPrinter (#22475)

Co-authored-by: Cheng Zhao <zcbenz@electronjs.org>
This commit is contained in:
trop[bot]
2020-03-03 15:05:21 +09:00
committed by GitHub
parent 6e4690574d
commit ae639186e3

View File

@@ -1737,6 +1737,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);