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