fix: silent printing of PDFs with webContents.print
(#47645)
fix: silent printing of PDFs with webContents.print 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:
parent
f468c9a896
commit
a5d68cebd3
1 changed files with 10 additions and 4 deletions
|
@ -666,7 +666,7 @@ index 6809c4576c71bc1e1a6ad4e0a37707272a9a10f4..3aad10424a6a31dab2ca393d00149ec6
|
|||
PrintingFailed(int32 cookie, PrintFailureReason reason);
|
||||
|
||||
diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc
|
||||
index 08af2c8458fdc2539b437c3ff7e3fa2b5d36eeda..5a8d2f3cc57a66535afb027ee43eebc3b3ffe41c 100644
|
||||
index 08af2c8458fdc2539b437c3ff7e3fa2b5d36eeda..bac316baaf4340848666085b3de69c99ee522abe 100644
|
||||
--- a/components/printing/renderer/print_render_frame_helper.cc
|
||||
+++ b/components/printing/renderer/print_render_frame_helper.cc
|
||||
@@ -52,6 +52,7 @@
|
||||
|
@ -744,7 +744,7 @@ index 08af2c8458fdc2539b437c3ff7e3fa2b5d36eeda..5a8d2f3cc57a66535afb027ee43eebc3
|
|||
print_preview_context_.OnPrintPreview();
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
@@ -2062,17 +2068,19 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
||||
@@ -2062,17 +2068,25 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
||||
|
||||
void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
const blink::WebNode& node,
|
||||
|
@ -759,6 +759,12 @@ index 08af2c8458fdc2539b437c3ff7e3fa2b5d36eeda..5a8d2f3cc57a66535afb027ee43eebc3
|
|||
FrameReference frame_ref(frame);
|
||||
|
||||
- if (!InitPrintSettings(frame, node)) {
|
||||
+ // If we're silently printing a PDF, we bypass settings logic
|
||||
+ // that sets modifiability to false so ensure it's set here.
|
||||
+ if (silent && IsPrintingPdfFrame(frame, node)) {
|
||||
+ settings.Set(kSettingPreviewModifiable, false);
|
||||
+ }
|
||||
+
|
||||
+ if (!InitPrintSettings(frame, node, std::move(settings))) {
|
||||
// Browser triggered this code path. It already knows about the failure.
|
||||
notify_browser_of_print_failure_ = false;
|
||||
|
@ -767,7 +773,7 @@ index 08af2c8458fdc2539b437c3ff7e3fa2b5d36eeda..5a8d2f3cc57a66535afb027ee43eebc3
|
|||
DidFinishPrinting(PrintingResult::kFailPrintInit);
|
||||
return;
|
||||
}
|
||||
@@ -2093,8 +2101,15 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
@@ -2093,8 +2107,15 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
print_pages_params_->params->print_scaling_option;
|
||||
|
||||
auto self = weak_ptr_factory_.GetWeakPtr();
|
||||
|
@ -784,7 +790,7 @@ index 08af2c8458fdc2539b437c3ff7e3fa2b5d36eeda..5a8d2f3cc57a66535afb027ee43eebc3
|
|||
// Check if `this` is still valid.
|
||||
if (!self)
|
||||
return;
|
||||
@@ -2362,29 +2377,43 @@ void PrintRenderFrameHelper::IPCProcessed() {
|
||||
@@ -2362,29 +2383,43 @@ void PrintRenderFrameHelper::IPCProcessed() {
|
||||
}
|
||||
|
||||
bool PrintRenderFrameHelper::InitPrintSettings(blink::WebLocalFrame* frame,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue