inactive_user_notification_blocker.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2017 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_INACTIVE_USER_NOTIFICATION_BLOCKER_H_
  5. #define ASH_SYSTEM_MESSAGE_CENTER_INACTIVE_USER_NOTIFICATION_BLOCKER_H_
  6. #include <map>
  7. #include "ash/ash_export.h"
  8. #include "ash/public/cpp/session/session_observer.h"
  9. #include "components/account_id/account_id.h"
  10. #include "ui/message_center/notification_blocker.h"
  11. namespace ash {
  12. // A notification blocker for per-profile stream switching.
  13. class ASH_EXPORT InactiveUserNotificationBlocker
  14. : public message_center::NotificationBlocker,
  15. public SessionObserver {
  16. public:
  17. explicit InactiveUserNotificationBlocker(
  18. message_center::MessageCenter* message_center);
  19. InactiveUserNotificationBlocker(const InactiveUserNotificationBlocker&) =
  20. delete;
  21. InactiveUserNotificationBlocker& operator=(
  22. const InactiveUserNotificationBlocker&) = delete;
  23. ~InactiveUserNotificationBlocker() override;
  24. // message_center::NotificationBlocker:
  25. bool ShouldShowNotification(
  26. const message_center::Notification& notification) const override;
  27. bool ShouldShowNotificationAsPopup(
  28. const message_center::Notification& notification) const override;
  29. // SessionObserver:
  30. void OnActiveUserSessionChanged(const AccountId& account_id) override;
  31. private:
  32. AccountId active_account_id_;
  33. std::map<AccountId, bool> quiet_modes_;
  34. ScopedSessionObserver scoped_observer_;
  35. };
  36. } // namespace ash
  37. #endif // ASH_SYSTEM_MESSAGE_CENTER_INACTIVE_USER_NOTIFICATION_BLOCKER_H_