download_controller.mojom 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. module crosapi.mojom;
  5. import "mojo/public/mojom/base/file_path.mojom";
  6. import "mojo/public/mojom/base/time.mojom";
  7. // This mirrors `download::DownloadItem::DownloadState`, anything added or
  8. // removed here must also be added or removed there.
  9. [Stable, Extensible]
  10. enum DownloadState {
  11. [Default] kUnknown = 0,
  12. kInProgress,
  13. kComplete,
  14. kCancelled,
  15. kInterrupted
  16. };
  17. // This mirrors `download::DownloadDangerType`, anything added or removed here
  18. // must also be added or removed there.
  19. [Stable, Extensible]
  20. enum DownloadDangerType {
  21. [Default] kDownloadDangerTypeInvalid = -1,
  22. kDownloadDangerTypeNotDangerous = 0,
  23. kDownloadDangerTypeDangerousFile = 1,
  24. kDownloadDangerTypeDangerousUrl = 2,
  25. kDownloadDangerTypeDangerousContent = 3,
  26. kDownloadDangerTypeMaybeDangerousContent = 4,
  27. kDownloadDangerTypeUncommonContent = 5,
  28. kDownloadDangerTypeUserValidated = 6,
  29. kDownloadDangerTypeDangerousHost = 7,
  30. kDownloadDangerTypePotentiallyUnwanted = 8,
  31. kDownloadDangerTypeAllowlistedByPolicy = 9,
  32. kDownloadDangerTypeAsyncScanning = 10,
  33. kDownloadDangerTypeBlockedPasswordProtected = 11,
  34. kDownloadDangerTypeBlockedTooLarge = 12,
  35. kDownloadDangerTypeSensitiveContentWarning = 13,
  36. kDownloadDangerTypeSensitiveContentBlock = 14,
  37. kDownloadDangerTypeDeepScannedSafe = 15,
  38. kDownloadDangerTypeDeepScannedOpenedDangerous = 16,
  39. kDownloadDangerTypePromptForScanning = 17,
  40. kDownloadDangerTypeBlockedUnsupportedFiletype = 18,
  41. kDownloadDangerTypeDangerousAccountCompromise = 19,
  42. };
  43. // This mirrors `download::DownloadItem::MixedContentStatus`, anything added or
  44. // removed here must also be added or removed there.
  45. [Stable, Extensible]
  46. enum DownloadMixedContentStatus {
  47. [Default] kInvalid = -1,
  48. kUnknown = 0,
  49. kSafe = 1,
  50. kValidated = 2,
  51. kWarn = 3,
  52. kBlock = 4,
  53. kSilentBlock = 5,
  54. };
  55. // This mirrors `download::DownloadItem`. See:
  56. // https://source.chromium.org/chromium/chromium/src/+/main:components/download/public/common/download_item.h?q=download_item.h
  57. //
  58. // NOTE: Starting in Version 1, `has_field` is added for every new
  59. // non-nullable `field`. This is for backwards compatibility, so that older
  60. // clients know when values are present or are absent by default.
  61. //
  62. // Next MinVersion: 5
  63. // Next ID: 20
  64. [Stable, RenamedFrom="crosapi.mojom.DownloadEvent"]
  65. struct DownloadItem {
  66. DownloadState state@0;
  67. mojo_base.mojom.FilePath target_file_path@1;
  68. bool is_from_incognito_profile@2;
  69. [MinVersion=1] string? guid@3;
  70. [MinVersion=1] mojo_base.mojom.FilePath? full_path@4;
  71. [MinVersion=1] bool has_is_paused@5;
  72. [MinVersion=1] bool is_paused@6;
  73. [MinVersion=1] bool has_open_when_complete@7;
  74. [MinVersion=1] bool open_when_complete@8;
  75. [MinVersion=1] bool has_received_bytes@9;
  76. [MinVersion=1] int64 received_bytes@10;
  77. [MinVersion=1] bool has_total_bytes@11;
  78. [MinVersion=1] int64 total_bytes@12;
  79. [MinVersion=2] mojo_base.mojom.Time? start_time@13;
  80. [MinVersion=3] bool has_is_dangerous@14;
  81. [MinVersion=3] bool is_dangerous@15;
  82. [MinVersion=3] bool has_is_mixed_content@16;
  83. [MinVersion=3] bool is_mixed_content@17;
  84. [MinVersion=4] DownloadDangerType danger_type@18;
  85. [MinVersion=4] DownloadMixedContentStatus mixed_content_status@19;
  86. };
  87. // A client implemented in lacros-chrome for the DownloadController which is
  88. // implemented in ash-chrome.
  89. //
  90. // Next MinVersion: 2
  91. // Next ID: 6
  92. [Stable, Uuid="eccf720b-538a-4943-a6fd-d073639c4140"]
  93. interface DownloadControllerClient {
  94. // Returns all downloads, no matter the type or state, sorted chronologically
  95. // by start time. This method will ultimately invoke
  96. // `download::SimpleDownloadManager::GetAllDownloads()`.
  97. [MinVersion=1] GetAllDownloads@5() => (array<DownloadItem> downloads);
  98. // Pauses the download associated with the specified `download_guid`. This
  99. // method will ultimately invoke `download::DownloadItem::Pause()`.
  100. Pause@1(string download_guid);
  101. // Resumes the download associated with the specified `download_guid`. If
  102. // `user_resume` is set to `true`, it signifies that this invocation was
  103. // triggered by an explicit user action. This method will ultimately invoke
  104. // `download::DownloadItem::Resume()`.
  105. Resume@2(string download_guid, bool user_resume);
  106. // Cancels the download associated with the specified `download_guid`. If
  107. // `user_cancel` is set to `true`, it signifies that this invocation was
  108. // triggered by an explicit user action. This method will ultimately invoke
  109. // `download::DownloadItem::Cancel()`.
  110. Cancel@3(string download_guid, bool user_cancel);
  111. // Marks the download associated with the specified `download_guid` to be
  112. // `open_when_complete`. This method will ultimately invoke
  113. // `download::DownloadItem::SetOpenWhenComplete()`.
  114. SetOpenWhenComplete@4(string download_guid, bool open_when_complete);
  115. };
  116. // Allows lacros to pass download information to ash-chrome.
  117. // Implemented in ash-chrome.
  118. //
  119. // Next MinVersion: 2
  120. // Next ID: 4
  121. [Stable, Uuid="c3d8bd4b-1fc9-4529-aeb2-76770b0ad1c3"]
  122. interface DownloadController {
  123. // Binds the DownloadControllerClient interface, which allows the
  124. // DownloadController implemented in ash-chrome to communicate with its client
  125. // which is implemented in lacros-chrome.
  126. [MinVersion=1] BindClient@3(
  127. pending_remote<DownloadControllerClient> client);
  128. // Called when a download is created. Comes from `content::DownloadManager`,
  129. // and will only pass events once that's initialized.
  130. OnDownloadCreated@0(crosapi.mojom.DownloadItem download);
  131. // Called whenever a `download::DownloadItem` is updated.
  132. OnDownloadUpdated@1(crosapi.mojom.DownloadItem download);
  133. // Called when a `download::DownloadItem` is destroyed.
  134. OnDownloadDestroyed@2(crosapi.mojom.DownloadItem download);
  135. };