1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// IPC messages for printing.
#ifndef COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
#define COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
#include <stdint.h>
#include <string>
#include <vector>
#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.h"
#include "components/printing/common/printing_param_traits_macros.h"
#include "ipc/ipc_message_macros.h"
#include "printing/buildflags/buildflags.h"
#include "printing/mojom/print.mojom.h"
#include "printing/page_range.h"
#include "printing/print_job_constants.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/ipc/geometry/gfx_param_traits.h"
#ifndef INTERNAL_COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
#define INTERNAL_COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
struct PrintHostMsg_RequestPrintPreview_Params {
PrintHostMsg_RequestPrintPreview_Params();
~PrintHostMsg_RequestPrintPreview_Params();
bool is_from_arc;
bool is_modifiable;
bool is_pdf;
bool webnode_only;
bool has_selection;
bool selection_only;
};
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // INTERNAL_COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
#define IPC_MESSAGE_START PrintMsgStart
IPC_ENUM_TRAITS_MAX_VALUE(printing::mojom::PageOrientation,
printing::mojom::PageOrientation::kMaxValue)
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(printing::mojom::PrintParams)
// Physical size of the page, including non-printable margins,
// in pixels according to dpi.
IPC_STRUCT_TRAITS_MEMBER(page_size)
// In pixels according to dpi.
IPC_STRUCT_TRAITS_MEMBER(content_size)
// Physical printable area of the page in pixels according to dpi.
IPC_STRUCT_TRAITS_MEMBER(printable_area)
// The y-offset of the printable area, in pixels according to dpi.
IPC_STRUCT_TRAITS_MEMBER(margin_top)
// The x-offset of the printable area, in pixels according to dpi.
IPC_STRUCT_TRAITS_MEMBER(margin_left)
// Specifies the page orientation.
IPC_STRUCT_TRAITS_MEMBER(page_orientation)
// Specifies dots per inch in the x and y direction.
IPC_STRUCT_TRAITS_MEMBER(dpi)
// Specifies the scale factor in percent
IPC_STRUCT_TRAITS_MEMBER(scale_factor)
// Cookie for the document to ensure correctness.
IPC_STRUCT_TRAITS_MEMBER(document_cookie)
// Should only print currently selected text.
IPC_STRUCT_TRAITS_MEMBER(selection_only)
// Does the printer support alpha blending?
IPC_STRUCT_TRAITS_MEMBER(supports_alpha_blend)
// *** Parameters below are used only for print preview. ***
// The print preview ui associated with this request.
IPC_STRUCT_TRAITS_MEMBER(preview_ui_id)
// The id of the preview request.
IPC_STRUCT_TRAITS_MEMBER(preview_request_id)
// True if this is the first preview request.
IPC_STRUCT_TRAITS_MEMBER(is_first_request)
// Specifies the page scaling option for preview printing.
IPC_STRUCT_TRAITS_MEMBER(print_scaling_option)
// True if print to pdf is requested.
IPC_STRUCT_TRAITS_MEMBER(print_to_pdf)
// Specifies if the header and footer should be rendered.
IPC_STRUCT_TRAITS_MEMBER(display_header_footer)
// Title string to be printed as header if requested by the user.
IPC_STRUCT_TRAITS_MEMBER(title)
// URL string to be printed as footer if requested by the user.
IPC_STRUCT_TRAITS_MEMBER(url)
// HTML template to use as a print header.
IPC_STRUCT_TRAITS_MEMBER(header_template)
// HTML template to use as a print footer.
IPC_STRUCT_TRAITS_MEMBER(footer_template)
// Whether to rasterize a PDF for printing
IPC_STRUCT_TRAITS_MEMBER(rasterize_pdf)
// True if print backgrounds is requested by the user.
IPC_STRUCT_TRAITS_MEMBER(should_print_backgrounds)
// The document type of printed page(s) from render.
IPC_STRUCT_TRAITS_MEMBER(printed_doc_type)
// True if page size defined by css should be preferred.
IPC_STRUCT_TRAITS_MEMBER(prefer_css_page_size)
// Number of pages per sheet. This parameter is for N-up mode.
// Defaults to 1 if the feature is disabled, and some number greater
// than 1 otherwise. See printing::NupParameters for supported values.
IPC_STRUCT_TRAITS_MEMBER(pages_per_sheet)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(printing::PageRange)
IPC_STRUCT_TRAITS_MEMBER(from)
IPC_STRUCT_TRAITS_MEMBER(to)
IPC_STRUCT_TRAITS_END()
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_RequestPrintPreview_Params)
IPC_STRUCT_TRAITS_MEMBER(is_from_arc)
IPC_STRUCT_TRAITS_MEMBER(is_modifiable)
IPC_STRUCT_TRAITS_MEMBER(is_pdf)
IPC_STRUCT_TRAITS_MEMBER(webnode_only)
IPC_STRUCT_TRAITS_MEMBER(has_selection)
IPC_STRUCT_TRAITS_MEMBER(selection_only)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(printing::mojom::PreviewIds)
IPC_STRUCT_TRAITS_MEMBER(request_id)
IPC_STRUCT_TRAITS_MEMBER(ui_id)
IPC_STRUCT_TRAITS_END()
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
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)
IPC_STRUCT_TRAITS_MEMBER(margin_right)
IPC_STRUCT_TRAITS_MEMBER(margin_top)
IPC_STRUCT_TRAITS_MEMBER(margin_bottom)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(printing::mojom::PrintPagesParams)
// Parameters to render the page as a printed page. It must always be the same
// value for all the document.
IPC_STRUCT_TRAITS_MEMBER(params)
// If empty, this means a request to render all the printed pages.
IPC_STRUCT_TRAITS_MEMBER(pages)
IPC_STRUCT_TRAITS_END()
// 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.
IPC_STRUCT_TRAITS_BEGIN(printing::mojom::DidPrintContentParams)
// A shared memory region for the metafile data.
IPC_STRUCT_TRAITS_MEMBER(metafile_data_region)
// Content id to render frame proxy id mapping for out-of-process subframes.
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_TRAITS_BEGIN(printing::mojom::DidStartPreviewParams)
// Total page count for the rendered preview. (Not the number of pages the
// user selected to print.)
IPC_STRUCT_TRAITS_MEMBER(page_count)
// The list of 0-based page numbers that will be rendered.
IPC_STRUCT_TRAITS_MEMBER(pages_to_render)
// number of pages per sheet and should be greater or equal to 1.
IPC_STRUCT_TRAITS_MEMBER(pages_per_sheet)
// Physical size of the page, including non-printable margins.
IPC_STRUCT_TRAITS_MEMBER(page_size)
// Scaling % to fit to page
IPC_STRUCT_TRAITS_MEMBER(fit_to_page_scaling)
IPC_STRUCT_TRAITS_END()
// Parameters to describe a rendered preview page.
IPC_STRUCT_TRAITS_BEGIN(printing::mojom::DidPreviewPageParams)
// Page's content including metafile data and subframe info.
IPC_STRUCT_TRAITS_MEMBER(content)
// |page_number| is zero-based and should not be negative.
IPC_STRUCT_TRAITS_MEMBER(page_number)
// Cookie for the document to ensure correctness.
IPC_STRUCT_TRAITS_MEMBER(document_cookie)
IPC_STRUCT_TRAITS_END()
// Parameters to describe the final rendered preview document.
IPC_STRUCT_TRAITS_BEGIN(printing::mojom::DidPreviewDocumentParams)
// Document's content including metafile data and subframe info.
IPC_STRUCT_TRAITS_MEMBER(content)
// Cookie for the document to ensure correctness.
IPC_STRUCT_TRAITS_MEMBER(document_cookie)
// Store the expected pages count.
IPC_STRUCT_TRAITS_MEMBER(expected_pages_count)
IPC_STRUCT_TRAITS_END()
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Parameters to describe a rendered page.
IPC_STRUCT_TRAITS_BEGIN(printing::mojom::DidPrintDocumentParams)
// Document's content including metafile data and subframe info.
IPC_STRUCT_TRAITS_MEMBER(content)
// Cookie for the document to ensure correctness.
IPC_STRUCT_TRAITS_MEMBER(document_cookie)
// The size of the page the page author specified.
IPC_STRUCT_TRAITS_MEMBER(page_size)
// The printable area the page author specified.
IPC_STRUCT_TRAITS_MEMBER(content_area)
// The physical offsets of the printer in DPI. Used for PS printing.
IPC_STRUCT_TRAITS_MEMBER(physical_offsets)
IPC_STRUCT_TRAITS_END()
// TODO(dgn): Rename *ScriptedPrint messages because they are not called only
// from scripts.
// Parameters for the IPC message PrintHostMsg_ScriptedPrint
IPC_STRUCT_TRAITS_BEGIN(printing::mojom::ScriptedPrintParams)
IPC_STRUCT_TRAITS_MEMBER(cookie)
IPC_STRUCT_TRAITS_MEMBER(expected_pages_count)
IPC_STRUCT_TRAITS_MEMBER(has_selection)
IPC_STRUCT_TRAITS_MEMBER(is_scripted)
IPC_STRUCT_TRAITS_MEMBER(is_modifiable)
IPC_STRUCT_TRAITS_MEMBER(margin_type)
IPC_STRUCT_TRAITS_END()
// Messages sent from the renderer to the browser.
// Sends back to the browser the rendered document that was requested by a
// PrintMsg_PrintPages message or from scripted printing. The memory handle in
// this message is already valid in the browser process. Waits until the
// document is complete ready before replying.
IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_DidPrintDocument,
printing::mojom::DidPrintDocumentParams
/* page content */,
bool /* completed */)
// It's the renderer that controls the printing process when it is generated
// by javascript. This step is about showing UI to the user to select the
// final print settings. The output parameter is the same as
// PrintMsg_PrintPages which is executed implicitly.
IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_ScriptedPrint,
printing::mojom::ScriptedPrintParams,
printing::mojom::PrintPagesParams
/* settings chosen by the user*/)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Asks the browser to do print preview.
IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview,
PrintHostMsg_RequestPrintPreview_Params /* params */)
// Notify the browser the about the to-be-rendered print preview document.
IPC_MESSAGE_ROUTED2(PrintHostMsg_DidStartPreview,
printing::mojom::DidStartPreviewParams /* params */,
printing::mojom::PreviewIds /* ids */)
// Notify the browser of preparing to print the document, for cases where
// the document will be collected from the individual pages instead of being
// provided by an extra metafile at end containing all pages.
IPC_MESSAGE_ROUTED2(PrintHostMsg_DidPrepareDocumentForPreview,
int /* document_cookie */,
printing::mojom::PreviewIds /* ids */)
// Notify the browser of the default page layout according to the currently
// selected printer and page size.
// |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::mojom::PageSizeMargins /* page layout in points */,
gfx::Rect /* printable area in points */,
bool /* has custom page size style */,
printing::mojom::PreviewIds /* ids */)
// Notify the browser a print preview page has been rendered.
IPC_MESSAGE_ROUTED2(PrintHostMsg_DidPreviewPage,
printing::mojom::DidPreviewPageParams /* params */,
printing::mojom::PreviewIds /* ids */)
// Asks the browser whether the print preview has been cancelled.
IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_CheckForCancel,
printing::mojom::PreviewIds /* ids */,
bool /* print preview cancelled */)
// Sends back to the browser the complete rendered document (non-draft mode,
// used for printing) that was requested by a PrintMsg_PrintPreview message.
// The memory handle in this message is already valid in the browser process.
IPC_MESSAGE_ROUTED2(PrintHostMsg_MetafileReadyForPrinting,
printing::mojom::DidPreviewDocumentParams /* params */,
printing::mojom::PreviewIds /* ids */)
// Run a nested run loop in the renderer until print preview for
// window.print() finishes.
IPC_SYNC_MESSAGE_ROUTED0_0(PrintHostMsg_SetupScriptedPrintPreview)
// Tell the browser to show the print preview, when the document is sufficiently
// loaded such that the renderer can determine whether it is modifiable or not.
IPC_MESSAGE_ROUTED1(PrintHostMsg_ShowScriptedPrintPreview,
bool /* is_modifiable */)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
|