message_center_observer.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright (c) 2013 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. #ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_OBSERVER_H_
  5. #define UI_MESSAGE_CENTER_MESSAGE_CENTER_OBSERVER_H_
  6. #include <string>
  7. #include "base/observer_list_types.h"
  8. #include "third_party/abseil-cpp/absl/types/optional.h"
  9. #include "ui/message_center/message_center_export.h"
  10. #include "ui/message_center/message_center_types.h"
  11. namespace message_center {
  12. class NotificationBlocker;
  13. // An observer class for the change of notifications in the MessageCenter.
  14. // WARNING: It is not safe to modify the message center from within these
  15. // callbacks.
  16. class MESSAGE_CENTER_EXPORT MessageCenterObserver
  17. : public base::CheckedObserver {
  18. public:
  19. // Called when the notification associated with |notification_id| is added
  20. // to the notification_list.
  21. virtual void OnNotificationAdded(const std::string& notification_id) {}
  22. // Called when the notification associated with |notification_id| is removed
  23. // from the notification_list.
  24. virtual void OnNotificationRemoved(const std::string& notification_id,
  25. bool by_user) {}
  26. // Called when the contents of the notification associated with
  27. // |notification_id| is updated.
  28. virtual void OnNotificationUpdated(const std::string& notification_id) {}
  29. // Called when a click event happens on the notification associated with
  30. // |notification_id|. |button_index| will be nullopt if the click occurred on
  31. // the body of the notification. |reply| will be filled in only if there was
  32. // an input field associated with the button.
  33. virtual void OnNotificationClicked(
  34. const std::string& notification_id,
  35. const absl::optional<int>& button_index,
  36. const absl::optional<std::u16string>& reply) {}
  37. // Called when notification settings button is clicked. The |handled| argument
  38. // indicates whether the notification delegate already handled the operation.
  39. virtual void OnNotificationSettingsClicked(bool handled) {}
  40. // Called when the notification associated with |notification_id| is actually
  41. // displayed.
  42. virtual void OnNotificationDisplayed(
  43. const std::string& notification_id,
  44. const DisplaySource source) {}
  45. // Called when the message view associated with `notification_id` is hovered.
  46. virtual void OnMessageViewHovered(const std::string& notification_id) {}
  47. // Called when the notification center is shown or hidden.
  48. virtual void OnCenterVisibilityChanged(Visibility visibility) {}
  49. // Called whenever the quiet mode changes as a result of user action or when
  50. // quiet mode expires.
  51. virtual void OnQuietModeChanged(bool in_quiet_mode) {}
  52. // Called when the blocking state of |blocker| is changed.
  53. virtual void OnBlockingStateChanged(NotificationBlocker* blocker) {}
  54. // Called after a visible notification popup closes, indicating it has been
  55. // shown to the user, and whether the notification is marked as read.
  56. virtual void OnNotificationPopupShown(const std::string& notification_id,
  57. bool mark_notification_as_read) {}
  58. };
  59. } // namespace message_center
  60. #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_OBSERVER_H_