Commit 1a33b7b1 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

[printing] Move PrintHostMsg_DidPreviewDocument_Params to print.mojom

This CL moves PrintHostMsg_DidPreviewDocument_Params to
//printing/mojom/print.mojom to pass it to Mojo interfaces. It's
a precursor CL of PrintHostMsg_MetafileReadyForPrinting
mojofication.

Bug: 1008939
Change-Id: I83b988849cbc93b780d9422d2ac3e5065e51fbbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2257035
Commit-Queue: Julie Kim <jkim@igalia.com>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783783}
parent 2e8386a0
...@@ -217,7 +217,7 @@ void PrintPreviewMessageHandler::OnDidPreviewPage( ...@@ -217,7 +217,7 @@ void PrintPreviewMessageHandler::OnDidPreviewPage(
void PrintPreviewMessageHandler::OnMetafileReadyForPrinting( void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
const PrintHostMsg_DidPreviewDocument_Params& params, const mojom::DidPreviewDocumentParams& params,
const PrintHostMsg_PreviewIds& ids) { const PrintHostMsg_PreviewIds& ids) {
// Always try to stop the worker. // Always try to stop the worker.
StopWorker(params.document_cookie); StopWorker(params.document_cookie);
...@@ -229,7 +229,7 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting( ...@@ -229,7 +229,7 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
const bool composite_document_using_individual_pages = const bool composite_document_using_individual_pages =
ShouldUseCompositor(print_preview_ui); ShouldUseCompositor(print_preview_ui);
const base::ReadOnlySharedMemoryRegion& metafile = const base::ReadOnlySharedMemoryRegion& metafile =
params.content.metafile_data_region; params.content->metafile_data_region;
// When the Print Compositor is active, the print document is composed from // When the Print Compositor is active, the print document is composed from
// the individual pages, so |metafile| should be invalid. // the individual pages, so |metafile| should be invalid.
...@@ -238,7 +238,7 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting( ...@@ -238,7 +238,7 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
if (composite_document_using_individual_pages == metafile.IsValid()) if (composite_document_using_individual_pages == metafile.IsValid())
return; return;
if (params.expected_pages_count <= 0) { if (params.expected_pages_count == 0) {
NOTREACHED(); NOTREACHED();
return; return;
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
#include "printing/mojom/print.mojom-forward.h" #include "printing/mojom/print.mojom-forward.h"
struct PrintHostMsg_DidPreviewDocument_Params;
struct PrintHostMsg_PreviewIds; struct PrintHostMsg_PreviewIds;
struct PrintHostMsg_RequestPrintPreview_Params; struct PrintHostMsg_RequestPrintPreview_Params;
...@@ -77,10 +76,9 @@ class PrintPreviewMessageHandler ...@@ -77,10 +76,9 @@ class PrintPreviewMessageHandler
void OnDidPreviewPage(content::RenderFrameHost* render_frame_host, void OnDidPreviewPage(content::RenderFrameHost* render_frame_host,
const mojom::DidPreviewPageParams& params, const mojom::DidPreviewPageParams& params,
const PrintHostMsg_PreviewIds& ids); const PrintHostMsg_PreviewIds& ids);
void OnMetafileReadyForPrinting( void OnMetafileReadyForPrinting(content::RenderFrameHost* render_frame_host,
content::RenderFrameHost* render_frame_host, const mojom::DidPreviewDocumentParams& params,
const PrintHostMsg_DidPreviewDocument_Params& params, const PrintHostMsg_PreviewIds& ids);
const PrintHostMsg_PreviewIds& ids);
void NotifyUIPreviewPageReady( void NotifyUIPreviewPageReady(
PrintPreviewUI* print_preview_ui, PrintPreviewUI* print_preview_ui,
......
...@@ -65,6 +65,16 @@ struct DidPreviewPageParams { ...@@ -65,6 +65,16 @@ struct DidPreviewPageParams {
int32 document_cookie; int32 document_cookie;
}; };
// Parameters to describe the final rendered preview document.
struct DidPreviewDocumentParams {
// Document's content including metafile data and subframe info.
DidPrintContentParams content;
// Cookie for the document to ensure correctness.
int32 document_cookie;
// Store the expected pages count.
uint32 expected_pages_count;
};
// Interface implemented by a class that desires to render print documents for // Interface implemented by a class that desires to render print documents for
// Chrome print preview. // Chrome print preview.
interface PrintRenderer { interface PrintRenderer {
......
...@@ -276,16 +276,16 @@ IPC_STRUCT_TRAITS_BEGIN(printing::mojom::DidPreviewPageParams) ...@@ -276,16 +276,16 @@ IPC_STRUCT_TRAITS_BEGIN(printing::mojom::DidPreviewPageParams)
IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_END()
// Parameters to describe the final rendered preview document. // Parameters to describe the final rendered preview document.
IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params) IPC_STRUCT_TRAITS_BEGIN(printing::mojom::DidPreviewDocumentParams)
// Document's content including metafile data and subframe info. // Document's content including metafile data and subframe info.
IPC_STRUCT_MEMBER(printing::mojom::DidPrintContentParams, content) IPC_STRUCT_TRAITS_MEMBER(content)
// Cookie for the document to ensure correctness. // Cookie for the document to ensure correctness.
IPC_STRUCT_MEMBER(int, document_cookie) IPC_STRUCT_TRAITS_MEMBER(document_cookie)
// Store the expected pages count. // Store the expected pages count.
IPC_STRUCT_MEMBER(int, expected_pages_count) IPC_STRUCT_TRAITS_MEMBER(expected_pages_count)
IPC_STRUCT_END() IPC_STRUCT_TRAITS_END()
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Parameters to describe a rendered page. // Parameters to describe a rendered page.
...@@ -415,7 +415,7 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_CheckForCancel, ...@@ -415,7 +415,7 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_CheckForCancel,
// used for printing) that was requested by a PrintMsg_PrintPreview message. // used for printing) that was requested by a PrintMsg_PrintPreview message.
// The memory handle in this message is already valid in the browser process. // The memory handle in this message is already valid in the browser process.
IPC_MESSAGE_ROUTED2(PrintHostMsg_MetafileReadyForPrinting, IPC_MESSAGE_ROUTED2(PrintHostMsg_MetafileReadyForPrinting,
PrintHostMsg_DidPreviewDocument_Params /* params */, printing::mojom::DidPreviewDocumentParams /* params */,
PrintHostMsg_PreviewIds /* ids */) PrintHostMsg_PreviewIds /* ids */)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
......
...@@ -1641,7 +1641,8 @@ bool PrintRenderFrameHelper::FinalizePrintReadyDocument() { ...@@ -1641,7 +1641,8 @@ bool PrintRenderFrameHelper::FinalizePrintReadyDocument() {
DCHECK(!is_print_ready_metafile_sent_); DCHECK(!is_print_ready_metafile_sent_);
print_preview_context_.FinalizePrintReadyDocument(); print_preview_context_.FinalizePrintReadyDocument();
PrintHostMsg_DidPreviewDocument_Params preview_params; mojom::DidPreviewDocumentParams preview_params;
preview_params.content = mojom::DidPrintContentParams::New();
// Modifiable content of MSKP type is collected into a document during // Modifiable content of MSKP type is collected into a document during
// individual page preview generation, so only need to share a separate // individual page preview generation, so only need to share a separate
...@@ -1650,7 +1651,7 @@ bool PrintRenderFrameHelper::FinalizePrintReadyDocument() { ...@@ -1650,7 +1651,7 @@ bool PrintRenderFrameHelper::FinalizePrintReadyDocument() {
MetafileSkia* metafile = print_preview_context_.metafile(); MetafileSkia* metafile = print_preview_context_.metafile();
if (metafile) { if (metafile) {
if (!CopyMetafileDataToReadOnlySharedMem(*metafile, if (!CopyMetafileDataToReadOnlySharedMem(*metafile,
&preview_params.content)) { preview_params.content.get())) {
LOG(ERROR) << "CopyMetafileDataToReadOnlySharedMem failed"; LOG(ERROR) << "CopyMetafileDataToReadOnlySharedMem failed";
print_preview_context_.set_error(PREVIEW_ERROR_METAFILE_COPY_FAILED); print_preview_context_.set_error(PREVIEW_ERROR_METAFILE_COPY_FAILED);
return false; return false;
...@@ -2727,7 +2728,8 @@ PrintRenderFrameHelper::PrintPreviewContext::pages_to_render() const { ...@@ -2727,7 +2728,8 @@ PrintRenderFrameHelper::PrintPreviewContext::pages_to_render() const {
return pages_to_render_; return pages_to_render_;
} }
int PrintRenderFrameHelper::PrintPreviewContext::pages_rendered_count() const { size_t PrintRenderFrameHelper::PrintPreviewContext::pages_rendered_count()
const {
DCHECK_EQ(DONE, state_); DCHECK_EQ(DONE, state_);
return pages_to_render_.size(); return pages_to_render_.size();
} }
......
...@@ -534,7 +534,7 @@ class PrintRenderFrameHelper ...@@ -534,7 +534,7 @@ class PrintRenderFrameHelper
int total_page_count() const; int total_page_count() const;
const std::vector<int>& pages_to_render() const; const std::vector<int>& pages_to_render() const;
int pages_rendered_count() const; size_t pages_rendered_count() const;
MetafileSkia* metafile(); MetafileSkia* metafile();
ContentProxySet* typeface_content_info(); ContentProxySet* typeface_content_info();
int last_error() const; int last_error() const;
......
...@@ -743,8 +743,8 @@ class MAYBE_PrintRenderFrameHelperPreviewTest ...@@ -743,8 +743,8 @@ class MAYBE_PrintRenderFrameHelperPreviewTest
PrintHostMsg_MetafileReadyForPrinting::Read(preview_msg, &preview_param); PrintHostMsg_MetafileReadyForPrinting::Read(preview_msg, &preview_param);
const auto& param = std::get<0>(preview_param); const auto& param = std::get<0>(preview_param);
EXPECT_NE(0, param.document_cookie); EXPECT_NE(0, param.document_cookie);
EXPECT_NE(0, param.expected_pages_count); EXPECT_NE(0U, param.expected_pages_count);
EXPECT_NE(0U, param.content.metafile_data_region.GetSize()); EXPECT_NE(0U, param.content->metafile_data_region.GetSize());
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment