| // 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 pdf.mojom; |
| |
| import "mojo/public/mojom/base/big_buffer.mojom"; |
| import "mojo/public/mojom/base/string16.mojom"; |
| import "services/network/public/mojom/referrer_policy.mojom"; |
| import "ui/gfx/geometry/mojom/geometry.mojom"; |
| import "url/mojom/url.mojom"; |
| |
| // Must match `SaveRequestType` in |
| // `chrome/common/extensions/api/pdf_viewer_private.idl` and |
| // `tools/typescript/definitions/pdf_viewer_private.d.ts`. |
| enum SaveRequestType { |
| kAnnotation = 0, |
| kOriginal = 1, |
| kEdited = 2, |
| kSearchified = 3, |
| }; |
| |
| // Returns by `GetSaveDataBufferHandlerForDrive()`. `handler` is the handler |
| // to read the data to save to Google Drive. `total_file_size` is the total file |
| // size to save. |
| [EnableIf=enable_pdf_save_to_drive] |
| struct SaveDataBufferHandlerGetResult { |
| pending_remote<SaveDataBufferHandler> handler; |
| uint32 total_file_size; |
| }; |
| |
| // Interface for reading the PDF data to save to Google Drive. |
| [EnableIf=enable_pdf_save_to_drive] |
| interface SaveDataBufferHandler { |
| // Returns `block_size` bytes to save the PDF to Google Drive starting from |
| // location `offset`. |
| Read(uint32 offset, uint32 block_size) => (mojo_base.mojom.BigBuffer block); |
| }; |
| |
| interface PdfListener { |
| // Sets the current caret position. |
| SetCaretPosition(gfx.mojom.PointF position); |
| |
| // Move the end of the range selection to |extent|. |
| MoveRangeSelectionExtent(gfx.mojom.PointF extent); |
| |
| // Sets the selection to be between |base| and |extent|. The |extent| will |
| // be moved if the selection is modified. |
| SetSelectionBounds(gfx.mojom.PointF base, gfx.mojom.PointF extent); |
| |
| // The status of the GetPdfBytes call. |
| enum GetPdfBytesStatus { |
| kSuccess = 0, |
| kSizeLimitExceeded = 1, |
| kFailed = 2, |
| }; |
| |
| // Get PDF bytes. If the size of the PDF in bytes is larger than `size_limit`, |
| // an empty vector will be returned instead. `bytes` is only guaranteed to be |
| // from the PDF engine if `status` is `kSuccess`. `page_count` is the number |
| // of pages in the PDF displayed in the renderer, not the number of pages |
| // returned in `bytes`. |
| GetPdfBytes(uint32 size_limit) |
| => (GetPdfBytesStatus status, array<uint8> bytes, uint32 page_count); |
| |
| // Get the text contained on the given page of the PDF. `page_index` should be |
| // the range [0, # of pages). |
| GetPageText(int32 page_index) => (mojo_base.mojom.String16 text); |
| |
| // Returns the index of the most visible page. If no page is visible, |
| // returns nullopt. |
| GetMostVisiblePageIndex() => (uint32? page_index); |
| |
| // Returns a `SaveDataBufferHandler` and the total file size to read the data |
| // to save to Google Drive. Once the handler is acquired, caller can read the |
| // data by calling `Read`. If the file is larger than INT_MAX size, returns |
| // nullptr. |
| [EnableIf=enable_pdf_save_to_drive] |
| GetSaveDataBufferHandlerForDrive(SaveRequestType request_type) |
| => (SaveDataBufferHandlerGetResult? result); |
| }; |
| |
| // Browser-side interface used by PDF renderers. |
| interface PdfHost { |
| SetListener(pending_remote<PdfListener> client); |
| |
| // Invoked when document load is completed successfully. Will not be invoked |
| // if the load fails. |
| OnDocumentLoadComplete(); |
| |
| // Updates the content restrictions, i.e. to disable print/copy. |
| UpdateContentRestrictions(int32 restrictions); |
| |
| // Brings up SaveAs... dialog to save specified URL. |
| SaveUrlAs(url.mojom.Url url, network.mojom.ReferrerPolicy policy); |
| |
| // Notifies the embedder of the top-left and bottom-right coordinates of the |
| // current selection. |
| SelectionChanged(gfx.mojom.PointF left, |
| int32 left_height, |
| gfx.mojom.PointF right, |
| int32 right_height); |
| |
| // Notifies the embedder know the plugin can handle save commands internally. |
| SetPluginCanSave(bool can_save); |
| |
| // Notifies that PDF searchifier has started processing pages. This should be |
| // called at most once. |
| [EnableIf=enable_screen_ai_service] |
| OnSearchifyStarted(); |
| }; |