// Copyright 2023 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 "chromeos/crosapi/mojom/download_controller.mojom";
import "mojo/public/mojom/base/file_path.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "ui/gfx/image/mojom/image.mojom";
// Indicates a download's progress.
//
// Next MinVersion: 1
// Next ID: 4
//
[Stable, Uuid="9533a4a7-962f-4723-86f1-752a12623d5a"]
struct DownloadProgress {
// Indicates whether the progress should be represented as infinitely looping.
bool loop@0;
// The total number of bytes that have been received and written to the
// underlying download file.
int64 received_bytes@1;
// The total number of bytes expected to be written to the underlying download
// file, or 0 if the total number of bytes is unknown.
int64 total_bytes@2;
// Indicates whether the progress should be visibly represented.
bool visible@3;
};
// Representation of a Lacros download's status to be passed into Ash Chrome
// and rendered in the appropriate System UI surface(s).
//
// Next MinVersion: 7
// Next ID: 13
//
[Stable, Uuid="d18b6479-e70d-44aa-b657-58ffff57735d"]
struct DownloadStatus {
// The GUID for the underlying download which uniquely identifies the download
// during its lifetime.
string guid@0;
// The current state of the underlying download.
DownloadState state@1;
// Deprecated. The total number of bytes that have been received and written
// to the underlying download file.
[MinVersion=1] int64? received_bytes_deprecated@2;
// Deprecated. The total number of bytes expected to be written to the
// underlying download file, or 0 if the total number of bytes is unknown.
[MinVersion=1] int64? total_bytes_deprecated@3;
// The target path of an in-progress download. Note that the actual path being
// written to may be that of a temporary or intermediate file, but the target
// path will be used once the underlying download completes. Also note that
// the target path may be empty if it hasn't yet been determined.
[MinVersion=1] mojo_base.mojom.FilePath? target_file_path@4;
// Path to the file being written to during an in-progress download. Empty if
// the path hasn't been determined or the download was interrupted.
// NOTE: Do NOT use this field to access the target path. Use
// `target_file_path` instead.
[MinVersion=2] mojo_base.mojom.FilePath? full_path@8;
// Whether an in-progress download can be cancelled by the user.
[MinVersion=1] bool? cancellable@5;
// Whether an in-progress download can be paused by the user.
[MinVersion=1] bool? pausable@6;
// Whether an in-progress download can be resumed by the user.
[MinVersion=1] bool? resumable@7;
// The text that indicates the underlying download's status.
[MinVersion=3] mojo_base.mojom.String16? status_text@9;
// The image representation of the underlying download.
[MinVersion=4] gfx.mojom.ImageSkia? image@10;
// Indicates the progress of the underlying download.
[MinVersion=5] DownloadProgress? progress@11;
// The icons that suggest the underlying download's status.
// TODO(http://b/328070365): Sending icons across the crosapi has some
// drawbacks (see the attached issue). Implement it in a better way.
[MinVersion=6] DownloadStatusIcons? icons@12;
};
// The icons that indicate a download's status for dark/light modes.
//
// Next MinVersion: 1
// Next ID: 2
//
// WARNING: Sending UI icons directly has drawbacks (see http://b/328070365).
// Prefer sending metadata to construct the UI instead.
[Stable, Uuid="9258a38a-0005-466c-9e5f-89516993cea6"]
struct DownloadStatusIcons {
gfx.mojom.ImageSkia dark_mode@0;
gfx.mojom.ImageSkia light_mode@1;
};
// The interface for the client of the `DownloadStatusUpdater` in Ash Chrome
// which is implemented in Lacros Chrome.
//
// Next MinVersion: 1
// Next ID: 4
//
[Stable, Uuid="a62293a0-4404-42d3-9bb6-0f0232ddf1af"]
interface DownloadStatusUpdaterClient {
// Invoked to cancel the download associated with the specified `guid`.
// Asynchronously returns whether the command was handled successfully.
Cancel@0(string guid) => (bool handled);
// Invoked to pause the download associated with the specified `guid`.
// Asynchronously returns whether the command was handled successfully.
Pause@1(string guid) => (bool handled);
// Invoked to resume the download associated with the specified `guid`.
// Asynchronously returns whether the command was handled successfully.
Resume@2(string guid) => (bool handled);
// Invoked to show the download associated with the specified `guid` in the
// browser. Asynchronously returns whether the command was handled
// successfully.
ShowInBrowser@3(string guid) => (bool handled);
};
// The interface which allows Lacros download status updates to be passed into
// Ash Chrome for rendering in the appropriate System UI surface(s).
//
// Next MinVersion: 2
// Next ID: 2
//
[Stable, Uuid="2f06d2a1-7c81-4418-affe-bc821f43594e"]
interface DownloadStatusUpdater {
// Invoked to bind the `client` which is implemented in Lacros Chrome.
[MinVersion=1] BindClient@1(
pending_remote<DownloadStatusUpdaterClient> client);
// Invoked when `status` for a download should be updated.
Update@0(DownloadStatus status);
};