message_center_utils.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #ifndef ASH_SYSTEM_MESSAGE_CENTER_MESSAGE_CENTER_UTILS_H_
  5. #define ASH_SYSTEM_MESSAGE_CENTER_MESSAGE_CENTER_UTILS_H_
  6. #include "ash/ash_export.h"
  7. #include "base/callback_forward.h"
  8. #include "ui/gfx/animation/tween.h"
  9. #include "ui/message_center/public/cpp/notification.h"
  10. namespace message_center {
  11. class NotificationViewController;
  12. }
  13. namespace views {
  14. class View;
  15. }
  16. namespace ash {
  17. namespace message_center_utils {
  18. // Comparator function for sorting the notifications in the order that they
  19. // should be displayed. Currently the ordering rule is very simple (subject to
  20. // change):
  21. // 1. All pinned notifications are displayed first.
  22. // 2. Otherwise, display in order of most recent timestamp.
  23. bool CompareNotifications(message_center::Notification* n1,
  24. message_center::Notification* n2);
  25. // Returns a vector of notifications that should have their own message
  26. // view sorted for display, using CompareNotifications() above for the sorting
  27. // order.
  28. std::vector<message_center::Notification*> GetSortedNotificationsWithOwnView();
  29. // Returns total notifications count, with a filter to not count some of them
  30. // These notifications such as camera, media controls, etc. don't need an
  31. // indicator in status area since they already have a dedicated tray item, and
  32. // grouped notifications only need to be counted as one.
  33. size_t ASH_EXPORT GetNotificationCount();
  34. // Get the notification view controller associated to a certain display.
  35. message_center::NotificationViewController*
  36. GetActiveNotificationViewControllerForDisplay(int64_t display_id);
  37. // Get the currently active notification view controller for the provided
  38. // `notification_view`. Each screen has it's own `MessagePopupCollection` and
  39. // `UnifiedMessageListView`.
  40. message_center::NotificationViewController*
  41. GetActiveNotificationViewControllerForNotificationView(
  42. views::View* notification_view);
  43. // Utils for animation within a notification view.
  44. // Initializes the layer for the specified `view` for animations.
  45. void InitLayerForAnimations(views::View* view);
  46. // Fade in animation using AnimationBuilder.
  47. void FadeInView(views::View* view,
  48. int delay_in_ms,
  49. int duration_in_ms,
  50. gfx::Tween::Type tween_type = gfx::Tween::LINEAR,
  51. const std::string& animation_histogram_name = std::string());
  52. // Fade out animation using AnimationBuilder.
  53. void FadeOutView(views::View* view,
  54. base::OnceClosure on_animation_ended,
  55. int delay_in_ms,
  56. int duration_in_ms,
  57. gfx::Tween::Type tween_type = gfx::Tween::LINEAR,
  58. const std::string& animation_histogram_name = std::string());
  59. // Slide out animation using AnimationBuilder.
  60. void SlideOutView(views::View* view,
  61. base::OnceClosure on_animation_ended,
  62. base::OnceClosure on_animation_aborted,
  63. int delay_in_ms,
  64. int duration_in_ms,
  65. gfx::Tween::Type tween_type = gfx::Tween::LINEAR,
  66. const std::string& animation_histogram_name = std::string());
  67. } // namespace message_center_utils
  68. } // namespace ash
  69. #endif // ASH_SYSTEM_MESSAGE_CENTER_MESSAGE_CENTER_UTILS_H_