1// Copyright 2019 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 5module printing.mojom; 6 7import "mojo/public/mojom/base/shared_memory.mojom"; 8import "mojo/public/mojom/base/values.mojom"; 9import "ui/gfx/geometry/mojom/geometry.mojom"; 10 11// Parameters required to print the content of an out-of-process subframe. 12struct PrintFrameContentParams { 13 // Physical printable area of the page in pixels according to dpi. 14 gfx.mojom.Rect printable_area; 15 16 // Cookie that is unique for each print request. It is used to associate the 17 // printed frame with its original print request. 18 int32 document_cookie; 19}; 20 21// Interface implemented by a class that desires to render print documents for 22// Chrome print preview. 23interface PrintRenderer { 24 // Creates a preview document for print preview using the provided 25 // |job_settings|. 26 // The returned |preview_document_region| contains the preview document data 27 // as a flattened PDF. It will be invalid if errors occurred while rendering 28 // the preview document. 29 CreatePreviewDocument(mojo_base.mojom.DictionaryValue job_settings) 30 => (mojo_base.mojom.ReadOnlySharedMemoryRegion? preview_document_region); 31}; 32 33// Render process interface exposed to the browser to handle most of the 34// printing grunt work for RenderView. 35interface PrintRenderFrame { 36 // Tells the RenderFrame to switch the CSS to print media type, render every 37 // requested page, and then switch back the CSS to display media type. 38 PrintRequestedPages(); 39 40 // Tells the RenderFrame to switch the CSS to print media type, render every 41 // requested page using the print preview document's frame/node, and then 42 // switch the CSS back to display media type. 43 PrintForSystemDialog(); 44 45 // Tells the RenderFrame to initiate print preview for the entire document. 46 // Optionally provides a |print_renderer| to render print documents. 47 [EnableIf=enable_print_preview] 48 InitiatePrintPreview(pending_associated_remote<PrintRenderer>? print_renderer, 49 bool has_selection); 50 51 // Tells the RenderFrame to switch the CSS to print media type and render 52 // every requested page for print preview using the given |settings|. This 53 // gets called multiple times as the user updates settings. 54 [EnableIf=enable_print_preview] 55 PrintPreview(mojo_base.mojom.DictionaryValue settings); 56 57 // Tells the RenderFrame that the print preview dialog was closed. 58 [EnableIf=enable_print_preview] 59 OnPrintPreviewDialogClosed(); 60 61 // Prints the content of an out-of-process subframe. 62 PrintFrameContent(PrintFrameContentParams params); 63 64 // Tells the RenderFrame whether printing is enabled or not. 65 SetPrintingEnabled(bool enabled); 66 67 // Tells the RenderFrame that printing is done so it can clean up. 68 PrintingDone(bool success); 69 70 // Tells the RenderFrame to initiate printing or print preview for a 71 // particular node, depending on which mode the RenderFrame is in. 72 PrintNodeUnderContextMenu(); 73}; 74