refactor: use default printing path when no user options (#46587)
This commit is contained in:
parent
74d641c7b3
commit
3064b24c9d
3 changed files with 34 additions and 14 deletions
|
@ -2944,9 +2944,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());
|
||||
|
@ -3005,6 +3004,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue