[email protected] | b78d79a5 | 2013-09-12 01:52:21 | [diff] [blame] | 1 | // Copyright 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 | |
| 5 | #include "ui/message_center/notification_blocker.h" |
| 6 | |
David Sanders | de5fee54 | 2022-03-23 02:47:44 | [diff] [blame] | 7 | #include "base/observer_list.h" |
[email protected] | b78d79a5 | 2013-09-12 01:52:21 | [diff] [blame] | 8 | #include "ui/message_center/message_center.h" |
| 9 | |
| 10 | namespace message_center { |
| 11 | |
| 12 | NotificationBlocker::NotificationBlocker(MessageCenter* message_center) |
| 13 | : message_center_(message_center) { |
| 14 | if (message_center_) |
| 15 | message_center_->AddNotificationBlocker(this); |
| 16 | } |
| 17 | |
| 18 | NotificationBlocker::~NotificationBlocker() { |
| 19 | if (message_center_) |
| 20 | message_center_->RemoveNotificationBlocker(this); |
| 21 | } |
| 22 | |
| 23 | void NotificationBlocker::AddObserver(NotificationBlocker::Observer* observer) { |
| 24 | observers_.AddObserver(observer); |
| 25 | } |
| 26 | |
| 27 | void NotificationBlocker::RemoveObserver( |
| 28 | NotificationBlocker::Observer* observer) { |
| 29 | observers_.RemoveObserver(observer); |
| 30 | } |
| 31 | |
[email protected] | 33aa554d | 2013-12-06 00:47:53 | [diff] [blame] | 32 | bool NotificationBlocker::ShouldShowNotification( |
bmalcolm | b34f499 | 2016-08-03 19:42:00 | [diff] [blame] | 33 | const Notification& notification) const { |
[email protected] | 33aa554d | 2013-12-06 00:47:53 | [diff] [blame] | 34 | return true; |
| 35 | } |
| 36 | |
| 37 | void NotificationBlocker::NotifyBlockingStateChanged() { |
ericwilligers | dfd9e46 | 2016-10-17 19:38:17 | [diff] [blame] | 38 | for (auto& observer : observers_) |
| 39 | observer.OnBlockingStateChanged(this); |
[email protected] | 33aa554d | 2013-12-06 00:47:53 | [diff] [blame] | 40 | } |
| 41 | |
[email protected] | b78d79a5 | 2013-09-12 01:52:21 | [diff] [blame] | 42 | } // namespace message_center |