// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module printing.mojom;
import "mojo/public/mojom/base/shared_memory.mojom";
import "printing/mojom/print.mojom";
import "sandbox/policy/mojom/sandbox.mojom";
import "ui/accessibility/mojom/ax_tree_update.mojom";
import "url/mojom/url.mojom";
[ServiceSandbox=sandbox.mojom.Sandbox.kPrintCompositor]
interface PrintCompositor {
// The status of composition and conversion execution.
enum Status {
kSuccess = 0,
kHandleMapError = 1,
kContentFormatError = 2,
kCompositingFailure = 3,
};
enum DocumentType {
kPDF = 0,
kXPS = 1,
};
// Notifies that a subframe is unavailable, such as the render frame process
// hosting it crashed or terminated. The subframe will be composited with no
// content in the composited result.
// `frame_guid` is this subframe's global unique id.
NotifyUnavailableSubframe(uint64 frame_guid);
// Adds the content of a subframe for composition.
// `frame_guid` is this subframe's global unique id.
// `serialized_content` is a buffer of a serialized Skia picture which
// has the painted content of this frame.
// `subframe_content_map` records content id and its corresponding frame's
// global unique id.
AddSubframeContent(
uint64 frame_guid,
mojo_base.mojom.ReadOnlySharedMemoryRegion serialized_content,
map<uint32, uint64> subframe_content_info);
// Sets the accessibility tree for the overall document. This is needed
// to generate tagged (accessible) PDFs.
//
// TODO(crbug.com/40727460): AXTreeUpdate can be quite large, hence the
// [UnlimitedSize] tag. It may be possible to remove this if AXTreeUpdate
// can be reworked to avoid very large serialized values.
[UnlimitedSize]
SetAccessibilityTree(ax.mojom.AXTreeUpdate accessibility_tree);
// Requests to composite a page and convert it into a PDF file.
// When doing concurrent document composition, this converts the page a
// second time to include it in the document provided by the call to
// `FinishDocumentComposition()`. Note that this page conversion into the
// document might be PDF or XPS.
// `frame_guid` is the global unique id of the frame to be composited.
// `sk_region` is a buffer of a Skia MultiPictureDocument which has
// the drawing content of this frame or a page of this frame.
// `subframe_content_map` records content id and its corresponding frame's
// global unique id.
CompositePage(uint64 frame_guid,
mojo_base.mojom.ReadOnlySharedMemoryRegion sk_region,
map<uint32, uint64> subframe_content_info)
=> (Status status,
mojo_base.mojom.ReadOnlySharedMemoryRegion? document_region);
// Requests to composite the entire document and convert it into a print
// document file. All the arguments carry the same meaning as
// `CompositePage()` above, except this call doesn't have `page_num`. Cannot
// be used in conjunction with `PrepareToCompositeDocument()` /
// `FinishDocumentComposition()`.
CompositeDocument(uint64 frame_guid,
mojo_base.mojom.ReadOnlySharedMemoryRegion sk_region,
map<uint32, uint64> subframe_content_info,
DocumentType document_type)
=> (Status status,
mojo_base.mojom.ReadOnlySharedMemoryRegion? document_region);
// Notifies that composition is to collect individual pages from
// `CompositePage()` concurrently into a document. Must be issued once
// prior to any `CompositePage()` calls in order for concurrent collection
// to be performed.
PrepareToCompositeDocument(DocumentType document_type)
=> (Status status);
// Signals that all pages for a composite document have been sent via
// `CompositePage()`, allowing for document composition to be wrapped up.
// Is to be used in conjunction with `PrepareToCompositeDocument()`, which
// must be made prior to this and any `CompositePage()` calls. This must be
// called exactly once to wrap up the document.
FinishDocumentComposition(uint32 pages_count)
=> (Status status,
mojo_base.mojom.ReadOnlySharedMemoryRegion? document_region);
// Tells the service what URL is committed in the main frame of the
// WebContents that is printing, for use in crash diagnosis.
SetWebContentsURL(url.mojom.Url url);
// Sets the user-agent string for the document.
SetUserAgent(string user_agent);
// Sets how to generate the document outline.
SetGenerateDocumentOutline(GenerateDocumentOutline generate_document_outline);
// Sets the title of the document.
SetTitle(string title);
};