// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module crosapi.mojom;
import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/base/mojom/ui_base_types.mojom";
// The different ways the multipaste menu can be shown. These values are
// written to logs. New enum values can be added, but existing enums must
// never be renumbered, deleted, or reused. If adding an enum, add it at the
// bottom.
// Next MinVersion: 4
[Stable, Extensible]
enum ClipboardHistoryControllerShowSource {
// Shown by the accelerator(search + v).
kAccelerator,
// Shown by a render view's context menu.
kRenderViewContextMenu,
// Shown by a textfield context menu.
kTextfieldContextMenu,
// Shown by the virtual keyboard.
kVirtualKeyboard,
// Used as a default value in case of version skew.
[Default] kUnknown,
// Deprecated: Shown by a toast.
[MinVersion=1] kToast,
// Shown by long-pressing Ctrl+V.
[MinVersion=2] kControlVLongpress,
// Shown from the submenu embedded in a render view's context memu.
[MinVersion=3] kRenderViewContextSubmenu,
// Shown from the submenu embedded in a textfield context menu.
[MinVersion=3] kTextfieldContextSubmenu,
};
// The formats dictating how clipboard history items are displayed.
// Maps to the `ClipboardHistoryDisplayFormat` enum used in histograms. Do not
// reorder entries; append any new ones to the end.
[Stable, Extensible]
enum ClipboardHistoryDisplayFormat {
[Default] kUnknown = -1,
kText = 0,
kPng = 1,
kHtml = 2,
kFile = 3,
};
// Describes a clipboard history item.
//
// NOTE: This structure does not contain the actual clipboard data. The
// clipboard data is indicated by the `display_text` and `display_format`
// fields.
//
// The `item_id` field is a unique identifier for the clipboard history item.
//
// The `display_text` field is the text that is displayed in the clipboard
// history menu. The `display_format` field indicates the format of the
// clipboard data.
//
// The `file_count` indicates the number of files in the corresponding clipboard
// history item.
//
[Stable]
struct ClipboardHistoryItemDescriptor {
mojo_base.mojom.UnguessableToken item_id@0;
ClipboardHistoryDisplayFormat display_format@1;
mojo_base.mojom.String16 display_text@2;
uint32 file_count@3;
};
// This interface is implemented by Ash-Chrome.
// ClipboardHistory (//ash/clipboard) is an Ash-Chrome feature that shows the
// last few things copied. It is shown by accelerator and contextual menu. This
// allows Lacros-Chrome to show the ClipboardHistory menu by contextual menu.
// Next MinVersion: 3
// Next method ID: 3
[Stable, Uuid="2dc3f126-d79f-4d9e-a7a7-0989c1be8acd"]
interface ClipboardHistory {
// Shows a menu in Ash-Chrome with the last few things copied.
ShowClipboard@0(gfx.mojom.Rect anchor_point,
ui.mojom.MenuSourceType menu_source_type,
crosapi.mojom.ClipboardHistoryControllerShowSource show_source);
// Pastes the clipboard item specified by `item_id` from `paste_source`.
// No-op if:
// 1. The clipboard item specified by `item_id` does not exist; or
// 2. The clipboard history is not allowed when Ash receives the calls.
[MinVersion=1]
PasteClipboardItemById@1(
mojo_base.mojom.UnguessableToken item_id,
int32 event_flags,
ClipboardHistoryControllerShowSource paste_source);
// Registers `client` which is implemented in Lacros-Chrome so that `client`
// can receive remote calls from Ash-Chrome. Used only when the clipboard
// history refresh feature is enabled.
[MinVersion=2]
RegisterClient@2(pending_remote<ClipboardHistoryClient> client);
};
// This interface is implemented by Lacros-Chrome.
[Stable, Uuid="67a12272-d7c0-40f8-8b09-90a150787358"]
interface ClipboardHistoryClient {
// Sets the clipboard history item descriptors cached in Lacros-Chrome.
SetClipboardHistoryItemDescriptors@0(
array<ClipboardHistoryItemDescriptor> item_descriptors);
};