refactor: use default printing path when no user options (#46616)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2025-04-11 16:15:38 -04:00 committed by GitHub
parent f66c385080
commit 23035a587e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 14 deletions

View file

@ -3035,9 +3035,8 @@ void OnGetDeviceNameToUse(base::WeakPtr<content::WebContents> web_contents,
return;
}
// If the user has passed a deviceName use it, otherwise use default printer.
// Use user-passed deviceName, otherwise default printer.
print_settings.Set(printing::kSettingDeviceName, info.second);
if (!print_settings.FindInt(printing::kSettingDpiHorizontal)) {
gfx::Size dpi = GetDefaultPrinterDPI(info.second);
print_settings.Set(printing::kSettingDpiHorizontal, dpi.width());
@ -3096,6 +3095,17 @@ void WebContents::Print(gin::Arguments* args) {
return;
}
if (options.IsEmptyObject()) {
auto* print_view_manager =
PrintViewManagerElectron::FromWebContents(web_contents());
if (!print_view_manager)
return;
content::RenderFrameHost* rfh = GetRenderFrameHostToUse(web_contents());
print_view_manager->PrintNow(rfh, std::move(settings), std::move(callback));
return;
}
// Set optional silent printing.
bool silent = false;
options.Get("silent", &silent);