Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: android_webview/common/print_messages.h

Issue 822133003: Refactor webview to use //components/printing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // IPC messages for printing.
6 // Multiply-included message file, hence no include guard.
7
8 // TODO(sgurun) copied from chrome/common. Remove after crbug.com/322276
9
10 #include <string>
11 #include <vector>
12
13 #include "base/memory/shared_memory.h"
14 #include "base/values.h"
15 #include "ipc/ipc_message_macros.h"
16 #include "printing/page_size_margins.h"
17 #include "printing/print_job_constants.h"
18 #include "third_party/WebKit/public/web/WebPrintScalingOption.h"
19 #include "ui/gfx/geometry/rect.h"
20 #include "ui/gfx/ipc/gfx_param_traits.h"
21 #include "ui/gfx/native_widget_types.h"
22
23 #ifndef AW_COMMON_PRINT_MESSAGES_H_
24 #define AW_COMMON_PRINT_MESSAGES_H_
25
26 struct PrintMsg_Print_Params {
27 PrintMsg_Print_Params();
28 ~PrintMsg_Print_Params();
29
30 // Resets the members of the struct to 0.
31 void Reset();
32
33 gfx::Size page_size;
34 gfx::Size content_size;
35 gfx::Rect printable_area;
36 int margin_top;
37 int margin_left;
38 double dpi;
39 double min_shrink;
40 double max_shrink;
41 int desired_dpi;
42 int document_cookie;
43 bool selection_only;
44 bool supports_alpha_blend;
45 int32 preview_ui_id;
46 int preview_request_id;
47 bool is_first_request;
48 blink::WebPrintScalingOption print_scaling_option;
49 bool print_to_pdf;
50 bool display_header_footer;
51 base::string16 title;
52 base::string16 url;
53 bool should_print_backgrounds;
54 };
55
56 struct PrintMsg_PrintPages_Params {
57 PrintMsg_PrintPages_Params();
58 ~PrintMsg_PrintPages_Params();
59
60 // Resets the members of the struct to 0.
61 void Reset();
62
63 PrintMsg_Print_Params params;
64 std::vector<int> pages;
65 };
66
67 struct PrintHostMsg_RequestPrintPreview_Params {
68 PrintHostMsg_RequestPrintPreview_Params();
69 ~PrintHostMsg_RequestPrintPreview_Params();
70 bool is_modifiable;
71 bool webnode_only;
72 bool has_selection;
73 bool selection_only;
74 };
75
76 #endif // AW_COMMON_PRINT_MESSAGES_H_
77
78 #define IPC_MESSAGE_START PrintMsgStart
79
80 IPC_ENUM_TRAITS_MAX_VALUE(printing::MarginType,
81 printing::MarginType::MARGIN_TYPE_LAST)
82
83 IPC_ENUM_TRAITS_MAX_VALUE(
84 blink::WebPrintScalingOption,
85 blink::WebPrintScalingOption::WebPrintScalingOptionLast)
86
87 // Parameters for a render request.
88 IPC_STRUCT_TRAITS_BEGIN(PrintMsg_Print_Params)
89 // Physical size of the page, including non-printable margins,
90 // in pixels according to dpi.
91 IPC_STRUCT_TRAITS_MEMBER(page_size)
92
93 // In pixels according to dpi_x and dpi_y.
94 IPC_STRUCT_TRAITS_MEMBER(content_size)
95
96 // Physical printable area of the page in pixels according to dpi.
97 IPC_STRUCT_TRAITS_MEMBER(printable_area)
98
99 // The y-offset of the printable area, in pixels according to dpi.
100 IPC_STRUCT_TRAITS_MEMBER(margin_top)
101
102 // The x-offset of the printable area, in pixels according to dpi.
103 IPC_STRUCT_TRAITS_MEMBER(margin_left)
104
105 // Specifies dots per inch.
106 IPC_STRUCT_TRAITS_MEMBER(dpi)
107
108 // Minimum shrink factor. See PrintSettings::min_shrink for more information.
109 IPC_STRUCT_TRAITS_MEMBER(min_shrink)
110
111 // Maximum shrink factor. See PrintSettings::max_shrink for more information.
112 IPC_STRUCT_TRAITS_MEMBER(max_shrink)
113
114 // Desired apparent dpi on paper.
115 IPC_STRUCT_TRAITS_MEMBER(desired_dpi)
116
117 // Cookie for the document to ensure correctness.
118 IPC_STRUCT_TRAITS_MEMBER(document_cookie)
119
120 // Should only print currently selected text.
121 IPC_STRUCT_TRAITS_MEMBER(selection_only)
122
123 // Does the printer support alpha blending?
124 IPC_STRUCT_TRAITS_MEMBER(supports_alpha_blend)
125
126 // *** Parameters below are used only for print preview. ***
127
128 // The print preview ui associated with this request.
129 IPC_STRUCT_TRAITS_MEMBER(preview_ui_id)
130
131 // The id of the preview request.
132 IPC_STRUCT_TRAITS_MEMBER(preview_request_id)
133
134 // True if this is the first preview request.
135 IPC_STRUCT_TRAITS_MEMBER(is_first_request)
136
137 // Specifies the page scaling option for preview printing.
138 IPC_STRUCT_TRAITS_MEMBER(print_scaling_option)
139
140 // True if print to pdf is requested.
141 IPC_STRUCT_TRAITS_MEMBER(print_to_pdf)
142
143 // Specifies if the header and footer should be rendered.
144 IPC_STRUCT_TRAITS_MEMBER(display_header_footer)
145
146 // Title string to be printed as header if requested by the user.
147 IPC_STRUCT_TRAITS_MEMBER(title)
148
149 // URL string to be printed as footer if requested by the user.
150 IPC_STRUCT_TRAITS_MEMBER(url)
151
152 // True if print backgrounds is requested by the user.
153 IPC_STRUCT_TRAITS_MEMBER(should_print_backgrounds)
154 IPC_STRUCT_TRAITS_END()
155
156 IPC_STRUCT_BEGIN(PrintMsg_PrintPage_Params)
157 // Parameters to render the page as a printed page. It must always be the same
158 // value for all the document.
159 IPC_STRUCT_MEMBER(PrintMsg_Print_Params, params)
160
161 // The page number is the indicator of the square that should be rendered
162 // according to the layout specified in PrintMsg_Print_Params.
163 IPC_STRUCT_MEMBER(int, page_number)
164 IPC_STRUCT_END()
165
166 IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_RequestPrintPreview_Params)
167 IPC_STRUCT_TRAITS_MEMBER(is_modifiable)
168 IPC_STRUCT_TRAITS_MEMBER(webnode_only)
169 IPC_STRUCT_TRAITS_MEMBER(has_selection)
170 IPC_STRUCT_TRAITS_MEMBER(selection_only)
171 IPC_STRUCT_TRAITS_END()
172
173 IPC_STRUCT_TRAITS_BEGIN(printing::PageSizeMargins)
174 IPC_STRUCT_TRAITS_MEMBER(content_width)
175 IPC_STRUCT_TRAITS_MEMBER(content_height)
176 IPC_STRUCT_TRAITS_MEMBER(margin_left)
177 IPC_STRUCT_TRAITS_MEMBER(margin_right)
178 IPC_STRUCT_TRAITS_MEMBER(margin_top)
179 IPC_STRUCT_TRAITS_MEMBER(margin_bottom)
180 IPC_STRUCT_TRAITS_END()
181
182 IPC_STRUCT_TRAITS_BEGIN(PrintMsg_PrintPages_Params)
183 // Parameters to render the page as a printed page. It must always be the same
184 // value for all the document.
185 IPC_STRUCT_TRAITS_MEMBER(params)
186
187 // If empty, this means a request to render all the printed pages.
188 IPC_STRUCT_TRAITS_MEMBER(pages)
189 IPC_STRUCT_TRAITS_END()
190
191 // Parameters to describe a rendered document.
192 IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params)
193 // True when we can reuse existing preview data. |metafile_data_handle| and
194 // |data_size| should not be used when this is true.
195 IPC_STRUCT_MEMBER(bool, reuse_existing_data)
196
197 // A shared memory handle to metafile data.
198 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
199
200 // Size of metafile data.
201 IPC_STRUCT_MEMBER(uint32, data_size)
202
203 // Cookie for the document to ensure correctness.
204 IPC_STRUCT_MEMBER(int, document_cookie)
205
206 // Store the expected pages count.
207 IPC_STRUCT_MEMBER(int, expected_pages_count)
208
209 // Whether the preview can be modified.
210 IPC_STRUCT_MEMBER(bool, modifiable)
211
212 // The id of the preview request.
213 IPC_STRUCT_MEMBER(int, preview_request_id)
214 IPC_STRUCT_END()
215
216 // Parameters to describe a rendered preview page.
217 IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewPage_Params)
218 // A shared memory handle to metafile data for a draft document of the page.
219 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
220
221 // Size of metafile data.
222 IPC_STRUCT_MEMBER(uint32, data_size)
223
224 // |page_number| is zero-based and can be |printing::INVALID_PAGE_INDEX| if it
225 // is just a check.
226 IPC_STRUCT_MEMBER(int, page_number)
227
228 // The id of the preview request.
229 IPC_STRUCT_MEMBER(int, preview_request_id)
230 IPC_STRUCT_END()
231
232 // Parameters sent along with the page count.
233 IPC_STRUCT_BEGIN(PrintHostMsg_DidGetPreviewPageCount_Params)
234 // Cookie for the document to ensure correctness.
235 IPC_STRUCT_MEMBER(int, document_cookie)
236
237 // Total page count.
238 IPC_STRUCT_MEMBER(int, page_count)
239
240 // Indicates whether the previewed document is modifiable.
241 IPC_STRUCT_MEMBER(bool, is_modifiable)
242
243 // The id of the preview request.
244 IPC_STRUCT_MEMBER(int, preview_request_id)
245
246 // Indicates whether the existing preview data needs to be cleared or not.
247 IPC_STRUCT_MEMBER(bool, clear_preview_data)
248 IPC_STRUCT_END()
249
250 // Parameters to describe a rendered page.
251 IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintPage_Params)
252 // A shared memory handle to the EMF data. This data can be quite large so a
253 // memory map needs to be used.
254 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
255
256 // Size of the metafile data.
257 IPC_STRUCT_MEMBER(uint32, data_size)
258
259 // Cookie for the document to ensure correctness.
260 IPC_STRUCT_MEMBER(int, document_cookie)
261
262 // Page number.
263 IPC_STRUCT_MEMBER(int, page_number)
264
265 // Shrink factor used to render this page.
266 IPC_STRUCT_MEMBER(double, actual_shrink)
267
268 // The size of the page the page author specified.
269 IPC_STRUCT_MEMBER(gfx::Size, page_size)
270
271 // The printable area the page author specified.
272 IPC_STRUCT_MEMBER(gfx::Rect, content_area)
273 IPC_STRUCT_END()
274
275 // Parameters for the IPC message ViewHostMsg_ScriptedPrint
276 IPC_STRUCT_BEGIN(PrintHostMsg_ScriptedPrint_Params)
277 IPC_STRUCT_MEMBER(int, cookie)
278 IPC_STRUCT_MEMBER(int, expected_pages_count)
279 IPC_STRUCT_MEMBER(bool, has_selection)
280 IPC_STRUCT_MEMBER(printing::MarginType, margin_type)
281 IPC_STRUCT_END()
282
283
284 // Messages sent from the browser to the renderer.
285
286 // Tells the render view to initiate print preview for the entire document.
287 IPC_MESSAGE_ROUTED1(PrintMsg_InitiatePrintPreview, bool /* selection_only */)
288
289 // Tells the render frame to initiate printing or print preview for a particular
290 // node, depending on which mode the render frame is in.
291 IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu)
292
293 // Tells the renderer to print the print preview tab's PDF plugin without
294 // showing the print dialog. (This is the final step in the print preview
295 // workflow.)
296 IPC_MESSAGE_ROUTED1(PrintMsg_PrintForPrintPreview,
297 base::DictionaryValue /* settings */)
298
299 // Tells the render view to switch the CSS to print media type, renders every
300 // requested pages and switch back the CSS to display media type.
301 IPC_MESSAGE_ROUTED0(PrintMsg_PrintPages)
302
303 // Tells the render view that printing is done so it can clean up.
304 IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone,
305 bool /* success */)
306
307 // Tells the render view whether scripted printing is blocked or not.
308 IPC_MESSAGE_ROUTED1(PrintMsg_SetScriptedPrintingBlocked,
309 bool /* blocked */)
310
311 // Tells the render view to switch the CSS to print media type, renders every
312 // requested pages for print preview using the given |settings|. This gets
313 // called multiple times as the user updates settings.
314 IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview,
315 base::DictionaryValue /* settings */)
316
317 // Like PrintMsg_PrintPages, but using the print preview document's frame/node.
318 IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog)
319
320 // Tells a renderer to stop blocking script initiated printing.
321 IPC_MESSAGE_ROUTED0(PrintMsg_ResetScriptedPrintCount)
322
323 // Messages sent from the renderer to the browser.
324
325 #if defined(OS_WIN)
326 // Duplicates a shared memory handle from the renderer to the browser. Then
327 // the renderer can flush the handle.
328 IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_DuplicateSection,
329 base::SharedMemoryHandle /* renderer handle */,
330 base::SharedMemoryHandle /* browser handle */)
331 #endif
332
333 // Check if printing is enabled.
334 IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_IsPrintingEnabled,
335 bool /* is_enabled */)
336
337 // Tells the browser that the renderer is done calculating the number of
338 // rendered pages according to the specified settings.
339 IPC_MESSAGE_ROUTED2(PrintHostMsg_DidGetPrintedPagesCount,
340 int /* rendered document cookie */,
341 int /* number of rendered pages */)
342
343 // Sends the document cookie of the current printer query to the browser.
344 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidGetDocumentCookie,
345 int /* rendered document cookie */)
346
347 // Tells the browser that the print dialog has been shown.
348 IPC_MESSAGE_ROUTED0(PrintHostMsg_DidShowPrintDialog)
349
350 // Sends back to the browser the rendered "printed page" that was requested by
351 // a ViewMsg_PrintPage message or from scripted printing. The memory handle in
352 // this message is already valid in the browser process.
353 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidPrintPage,
354 PrintHostMsg_DidPrintPage_Params /* page content */)
355
356 // The renderer wants to know the default print settings.
357 IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_GetDefaultPrintSettings,
358 PrintMsg_Print_Params /* default_settings */)
359
360 // The renderer wants to update the current print settings with new
361 // |job_settings|.
362 IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_UpdatePrintSettings,
363 int /* document_cookie */,
364 base::DictionaryValue /* job_settings */,
365 PrintMsg_PrintPages_Params /* current_settings */)
366
367 // It's the renderer that controls the printing process when it is generated
368 // by javascript. This step is about showing UI to the user to select the
369 // final print settings. The output parameter is the same as
370 // ViewMsg_PrintPages which is executed implicitly.
371 IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_ScriptedPrint,
372 PrintHostMsg_ScriptedPrint_Params,
373 PrintMsg_PrintPages_Params
374 /* settings chosen by the user*/)
375
376 #if defined(OS_ANDROID)
377 // Asks the browser to create a temporary file for the renderer to fill
378 // in resulting PdfMetafileSkia in printing.
379 IPC_SYNC_MESSAGE_CONTROL1_2(PrintHostMsg_AllocateTempFileForPrinting,
380 int /* render_view_id */,
381 base::FileDescriptor /* temp file fd */,
382 int /* fd in browser*/)
383 IPC_MESSAGE_CONTROL2(PrintHostMsg_TempFileForPrintingWritten,
384 int /* render_view_id */,
385 int /* fd in browser */)
386 #endif
387 // Asks the browser to do print preview.
388 IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview,
389 PrintHostMsg_RequestPrintPreview_Params /* params */)
390
391 // Notify the browser the number of pages in the print preview document.
392 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidGetPreviewPageCount,
393 PrintHostMsg_DidGetPreviewPageCount_Params /* params */)
394
395 // Notify the browser of the default page layout according to the currently
396 // selected printer and page size.
397 // |printable_area_in_points| Specifies the printable area in points.
398 // |has_custom_page_size_style| is true when the printing frame has a custom
399 // page size css otherwise false.
400 IPC_MESSAGE_ROUTED3(PrintHostMsg_DidGetDefaultPageLayout,
401 printing::PageSizeMargins /* page layout in points */,
402 gfx::Rect /* printable area in points */,
403 bool /* has custom page size style */)
404
405 // Notify the browser a print preview page has been rendered.
406 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidPreviewPage,
407 PrintHostMsg_DidPreviewPage_Params /* params */)
408
409 // Asks the browser whether the print preview has been cancelled.
410 IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_CheckForCancel,
411 int32 /* PrintPreviewUI ID */,
412 int /* request id */,
413 bool /* print preview cancelled */)
414
415 // Sends back to the browser the complete rendered document (non-draft mode,
416 // used for printing) that was requested by a PrintMsg_PrintPreview message.
417 // The memory handle in this message is already valid in the browser process.
418 IPC_MESSAGE_ROUTED1(PrintHostMsg_MetafileReadyForPrinting,
419 PrintHostMsg_DidPreviewDocument_Params /* params */)
420
421 // Tell the browser printing failed.
422 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed,
423 int /* document cookie */)
424
425 // Tell the browser print preview failed.
426 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewFailed,
427 int /* document cookie */)
428
429 // Tell the browser print preview was cancelled.
430 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewCancelled,
431 int /* document cookie */)
432
433 // Tell the browser print preview found the selected printer has invalid
434 // settings (which typically caused by disconnected network printer or printer
435 // driver is bogus).
436 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewInvalidPrinterSettings,
437 int /* document cookie */)
438
439 // Run a nested message loop in the renderer until print preview for
440 // window.print() finishes.
441 IPC_SYNC_MESSAGE_ROUTED0_0(PrintHostMsg_SetupScriptedPrintPreview)
442
443 // Tell the browser to show the print preview, when the document is sufficiently
444 // loaded such that the renderer can determine whether it is modifiable or not.
445 IPC_MESSAGE_ROUTED1(PrintHostMsg_ShowScriptedPrintPreview,
446 bool /* is_modifiable */)
447
448 // Notify the browser that the PDF in the initiator renderer has disabled print
449 // scaling option.
450 IPC_MESSAGE_ROUTED0(PrintHostMsg_PrintPreviewScalingDisabled)
OLDNEW
« no previous file with comments | « android_webview/common/android_webview_message_generator.h ('k') | android_webview/common/print_messages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698