message_center.mojom 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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/notification.mojom";
  6. import "mojo/public/mojom/base/string16.mojom";
  7. // Handles notifications created via the Notifications web platform API and the
  8. // chrome.notifications() extension API. Shows the notifications in the
  9. // message center. Implemented in ash-chrome.
  10. [Stable, Uuid="0d9c1eb6-a383-45c0-ac11-2336e1227f74"]
  11. interface MessageCenter {
  12. // Displays a notification. If the notification's ID is the same as an
  13. // existing notification, that notification is replaced. The delegate will be
  14. // called with user actions.
  15. DisplayNotification@0(Notification notification,
  16. pending_remote<NotificationDelegate> delegate);
  17. // Closes a notification by the ID provided in |notification| above.
  18. CloseNotification@1(string id);
  19. // Returns the IDs of the currently-displayed notifications. Order within the
  20. // array is not guaranteed. Mojo does not support sets.
  21. [MinVersion=1]
  22. GetDisplayedNotifications@2() => (array<string> ids);
  23. };
  24. // Handles responses to user actions on notifications. Multiple actions may
  25. // occur on a single notification. For example, clicking a notification button
  26. // may not close the notification. Implemented in lacros-chrome.
  27. [Stable, Uuid="1a850ac9-a813-4d0d-aa2d-b0d6cf10d548"]
  28. interface NotificationDelegate {
  29. // Called when a notification previously displayed by the client is closed.
  30. OnNotificationClosed@0(bool by_user);
  31. // Called when the body of a notification is clicked.
  32. OnNotificationClicked@1();
  33. // Called when a notification that has buttons (e.g., "Learn more") receives a
  34. // click on one of the buttons.
  35. OnNotificationButtonClicked@2(
  36. uint32 button_index,
  37. // This string contains input that is submitted for a notification button
  38. // with input. It's value will be null if the clicked button has no
  39. // associated input.
  40. [MinVersion=2] mojo_base.mojom.String16? reply);
  41. // Called when a notification's settings button has been pressed.
  42. OnNotificationSettingsButtonClicked@3();
  43. // Called when a notification has been disabled (via inline settings).
  44. OnNotificationDisabled@4();
  45. };