blob: f3c284e8c9c92501cc36bbbe9470415ebd48ca05 [file] [log] [blame]
// Copyright 2021 The Chromium Authors. All rights reserved.
// 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/file_path.mojom";
// This mirrors `download::DownloadItem::DownloadState`, anything added or
// removed here must also be added or removed there.
[Stable, Extensible]
enum DownloadState {
[Default] kUnknown = 0,
kInProgress,
kComplete,
kCancelled,
kInterrupted
};
// This mirrors `download::DownloadItem`. See:
// https://source.chromium.org/chromium/chromium/src/+/main:components/download/public/common/download_item.h?q=download_item.h
//
// NOTE: Starting in Version 1, `has_field` is added for every new
// non-nullable `field`. This is for backwards compatibility, so that older
// clients know when values are present or are absent by default.
//
// Next MinVersion: 2
// Next ID: 13
[Stable]
struct DownloadEvent {
DownloadState state@0;
mojo_base.mojom.FilePath target_file_path@1;
bool is_from_incognito_profile@2;
[MinVersion=1] string? guid@3;
[MinVersion=1] mojo_base.mojom.FilePath? full_path@4;
[MinVersion=1] bool has_is_paused@5;
[MinVersion=1] bool is_paused@6;
[MinVersion=1] bool has_open_when_complete@7;
[MinVersion=1] bool open_when_complete@8;
[MinVersion=1] bool has_received_bytes@9;
[MinVersion=1] int64 received_bytes@10;
[MinVersion=1] bool has_total_bytes@11;
[MinVersion=1] int64 total_bytes@12;
};
// A client implemented in lacros-chrome for the DownloadController which is
// implemented in ash-chrome.
[Stable, Uuid="eccf720b-538a-4943-a6fd-d073639c4140"]
interface DownloadControllerClient {
// Pauses the download associated with the specified `download_guid`. This
// method will ultimately invoke `download::DownloadItem::Pause()`.
Pause@1(string download_guid);
// Resumes the download associated with the specified `download_guid`. If
// `user_resume` is set to `true`, it signifies that this invocation was
// triggered by an explicit user action. This method will ultimately invoke
// `download::DownloadItem::Resume()`.
Resume@2(string download_guid, bool user_resume);
// Cancels the download associated with the specified `download_guid`. If
// `user_cancel` is set to `true`, it signifies that this invocation was
// triggered by an explicit user action. This method will ultimately invoke
// `download::DownloadItem::Cancel()`.
Cancel@3(string download_guid, bool user_cancel);
// Marks the download associated with the specified `download_guid` to be
// `open_when_complete`. This method will ultimately invoke
// `download::DownloadItem::SetOpenWhenComplete()`.
SetOpenWhenComplete@4(string download_guid, bool open_when_complete);
};
// Allows lacros to pass download information to ash-chrome.
// Implemented in ash-chrome.
//
// Next MinVersion: 2
// Next ID: 4
[Stable, Uuid="c3d8bd4b-1fc9-4529-aeb2-76770b0ad1c3"]
interface DownloadController {
// Binds the DownloadControllerClient interface, which allows the
// DownloadController implemented in ash-chrome to communicate with its client
// which is implemented in lacros-chrome.
[MinVersion=1] BindClient@3(
pending_remote<DownloadControllerClient> client);
// Called when a download is created. Comes from `content::DownloadManager`,
// and will only pass events once that's initialized.
OnDownloadCreated@0(crosapi.mojom.DownloadEvent event);
// Called whenever a `download::DownloadItem` is updated.
OnDownloadUpdated@1(crosapi.mojom.DownloadEvent event);
// Called when a `download::DownloadItem` is destroyed.
OnDownloadDestroyed@2(crosapi.mojom.DownloadEvent event);
};