// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module blink.mojom;
import "mojo/public/mojom/base/file_path.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/base/dragdrop/mojom/drag_drop_types.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "url/mojom/url.mojom";
import "third_party/blink/public/mojom/data_transfer/data_transfer.mojom";
import "third_party/blink/public/mojom/blob/serialized_blob.mojom";
// This struct encodes what drag-and-drop operations are allowed. It's
// typemapped to blink::DragOperationsMask.
// TODO(https://crbug.com/1082291): Change this to a bitset if/when mojom
// supports bitset types.
struct AllowedDragOperations {
bool allow_copy;
bool allow_link;
bool allow_move;
};
// Used when dragging images, links, plain text, HTML content or other
// arbitrary data.
struct DragItemString {
// Mime type of the dragged data.
string string_type;
// Depending of the value of `string_type`, it contains the dragged link,
// text, HTML markup or any other data.
mojo_base.mojom.BigString16 string_data;
// Title associated with a link. Only valid when string_type == "text/uri-list".
mojo_base.mojom.String16? title;
// Stores the base URL for the contained markup. Only valid when string_type
// == "text/html".
url.mojom.Url? base_url;
};
// Only used when dragging images out of Blink.
struct DragItemBinary {
// Image data.
mojo_base.mojom.BigBuffer data;
// True if image is same origin (or allowed crossorigin) in the source frame,
// or is being dragged to a different page.
bool is_image_accessible;
url.mojom.Url source_url;
mojo_base.mojom.FilePath filename_extension;
// Content-Disposition response header.
string? content_disposition;
};
// Used for dragging files using the FileSystem API.
struct DragItemFileSystemFile {
url.mojom.Url url;
int64 size;
string? file_system_id;
// `serialized_blob` is only set for drop operations.
SerializedBlob? serialized_blob;
};
union DragItem {
DragItemString string;
DataTransferFile file;
DragItemBinary binary;
DragItemFileSystemFile file_system_file;
};
// Holds data that may be exchanged through a drag-n-drop operation.
struct DragData {
array<DragItem> items;
string? file_system_id; // Only used when dragging into Blink to represent a
// new isolated file system to access the dropped
// files.
// If true, the renderer always performs the default action for the drop, such
// as opening a dragged URL in a new tab. Otherwise, the renderer may give the
// drag data to the page if it has overridden the default action.
//
// This value is calculated using the last drag operation reported from a
// dragover response from the document, via the renderer, to the browser. Due
// to the async nature of the browser-renderer interaction, it's possible for
// a document's signal of interest in a drop to not be received by the browser
// before it starts to finish the drop. In this case the browser will pass
// the drop data to the renderer, but the renderer will take a default action
// instead of passing the drop to the document.
bool force_default_action;
// Used for DragItemString when string_type == "downloadurl".
network.mojom.ReferrerPolicy referrer_policy =
network.mojom.ReferrerPolicy.kDefault;
};
// Information about the event that started a drag session.
struct DragEventSourceInfo {
gfx.mojom.Point location;
ui.mojom.DragEventSource source;
};