From 4eb0d497abf4792ad6c1f61978196ba00c409250 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Fri, 9 Nov 2018 12:46:43 +0530 Subject: [PATCH] chore: update printing.patch --- .../printing/print_preview_message_handler.cc | 9 +- .../printing/print_preview_message_handler.h | 3 +- patches/common/chromium/printing.patch | 100 ++++++++---------- 3 files changed, 45 insertions(+), 67 deletions(-) diff --git a/atom/browser/printing/print_preview_message_handler.cc b/atom/browser/printing/print_preview_message_handler.cc index 0c4b74ce3f97..4e3b0f4bc28f 100644 --- a/atom/browser/printing/print_preview_message_handler.cc +++ b/atom/browser/printing/print_preview_message_handler.cc @@ -26,8 +26,6 @@ using content::BrowserThread; -DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::PrintPreviewMessageHandler); - namespace atom { namespace { @@ -110,11 +108,9 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting( printing::PrintCompositeClient::FromWebContents(web_contents()); DCHECK(client); client->DoCompositeDocumentToPdf( - params.document_cookie, render_frame_host, content.metafile_data_handle, - content.data_size, content.subframe_content_info, + params.document_cookie, render_frame_host, content, base::BindOnce(&PrintPreviewMessageHandler::OnCompositePdfDocumentDone, - weak_ptr_factory_.GetWeakPtr(), - params.expected_pages_count, ids)); + weak_ptr_factory_.GetWeakPtr(), ids)); } else { RunPrintToPDFCallback( ids.request_id, @@ -123,7 +119,6 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting( } void PrintPreviewMessageHandler::OnCompositePdfDocumentDone( - int page_number, const PrintHostMsg_PreviewIds& ids, printing::mojom::PdfCompositor::Status status, base::ReadOnlySharedMemoryRegion region) { diff --git a/atom/browser/printing/print_preview_message_handler.h b/atom/browser/printing/print_preview_message_handler.h index 9470e9ea45fe..e1ba67784349 100644 --- a/atom/browser/printing/print_preview_message_handler.h +++ b/atom/browser/printing/print_preview_message_handler.h @@ -50,8 +50,7 @@ class PrintPreviewMessageHandler content::RenderFrameHost* render_frame_host, const PrintHostMsg_DidPreviewDocument_Params& params, const PrintHostMsg_PreviewIds& ids); - void OnCompositePdfDocumentDone(int page_number, - const PrintHostMsg_PreviewIds& ids, + void OnCompositePdfDocumentDone(const PrintHostMsg_PreviewIds& ids, printing::mojom::PdfCompositor::Status status, base::ReadOnlySharedMemoryRegion region); void OnPrintPreviewFailed(int document_cookie, diff --git a/patches/common/chromium/printing.patch b/patches/common/chromium/printing.patch index bb3df94d29a7..964fdfda16a3 100644 --- a/patches/common/chromium/printing.patch +++ b/patches/common/chromium/printing.patch @@ -22,7 +22,7 @@ index 1065e808e621c087bde9320abe019f05292f977c..6cf33877d21a6bf06532f7f9d79804c7 #include "content/public/browser/notification_service.h" #include "content/public/browser/render_frame_host.h" diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc -index 9b0c15b3c5016707788476295d53ab9d8a80e338..8b6580220fb0645a2335d625df8f0ceb211db88c 100644 +index 169bfefa0e442ddc0aa51ac4e98b48fc24d8a805..12cede4509e88c12daf3a53ae40204f945b9172f 100644 --- a/chrome/browser/printing/print_view_manager_base.cc +++ b/chrome/browser/printing/print_view_manager_base.cc @@ -27,10 +27,7 @@ @@ -43,7 +43,7 @@ index 9b0c15b3c5016707788476295d53ab9d8a80e338..8b6580220fb0645a2335d625df8f0ceb +#include "electron/grit/electron_resources.h" #include "mojo/public/cpp/system/buffer.h" #include "printing/buildflags/buildflags.h" - #include "printing/pdf_metafile_skia.h" + #include "printing/metafile_skia.h" @@ -67,6 +65,8 @@ using PrintSettingsCallback = base::OnceCallback)>; @@ -61,7 +61,7 @@ index 9b0c15b3c5016707788476295d53ab9d8a80e338..8b6580220fb0645a2335d625df8f0ceb } #if BUILDFLAG(ENABLE_PRINT_PREVIEW) -@@ -112,12 +113,14 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents) +@@ -111,12 +112,14 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents) queue_(g_browser_process->print_job_manager()->queue()), weak_ptr_factory_(this) { DCHECK(queue_); @@ -76,7 +76,7 @@ index 9b0c15b3c5016707788476295d53ab9d8a80e338..8b6580220fb0645a2335d625df8f0ceb } PrintViewManagerBase::~PrintViewManagerBase() { -@@ -125,12 +128,14 @@ PrintViewManagerBase::~PrintViewManagerBase() { +@@ -124,12 +127,14 @@ PrintViewManagerBase::~PrintViewManagerBase() { DisconnectFromCurrentPrintJob(); } @@ -94,7 +94,7 @@ index 9b0c15b3c5016707788476295d53ab9d8a80e338..8b6580220fb0645a2335d625df8f0ceb } #if BUILDFLAG(ENABLE_PRINT_PREVIEW) -@@ -247,9 +252,9 @@ void PrintViewManagerBase::StartLocalPrintJob( +@@ -245,9 +250,9 @@ void PrintViewManagerBase::StartLocalPrintJob( void PrintViewManagerBase::UpdatePrintingEnabled() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // The Unretained() is safe because ForEachFrame() is synchronous. @@ -107,16 +107,7 @@ index 9b0c15b3c5016707788476295d53ab9d8a80e338..8b6580220fb0645a2335d625df8f0ceb } void PrintViewManagerBase::NavigationStopped() { -@@ -316,7 +321,7 @@ void PrintViewManagerBase::OnDidPrintDocument( - } - - auto* client = PrintCompositeClient::FromWebContents(web_contents()); -- if (IsOopifEnabled() && !PrintingPdfContent(render_frame_host)) { -+ if (IsOopifEnabled()) { - client->DoCompositeDocumentToPdf( - params.document_cookie, render_frame_host, content.metafile_data_handle, - content.data_size, content.subframe_content_info, -@@ -342,7 +347,7 @@ void PrintViewManagerBase::OnPrintingFailed(int cookie) { +@@ -339,7 +344,7 @@ void PrintViewManagerBase::OnPrintingFailed(int cookie) { PrintManager::OnPrintingFailed(cookie); #if BUILDFLAG(ENABLE_PRINT_PREVIEW) @@ -125,7 +116,7 @@ index 9b0c15b3c5016707788476295d53ab9d8a80e338..8b6580220fb0645a2335d625df8f0ceb #endif ReleasePrinterQuery(); -@@ -592,6 +597,9 @@ void PrintViewManagerBase::ReleasePrintJob() { +@@ -587,6 +592,9 @@ void PrintViewManagerBase::ReleasePrintJob() { content::RenderFrameHost* rfh = printing_rfh_; printing_rfh_ = nullptr; @@ -136,10 +127,10 @@ index 9b0c15b3c5016707788476295d53ab9d8a80e338..8b6580220fb0645a2335d625df8f0ceb return; diff --git a/chrome/browser/printing/print_view_manager_base.h b/chrome/browser/printing/print_view_manager_base.h -index fe0e0b5b065cdcc4edd04665271db14b1bf935e3..be2b3ceb0bd582d499372374349bdd685a1994b6 100644 +index 542d061efc80b536867ff51cb5f211d15a6ea199..be27c20f2fe8d1e666e9a35b3835a62b8234a2c5 100644 --- a/chrome/browser/printing/print_view_manager_base.h +++ b/chrome/browser/printing/print_view_manager_base.h -@@ -38,6 +38,8 @@ class PrintJob; +@@ -39,6 +39,8 @@ class PrintJob; class PrintQueriesQueue; class PrinterQuery; @@ -148,7 +139,7 @@ index fe0e0b5b065cdcc4edd04665271db14b1bf935e3..be2b3ceb0bd582d499372374349bdd68 // Base class for managing the print commands for a WebContents. class PrintViewManagerBase : public content::NotificationObserver, public PrintManager { -@@ -47,7 +49,9 @@ class PrintViewManagerBase : public content::NotificationObserver, +@@ -48,7 +50,9 @@ class PrintViewManagerBase : public content::NotificationObserver, // Prints the current document immediately. Since the rendering is // asynchronous, the actual printing will not be completed on the return of // this function. Returns false if printing is impossible at the moment. @@ -159,7 +150,7 @@ index fe0e0b5b065cdcc4edd04665271db14b1bf935e3..be2b3ceb0bd582d499372374349bdd68 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) // Prints the document in |print_data| with settings specified in -@@ -195,6 +199,9 @@ class PrintViewManagerBase : public content::NotificationObserver, +@@ -196,6 +200,9 @@ class PrintViewManagerBase : public content::NotificationObserver, // The current RFH that is printing with a system printing dialog. content::RenderFrameHost* printing_rfh_; @@ -170,7 +161,7 @@ index fe0e0b5b065cdcc4edd04665271db14b1bf935e3..be2b3ceb0bd582d499372374349bdd68 bool printing_succeeded_; diff --git a/chrome/browser/printing/printing_message_filter.cc b/chrome/browser/printing/printing_message_filter.cc -index 54866fdcdb64f4ffd2414c8637ffa2f8fb10c024..e1208906a6145b30c72a484a3b29f47279d75a0e 100644 +index 67079421bf44c832fdc98c8d2c75875e95e0a81c..1896a57f3228e724d9817b25bfd3bd3b94bc10c0 100644 --- a/chrome/browser/printing/printing_message_filter.cc +++ b/chrome/browser/printing/printing_message_filter.cc @@ -20,6 +20,7 @@ @@ -240,26 +231,26 @@ index 54866fdcdb64f4ffd2414c8637ffa2f8fb10c024..e1208906a6145b30c72a484a3b29f472 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) void PrintingMessageFilter::OnCheckForCancel(const PrintHostMsg_PreviewIds& ids, bool* cancel) { -- PrintPreviewUI::GetCurrentPrintPreviewStatus(ids, cancel); -+ // PrintPreviewUI::GetCurrentPrintPreviewStatus(ids, cancel); +- *cancel = PrintPreviewUI::ShouldCancelRequest(ids); ++ *cancel = false; } #endif diff --git a/chrome/browser/printing/printing_message_filter.h b/chrome/browser/printing/printing_message_filter.h -index a881a853bfb0b46d0e074b7e86121429a5a761a3..87efeab40574ac72e4dea33f3ff68919bff93839 100644 +index a881a853bfb0b46d0e074b7e86121429a5a761a3..0b41890bb9b5f10765c12158f6e8b7d373b335b9 100644 --- a/chrome/browser/printing/printing_message_filter.h +++ b/chrome/browser/printing/printing_message_filter.h -@@ -27,6 +27,10 @@ class DictionaryValue; - #if defined(OS_ANDROID) - struct FileDescriptor; +@@ -29,6 +29,10 @@ struct FileDescriptor; #endif -+} // namespace base -+ -+namespace content { -+class BrowserContext; } ++namespace content { ++class BrowserContext; ++} ++ namespace printing { + + class PrintQueriesQueue; @@ -38,7 +42,8 @@ class PrinterQuery; // renderer process on the IPC thread. class PrintingMessageFilter : public content::BrowserMessageFilter { @@ -270,16 +261,8 @@ index a881a853bfb0b46d0e074b7e86121429a5a761a3..87efeab40574ac72e4dea33f3ff68919 // content::BrowserMessageFilter methods. void OverrideThreadForMessage(const IPC::Message& message, -@@ -73,6 +78,7 @@ class PrintingMessageFilter : public content::BrowserMessageFilter { - - // Get the default print setting. - void OnGetDefaultPrintSettings(IPC::Message* reply_msg); -+ - void OnGetDefaultPrintSettingsReply(scoped_refptr printer_query, - IPC::Message* reply_msg); - diff --git a/components/printing/common/print_messages.h b/components/printing/common/print_messages.h -index d29bb6aedecd228e4bc02c84b86cce7151f33746..b489694b2701bddcfa95e187f5fcbf65d9a8ae8c 100644 +index e3c11e1302ff0d1a9cca4cb575a6c8bccfde243d..97dcb7f84ccc8bf367c1a5ee4eb59d945d1c03ba 100644 --- a/components/printing/common/print_messages.h +++ b/components/printing/common/print_messages.h @@ -363,7 +363,10 @@ IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu) @@ -295,10 +278,10 @@ index d29bb6aedecd228e4bc02c84b86cce7151f33746..b489694b2701bddcfa95e187f5fcbf65 // Like PrintMsg_PrintPages, but using the print preview document's frame/node. IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog) diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc -index c7ea5cf76aa629b8feaf99ff6e289140de1d35bd..aee6e02b86a4cf99e263f5a26025a681e3f41463 100644 +index 86a68c361f06bf26d980ee8730f7d759982dfffa..b67affdf12f45d190777b1ad16d33cef2d6da400 100644 --- a/components/printing/renderer/print_render_frame_helper.cc +++ b/components/printing/renderer/print_render_frame_helper.cc -@@ -1045,7 +1045,9 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) { +@@ -1030,7 +1030,9 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) { web_frame->DispatchBeforePrintEvent(); if (!weak_this) return; @@ -309,7 +292,7 @@ index c7ea5cf76aa629b8feaf99ff6e289140de1d35bd..aee6e02b86a4cf99e263f5a26025a681 if (weak_this) web_frame->DispatchAfterPrintEvent(); } -@@ -1093,7 +1095,10 @@ void PrintRenderFrameHelper::OnDestruct() { +@@ -1078,7 +1080,10 @@ void PrintRenderFrameHelper::OnDestruct() { delete this; } @@ -321,26 +304,27 @@ index c7ea5cf76aa629b8feaf99ff6e289140de1d35bd..aee6e02b86a4cf99e263f5a26025a681 if (ipc_nesting_level_ > 1) return; -@@ -1106,7 +1111,7 @@ void PrintRenderFrameHelper::OnPrintPages() { +@@ -1091,7 +1096,8 @@ void PrintRenderFrameHelper::OnPrintPages() { // If we are printing a PDF extension frame, find the plugin node and print // that instead. auto plugin = delegate_->GetPdfElement(frame); - Print(frame, plugin, false /* is_scripted? */); -+ Print(frame, plugin, false, silent, print_background, settings); ++ Print(frame, plugin, false /* is_scripted? */, ++ silent, print_background, settings); if (weak_this) frame->DispatchAfterPrintEvent(); // WARNING: |this| may be gone at this point. Do not do any more work here and -@@ -1122,7 +1127,8 @@ void PrintRenderFrameHelper::OnPrintForSystemDialog() { +@@ -1107,7 +1113,8 @@ void PrintRenderFrameHelper::OnPrintForSystemDialog() { return; } auto weak_this = weak_ptr_factory_.GetWeakPtr(); - Print(frame, print_preview_context_.source_node(), false); -+ Print(frame, print_preview_context_.source_node(), false, false, false, -+ base::DictionaryValue()); ++ Print(frame, print_preview_context_.source_node(), false, ++ false, false, base::DictionaryValue()); if (weak_this) frame->DispatchAfterPrintEvent(); // WARNING: |this| may be gone at this point. Do not do any more work here and -@@ -1158,6 +1164,8 @@ void PrintRenderFrameHelper::OnPrintPreview( +@@ -1143,6 +1150,8 @@ void PrintRenderFrameHelper::OnPrintPreview( if (ipc_nesting_level_ > 1) return; @@ -349,7 +333,7 @@ index c7ea5cf76aa629b8feaf99ff6e289140de1d35bd..aee6e02b86a4cf99e263f5a26025a681 print_preview_context_.OnPrintPreview(); UMA_HISTOGRAM_ENUMERATION("PrintPreview.PreviewEvent", -@@ -1541,7 +1549,9 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) { +@@ -1525,7 +1534,9 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) { auto self = weak_ptr_factory_.GetWeakPtr(); Print(duplicate_node.GetDocument().GetFrame(), duplicate_node, @@ -360,7 +344,7 @@ index c7ea5cf76aa629b8feaf99ff6e289140de1d35bd..aee6e02b86a4cf99e263f5a26025a681 // Check if |this| is still valid. if (!self) return; -@@ -1552,7 +1562,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) { +@@ -1536,7 +1547,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) { void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, const blink::WebNode& node, @@ -372,7 +356,7 @@ index c7ea5cf76aa629b8feaf99ff6e289140de1d35bd..aee6e02b86a4cf99e263f5a26025a681 // If still not finished with earlier print request simply ignore. if (prep_frame_view_) return; -@@ -1560,7 +1573,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, +@@ -1544,7 +1558,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, FrameReference frame_ref(frame); int expected_page_count = 0; @@ -381,7 +365,7 @@ index c7ea5cf76aa629b8feaf99ff6e289140de1d35bd..aee6e02b86a4cf99e263f5a26025a681 DidFinishPrinting(FAIL_PRINT_INIT); return; // Failed to init print page settings. } -@@ -1580,8 +1593,9 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, +@@ -1564,8 +1578,9 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, PrintMsg_PrintPages_Params print_settings; auto self = weak_ptr_factory_.GetWeakPtr(); @@ -393,7 +377,7 @@ index c7ea5cf76aa629b8feaf99ff6e289140de1d35bd..aee6e02b86a4cf99e263f5a26025a681 // Check if |this| is still valid. if (!self) return; -@@ -1591,6 +1605,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, +@@ -1575,6 +1590,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, ? blink::kWebPrintScalingOptionSourceSize : scaling_option; SetPrintPagesParams(print_settings); @@ -401,7 +385,7 @@ index c7ea5cf76aa629b8feaf99ff6e289140de1d35bd..aee6e02b86a4cf99e263f5a26025a681 if (print_settings.params.dpi.IsEmpty() || !print_settings.params.document_cookie) { DidFinishPrinting(OK); // Release resources and fail silently on failure. -@@ -1778,10 +1793,24 @@ std::vector PrintRenderFrameHelper::GetPrintedPages( +@@ -1762,10 +1778,24 @@ std::vector PrintRenderFrameHelper::GetPrintedPages( return printed_pages; } @@ -429,7 +413,7 @@ index c7ea5cf76aa629b8feaf99ff6e289140de1d35bd..aee6e02b86a4cf99e263f5a26025a681 // Check if the printer returned any settings, if the settings is empty, we // can safely assume there are no printer drivers configured. So we safely // terminate. -@@ -1801,12 +1830,14 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) { +@@ -1785,12 +1815,14 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) { return result; } @@ -449,7 +433,7 @@ index c7ea5cf76aa629b8feaf99ff6e289140de1d35bd..aee6e02b86a4cf99e263f5a26025a681 Send(new PrintHostMsg_ShowInvalidPrinterSettingsError(routing_id())); return false; diff --git a/components/printing/renderer/print_render_frame_helper.h b/components/printing/renderer/print_render_frame_helper.h -index 6e2d7e1467b7bc179b1a0fc30dd656de612708cb..8b1516ce5e11d915efdf06cc75f334cd92ce7d99 100644 +index d09db4d500ca3cfa9716114e679bcf428c76c085..a0436373990dafa38c226160d967687b21c021e7 100644 --- a/components/printing/renderer/print_render_frame_helper.h +++ b/components/printing/renderer/print_render_frame_helper.h @@ -187,7 +187,9 @@ class PrintRenderFrameHelper @@ -475,7 +459,7 @@ index 6e2d7e1467b7bc179b1a0fc30dd656de612708cb..8b1516ce5e11d915efdf06cc75f334cd // Notification when printing is done - signal tear-down/free resources. void DidFinishPrinting(PrintingResult result); -@@ -247,12 +252,14 @@ class PrintRenderFrameHelper +@@ -248,12 +253,14 @@ class PrintRenderFrameHelper // Initialize print page settings with default settings. // Used only for native printing workflow.