notification.mojom 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. // Copyright 2020 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 "chromeos/crosapi/mojom/bitmap.mojom";
  6. import "mojo/public/mojom/base/string16.mojom";
  7. import "mojo/public/mojom/base/time.mojom";
  8. import "skia/public/mojom/skcolor.mojom";
  9. import "ui/gfx/image/mojom/image.mojom";
  10. import "url/mojom/url.mojom";
  11. // Type of notification to show. See the chrome.notifications extension API:
  12. // https://developer.chrome.com/extensions/notifications#type-TemplateType
  13. [Stable, Extensible]
  14. enum NotificationType {
  15. // Icon, title and message.
  16. kSimple = 0,
  17. // Icon, title and message with a large image.
  18. kImage = 1,
  19. // List of items. Note: C++ calls this type "multiple".
  20. kList = 2,
  21. // Progress bar.
  22. kProgress = 3,
  23. };
  24. [Stable, Extensible]
  25. enum NotifierType {
  26. [Default] kApplication = 0,
  27. kArcApplication = 1,
  28. kWebPage = 2,
  29. kSystemComponent = 3,
  30. kCrostiniApplication = 4,
  31. kPhoneHub = 5,
  32. };
  33. // How to display notifications when a fullscreen window is open. For example,
  34. // a child account time limit notification should appear over a fullscreen
  35. // video.
  36. [Stable, Extensible]
  37. enum FullscreenVisibility {
  38. // Do not show over fullscreen windows.
  39. kNone = 0,
  40. // Show on top of user-created fullscreen windows.
  41. kOverUser = 1,
  42. };
  43. [Stable]
  44. struct NotifierId {
  45. NotifierType type@0;
  46. // The identifier of the app notifier. Empty if |type| is kWebPage.
  47. string id@1;
  48. url.mojom.Url? url@2;
  49. mojo_base.mojom.String16? title@3;
  50. // A unique identifier of the user profile associated with the
  51. // notification, usually an email address.
  52. string profile_id@4;
  53. };
  54. // List items for NotificationType::kList.
  55. [Stable]
  56. struct NotificationItem {
  57. mojo_base.mojom.String16 title@0;
  58. mojo_base.mojom.String16 message@1;
  59. };
  60. // Data for each button. Implemented as a struct for extensibility (e.g. so we
  61. // could add icon buttons).
  62. [Stable]
  63. struct ButtonInfo {
  64. mojo_base.mojom.String16 title@0;
  65. // The placeholder string that should be displayed in the input field for
  66. // text input type buttons until the user has entered a response themselves.
  67. // If the value is null, there is no input field associated with the button.
  68. [MinVersion=1] mojo_base.mojom.String16? placeholder@1;
  69. };
  70. // A notification to show in the system message center. Fields exist to support
  71. // both the web platform notification API and the chrome.notifications extension
  72. // API. See documentation at:
  73. // https://developer.mozilla.org/en-US/docs/Web/API/notification
  74. // https://developer.chrome.com/extensions/notifications#type-NotificationOptions
  75. //
  76. // Next MinVersion: 4
  77. // Next ID: 27
  78. [Stable]
  79. struct Notification {
  80. // Type of notification to show.
  81. NotificationType type@0;
  82. // The client decides the format of the ID.
  83. string id@1;
  84. // The title, usually just a few words.
  85. mojo_base.mojom.String16 title@2;
  86. // The message body. If long, will wrap inside the notification.
  87. mojo_base.mojom.String16 message@3;
  88. // Human-readable description of the source of the notification. For example,
  89. // "Google Calendar".
  90. mojo_base.mojom.String16 display_source@4;
  91. // For web notifications, the URL of the website responsible for showing the
  92. // notification. Otherwise empty.
  93. url.mojom.Url? origin_url@5;
  94. // DEPRECATED, replaced with |icon| below.
  95. Bitmap? deprecated_icon@6;
  96. // Priority from -2 to 2. Zero is the default. Other values are clamped.
  97. int32 priority@7;
  98. // User must explicitly dismiss.
  99. bool require_interaction@8;
  100. // Time at which the notification is applicable (past, present or future).
  101. // See web platform API "timestamp" and chrome.notifications "eventTime".
  102. mojo_base.mojom.Time timestamp@9;
  103. // DEPRECATED, replaced with |image| below.
  104. Bitmap? deprecated_image@10;
  105. // DEPRECATED, replaced with |badge| below.
  106. Bitmap? deprecated_badge@11;
  107. // Item list for type kList. Not displayed for other types.
  108. array<NotificationItem> items@12;
  109. // Progress from 0 to 100 for type kProgress. Negative values result in an
  110. // animating "indefinite progress" indicator. Values above 100 are clamped.
  111. int32 progress@13;
  112. // Status message for type kProgress.
  113. mojo_base.mojom.String16 progress_status@14;
  114. // Up to 4 buttons. It is not guaranteed that all buttons will be visible,
  115. // especially if the labels are long.
  116. array<ButtonInfo> buttons@15;
  117. // Pinned notifications cannot be closed by the user, only by a call to
  118. // MessageCenter::CloseNotification.
  119. bool pinned@16;
  120. // Whether an announcement should occur (e.g. a popup or vibration) when an
  121. // existing notification is updated. See web platform API
  122. // Notification.renotify.
  123. bool renotify@17;
  124. // Whether all announcement mechanisms should be suppressed. See web platform
  125. // API Notification.silent.
  126. bool silent@18;
  127. // Accessible description of the notification's contents. If empty, the
  128. // message field will be used instead.
  129. mojo_base.mojom.String16 accessible_name@19;
  130. // Whether to show on top of fullscreen windows. See enum definition.
  131. FullscreenVisibility fullscreen_visibility@20;
  132. // Icon for the notification.
  133. [MinVersion=1]
  134. gfx.mojom.ImageSkia? icon@21;
  135. // For type kImage, the large image.
  136. [MinVersion=1]
  137. gfx.mojom.ImageSkia? image@22;
  138. // Badge to show the source of the notification (e.g. a 16x16 browser icon).
  139. [MinVersion=1]
  140. gfx.mojom.ImageSkia? badge@23;
  141. [MinVersion=2]
  142. // Whether the bool badge_needs_additional_masking is set.
  143. bool badge_needs_additional_masking_has_value@24;
  144. [MinVersion=2]
  145. // Whether the badge needs additional masking.
  146. bool badge_needs_additional_masking@25;
  147. [MinVersion=3]
  148. // Unified theme color used in new style notification.
  149. skia.mojom.SkColor? accent_color@26;
  150. [MinVersion=4]
  151. // The notifierId contains additional details for the notification's origin.
  152. // Will contain information on the type of sender
  153. // (Webpage, Android, System etc..) along with additional info that can
  154. // identify the sender (url, app name etc..).
  155. NotifierId? notifier_id@27;
  156. };