summaryrefslogtreecommitdiff
path: root/chromium/components/printing/common
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/components/printing/common
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/printing/common')
-rw-r--r--chromium/components/printing/common/BUILD.gn1
-rw-r--r--chromium/components/printing/common/print.mojom44
-rw-r--r--chromium/components/printing/common/print_messages.cc10
-rw-r--r--chromium/components/printing/common/print_messages.h79
4 files changed, 80 insertions, 54 deletions
diff --git a/chromium/components/printing/common/BUILD.gn b/chromium/components/printing/common/BUILD.gn
index ce878a58e6d..386f3770eed 100644
--- a/chromium/components/printing/common/BUILD.gn
+++ b/chromium/components/printing/common/BUILD.gn
@@ -15,6 +15,7 @@ static_library("common") {
]
deps = [
+ ":mojo_interfaces",
"//base",
"//components/cloud_devices/common:common",
"//ipc",
diff --git a/chromium/components/printing/common/print.mojom b/chromium/components/printing/common/print.mojom
index 408f5bc1e43..faccd2a6881 100644
--- a/chromium/components/printing/common/print.mojom
+++ b/chromium/components/printing/common/print.mojom
@@ -29,6 +29,32 @@ struct OptionsFromDocumentParams {
DuplexMode duplex;
};
+// Holds the printed content information.
+// The printed content is in shared memory, and passed as a region.
+// A map on out-of-process subframe contents is also included so the printed
+// content can be composited as needed.
+struct DidPrintContentParams {
+ // A shared memory region for the metafile data.
+ mojo_base.mojom.ReadOnlySharedMemoryRegion metafile_data_region;
+ // Content id to render frame proxy id mapping for out-of-process subframes.
+ map<uint32, int32> subframe_content_info;
+};
+
+// Parameters to describe the to-be-rendered preview document.
+struct DidStartPreviewParams {
+ // Total page count for the rendered preview. (Not the number of pages the
+ // user selected to print.)
+ int32 page_count;
+ // The list of 0-based page numbers that will be rendered.
+ array<int32> pages_to_render;
+ // number of pages per sheet and should be greater or equal to 1.
+ int32 pages_per_sheet;
+ // Physical size of the page, including non-printable margins.
+ gfx.mojom.Size page_size;
+ // Scaling % to fit to page
+ int32 fit_to_page_scaling;
+};
+
// Interface implemented by a class that desires to render print documents for
// Chrome print preview.
interface PrintRenderer {
@@ -54,6 +80,18 @@ interface PrintPreviewUI {
// ensure correctness and |request_id| is the id for the preview request.
[EnableIf=enable_print_preview]
PrintPreviewFailed(int32 document_cookie, int32 request_id);
+
+ // Tell the browser print preview was cancelled. |document_cookie| is the
+ // param to ensure correctness and |request_id| is the id for the preview
+ // request.
+ [EnableIf=enable_print_preview]
+ PrintPreviewCancelled(int32 document_cookie, int32 request_id);
+
+ // Tell the browser print preview found the selected printer has invalid
+ // settings (which typically caused by disconnected network printer or
+ // printer driver is bogus).
+ [EnableIf=enable_print_preview]
+ PrinterSettingsInvalid(int32 document_cookie, int32 request_id);
};
// Render process interface exposed to the browser to handle most of the
@@ -88,8 +126,10 @@ interface PrintRenderFrame {
[EnableIf=enable_print_preview]
OnPrintPreviewDialogClosed();
- // Prints the content of an out-of-process subframe.
- PrintFrameContent(PrintFrameContentParams params);
+ // Prints the content of an out-of-process subframe. Replies back to the
+ // browser the rendered subframe content that was requested.
+ PrintFrameContent(PrintFrameContentParams params)
+ => (int32 document_cookie, DidPrintContentParams params);
// Tells the RenderFrame whether printing is enabled or not.
SetPrintingEnabled(bool enabled);
diff --git a/chromium/components/printing/common/print_messages.cc b/chromium/components/printing/common/print_messages.cc
index 46b965863e5..1ae067c5268 100644
--- a/chromium/components/printing/common/print_messages.cc
+++ b/chromium/components/printing/common/print_messages.cc
@@ -66,6 +66,7 @@ namespace IPC {
PrintMsg_Print_Params::PrintMsg_Print_Params()
: margin_top(0),
margin_left(0),
+ page_orientation(printing::mojom::PageOrientation::kUpright),
scale_factor(1.0f),
rasterize_pdf(false),
document_cookie(0),
@@ -74,11 +75,11 @@ PrintMsg_Print_Params::PrintMsg_Print_Params()
preview_ui_id(-1),
preview_request_id(0),
is_first_request(false),
- print_scaling_option(blink::kWebPrintScalingOptionSourceSize),
+ print_scaling_option(printing::mojom::PrintScalingOption::kSourceSize),
print_to_pdf(false),
display_header_footer(false),
should_print_backgrounds(false),
- printed_doc_type(printing::SkiaDocumentType::PDF),
+ printed_doc_type(printing::mojom::SkiaDocumentType::kPDF),
prefer_css_page_size(false),
pages_per_sheet(1) {}
@@ -93,6 +94,7 @@ void PrintMsg_Print_Params::Reset() {
printable_area = gfx::Rect();
margin_top = 0;
margin_left = 0;
+ page_orientation = printing::mojom::PageOrientation::kUpright;
dpi = gfx::Size();
scale_factor = 1.0f;
rasterize_pdf = false;
@@ -102,7 +104,7 @@ void PrintMsg_Print_Params::Reset() {
preview_ui_id = -1;
preview_request_id = 0;
is_first_request = false;
- print_scaling_option = blink::kWebPrintScalingOptionSourceSize;
+ print_scaling_option = printing::mojom::PrintScalingOption::kSourceSize;
print_to_pdf = false;
display_header_footer = false;
title = base::string16();
@@ -110,7 +112,7 @@ void PrintMsg_Print_Params::Reset() {
header_template = base::string16();
footer_template = base::string16();
should_print_backgrounds = false;
- printed_doc_type = printing::SkiaDocumentType::PDF;
+ printed_doc_type = printing::mojom::SkiaDocumentType::kPDF;
prefer_css_page_size = false;
pages_per_sheet = 1;
}
diff --git a/chromium/components/printing/common/print_messages.h b/chromium/components/printing/common/print_messages.h
index 18b238f14b7..6b2e5582053 100644
--- a/chromium/components/printing/common/print_messages.h
+++ b/chromium/components/printing/common/print_messages.h
@@ -14,14 +14,13 @@
#include "base/memory/read_only_shared_memory_region.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "components/printing/common/print.mojom.h"
#include "components/printing/common/printing_param_traits_macros.h"
#include "ipc/ipc_message_macros.h"
#include "printing/buildflags/buildflags.h"
-#include "printing/common/metafile_utils.h"
+#include "printing/mojom/print.mojom.h"
#include "printing/page_range.h"
-#include "printing/page_size_margins.h"
#include "printing/print_job_constants.h"
-#include "third_party/blink/public/web/web_print_scaling_option.h"
#include "ui/accessibility/ax_param_traits.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
@@ -44,6 +43,7 @@ struct PrintMsg_Print_Params {
gfx::Rect printable_area;
int margin_top;
int margin_left;
+ printing::mojom::PageOrientation page_orientation;
gfx::Size dpi;
double scale_factor;
bool rasterize_pdf;
@@ -53,7 +53,7 @@ struct PrintMsg_Print_Params {
int32_t preview_ui_id;
int preview_request_id;
bool is_first_request;
- blink::WebPrintScalingOption print_scaling_option;
+ printing::mojom::PrintScalingOption print_scaling_option;
bool print_to_pdf;
bool display_header_footer;
base::string16 title;
@@ -61,7 +61,7 @@ struct PrintMsg_Print_Params {
base::string16 header_template;
base::string16 footer_template;
bool should_print_backgrounds;
- printing::SkiaDocumentType printed_doc_type;
+ printing::mojom::SkiaDocumentType printed_doc_type;
bool prefer_css_page_size;
int pages_per_sheet;
};
@@ -103,10 +103,10 @@ struct PrintHostMsg_PreviewIds {
#define IPC_MESSAGE_START PrintMsgStart
-IPC_ENUM_TRAITS_MAX_VALUE(blink::WebPrintScalingOption,
- blink::kWebPrintScalingOptionLast)
-IPC_ENUM_TRAITS_MAX_VALUE(printing::SkiaDocumentType,
- printing::SkiaDocumentType::MAX)
+IPC_ENUM_TRAITS_MAX_VALUE(printing::mojom::PrintScalingOption,
+ printing::mojom::PrintScalingOption::kMaxValue)
+IPC_ENUM_TRAITS_MAX_VALUE(printing::mojom::SkiaDocumentType,
+ printing::mojom::SkiaDocumentType::kMaxValue)
// Parameters for a render request.
IPC_STRUCT_TRAITS_BEGIN(PrintMsg_Print_Params)
@@ -212,7 +212,7 @@ IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_PreviewIds)
IPC_STRUCT_TRAITS_END()
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
-IPC_STRUCT_TRAITS_BEGIN(printing::PageSizeMargins)
+IPC_STRUCT_TRAITS_BEGIN(printing::mojom::PageSizeMargins)
IPC_STRUCT_TRAITS_MEMBER(content_width)
IPC_STRUCT_TRAITS_MEMBER(content_height)
IPC_STRUCT_TRAITS_MEMBER(margin_left)
@@ -234,38 +234,38 @@ IPC_STRUCT_TRAITS_END()
// The printed content is in shared memory, and passed as a region.
// A map on out-of-process subframe contents is also included so the printed
// content can be composited as needed.
-IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintContent_Params)
+IPC_STRUCT_TRAITS_BEGIN(printing::mojom::DidPrintContentParams)
// A shared memory region for the metafile data.
- IPC_STRUCT_MEMBER(base::ReadOnlySharedMemoryRegion, metafile_data_region)
+ IPC_STRUCT_TRAITS_MEMBER(metafile_data_region)
// Content id to render frame proxy id mapping for out-of-process subframes.
- IPC_STRUCT_MEMBER(printing::ContentToProxyIdMap, subframe_content_info)
-IPC_STRUCT_END()
+ IPC_STRUCT_TRAITS_MEMBER(subframe_content_info)
+IPC_STRUCT_TRAITS_END()
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Parameters to describe the to-be-rendered preview document.
-IPC_STRUCT_BEGIN(PrintHostMsg_DidStartPreview_Params)
+IPC_STRUCT_TRAITS_BEGIN(printing::mojom::DidStartPreviewParams)
// Total page count for the rendered preview. (Not the number of pages the
// user selected to print.)
- IPC_STRUCT_MEMBER(int, page_count)
+ IPC_STRUCT_TRAITS_MEMBER(page_count)
// The list of 0-based page numbers that will be rendered.
- IPC_STRUCT_MEMBER(std::vector<int>, pages_to_render)
+ IPC_STRUCT_TRAITS_MEMBER(pages_to_render)
// number of pages per sheet and should be greater or equal to 1.
- IPC_STRUCT_MEMBER(int, pages_per_sheet)
+ IPC_STRUCT_TRAITS_MEMBER(pages_per_sheet)
// Physical size of the page, including non-printable margins.
- IPC_STRUCT_MEMBER(gfx::Size, page_size)
+ IPC_STRUCT_TRAITS_MEMBER(page_size)
// Scaling % to fit to page
- IPC_STRUCT_MEMBER(int, fit_to_page_scaling)
-IPC_STRUCT_END()
+ IPC_STRUCT_TRAITS_MEMBER(fit_to_page_scaling)
+IPC_STRUCT_TRAITS_END()
// Parameters to describe a rendered preview page.
IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewPage_Params)
// Page's content including metafile data and subframe info.
- IPC_STRUCT_MEMBER(PrintHostMsg_DidPrintContent_Params, content)
+ IPC_STRUCT_MEMBER(printing::mojom::DidPrintContentParams, content)
// |page_number| is zero-based and should not be negative.
IPC_STRUCT_MEMBER(int, page_number)
@@ -277,7 +277,7 @@ IPC_STRUCT_END()
// Parameters to describe the final rendered preview document.
IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params)
// Document's content including metafile data and subframe info.
- IPC_STRUCT_MEMBER(PrintHostMsg_DidPrintContent_Params, content)
+ IPC_STRUCT_MEMBER(printing::mojom::DidPrintContentParams, content)
// Cookie for the document to ensure correctness.
IPC_STRUCT_MEMBER(int, document_cookie)
@@ -290,7 +290,7 @@ IPC_STRUCT_END()
// Parameters to describe a rendered page.
IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintDocument_Params)
// Document's content including metafile data and subframe info.
- IPC_STRUCT_MEMBER(PrintHostMsg_DidPrintContent_Params, content)
+ IPC_STRUCT_MEMBER(printing::mojom::DidPrintContentParams, content)
// Cookie for the document to ensure correctness.
IPC_STRUCT_MEMBER(int, document_cookie)
@@ -342,12 +342,6 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_DidPrintDocument,
/* page content */,
bool /* completed */)
-// Sends back to the browser the rendered subframe content that was
-// requested by a PrintMsg_PrintFrameContent message.
-IPC_MESSAGE_ROUTED2(PrintHostMsg_DidPrintFrameContent,
- int /* rendered document cookie */,
- PrintHostMsg_DidPrintContent_Params)
-
#if BUILDFLAG(ENABLE_TAGGED_PDF)
// Sends the accessibility tree corresponding to a document being
// printed, needed for a tagged (accessible) PDF.
@@ -384,7 +378,7 @@ IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview,
// Notify the browser the about the to-be-rendered print preview document.
IPC_MESSAGE_ROUTED2(PrintHostMsg_DidStartPreview,
- PrintHostMsg_DidStartPreview_Params /* params */,
+ printing::mojom::DidStartPreviewParams /* params */,
PrintHostMsg_PreviewIds /* ids */)
// Notify the browser of preparing to print the document, for cases where
@@ -399,11 +393,12 @@ IPC_MESSAGE_ROUTED2(PrintHostMsg_DidPrepareDocumentForPreview,
// |printable_area_in_points| Specifies the printable area in points.
// |has_custom_page_size_style| is true when the printing frame has a custom
// page size css otherwise false.
-IPC_MESSAGE_ROUTED4(PrintHostMsg_DidGetDefaultPageLayout,
- printing::PageSizeMargins /* page layout in points */,
- gfx::Rect /* printable area in points */,
- bool /* has custom page size style */,
- PrintHostMsg_PreviewIds /* ids */)
+IPC_MESSAGE_ROUTED4(
+ PrintHostMsg_DidGetDefaultPageLayout,
+ printing::mojom::PageSizeMargins /* page layout in points */,
+ gfx::Rect /* printable area in points */,
+ bool /* has custom page size style */,
+ PrintHostMsg_PreviewIds /* ids */)
// Notify the browser a print preview page has been rendered.
IPC_MESSAGE_ROUTED2(PrintHostMsg_DidPreviewPage,
@@ -431,18 +426,6 @@ IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed,
int /* document cookie */)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
-// Tell the browser print preview was cancelled.
-IPC_MESSAGE_ROUTED2(PrintHostMsg_PrintPreviewCancelled,
- int /* document cookie */,
- PrintHostMsg_PreviewIds /* ids */)
-
-// Tell the browser print preview found the selected printer has invalid
-// settings (which typically caused by disconnected network printer or printer
-// driver is bogus).
-IPC_MESSAGE_ROUTED2(PrintHostMsg_PrintPreviewInvalidPrinterSettings,
- int /* document cookie */,
- PrintHostMsg_PreviewIds /* ids */)
-
// Run a nested run loop in the renderer until print preview for
// window.print() finishes.
IPC_SYNC_MESSAGE_ROUTED0_0(PrintHostMsg_SetupScriptedPrintPreview)