| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/message_center/message_center_impl.h" | 5 #include "ui/message_center/message_center_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 void SetNotificationsEnabled(bool enabled) { | 148 void SetNotificationsEnabled(bool enabled) { |
| 149 if (notifications_enabled_ != enabled) { | 149 if (notifications_enabled_ != enabled) { |
| 150 notifications_enabled_ = enabled; | 150 notifications_enabled_ = enabled; |
| 151 NotifyBlockingStateChanged(); | 151 NotifyBlockingStateChanged(); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 // NotificationBlocker overrides: | 155 // NotificationBlocker overrides: |
| 156 bool ShouldShowNotificationAsPopup( | 156 bool ShouldShowNotificationAsPopup( |
| 157 const message_center::NotifierId& notifier_id) const override { | 157 const message_center::Notification& notification) const override { |
| 158 return notifications_enabled_; | 158 return notifications_enabled_; |
| 159 } | 159 } |
| 160 | 160 |
| 161 private: | 161 private: |
| 162 bool notifications_enabled_; | 162 bool notifications_enabled_; |
| 163 | 163 |
| 164 DISALLOW_COPY_AND_ASSIGN(ToggledNotificationBlocker); | 164 DISALLOW_COPY_AND_ASSIGN(ToggledNotificationBlocker); |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 class PopupNotificationBlocker : public ToggledNotificationBlocker { | 167 class PopupNotificationBlocker : public ToggledNotificationBlocker { |
| 168 public: | 168 public: |
| 169 PopupNotificationBlocker(MessageCenter* message_center, | 169 PopupNotificationBlocker(MessageCenter* message_center, |
| 170 const NotifierId& allowed_notifier) | 170 const NotifierId& allowed_notifier) |
| 171 : ToggledNotificationBlocker(message_center), | 171 : ToggledNotificationBlocker(message_center), |
| 172 allowed_notifier_(allowed_notifier) {} | 172 allowed_notifier_(allowed_notifier) {} |
| 173 ~PopupNotificationBlocker() override {} | 173 ~PopupNotificationBlocker() override {} |
| 174 | 174 |
| 175 // NotificationBlocker overrides: | 175 // NotificationBlocker overrides: |
| 176 bool ShouldShowNotificationAsPopup( | 176 bool ShouldShowNotificationAsPopup( |
| 177 const NotifierId& notifier_id) const override { | 177 const Notification& notification) const override { |
| 178 return (notifier_id == allowed_notifier_) || | 178 return (notification.notifier_id() == allowed_notifier_) || |
| 179 ToggledNotificationBlocker::ShouldShowNotificationAsPopup(notifier_id); | 179 ToggledNotificationBlocker::ShouldShowNotificationAsPopup( |
| 180 notification); |
| 180 } | 181 } |
| 181 | 182 |
| 182 private: | 183 private: |
| 183 NotifierId allowed_notifier_; | 184 NotifierId allowed_notifier_; |
| 184 | 185 |
| 185 DISALLOW_COPY_AND_ASSIGN(PopupNotificationBlocker); | 186 DISALLOW_COPY_AND_ASSIGN(PopupNotificationBlocker); |
| 186 }; | 187 }; |
| 187 | 188 |
| 188 class TotalNotificationBlocker : public PopupNotificationBlocker { | 189 class TotalNotificationBlocker : public PopupNotificationBlocker { |
| 189 public: | 190 public: |
| 190 TotalNotificationBlocker(MessageCenter* message_center, | 191 TotalNotificationBlocker(MessageCenter* message_center, |
| 191 const NotifierId& allowed_notifier) | 192 const NotifierId& allowed_notifier) |
| 192 : PopupNotificationBlocker(message_center, allowed_notifier) {} | 193 : PopupNotificationBlocker(message_center, allowed_notifier) {} |
| 193 ~TotalNotificationBlocker() override {} | 194 ~TotalNotificationBlocker() override {} |
| 194 | 195 |
| 195 // NotificationBlocker overrides: | 196 // NotificationBlocker overrides: |
| 196 bool ShouldShowNotification(const NotifierId& notifier_id) const override { | 197 bool ShouldShowNotification(const Notification& notification) const override { |
| 197 return ShouldShowNotificationAsPopup(notifier_id); | 198 return ShouldShowNotificationAsPopup(notification); |
| 198 } | 199 } |
| 199 | 200 |
| 200 private: | 201 private: |
| 201 DISALLOW_COPY_AND_ASSIGN(TotalNotificationBlocker); | 202 DISALLOW_COPY_AND_ASSIGN(TotalNotificationBlocker); |
| 202 }; | 203 }; |
| 203 | 204 |
| 204 bool PopupNotificationsContain( | 205 bool PopupNotificationsContain( |
| 205 const NotificationList::PopupNotifications& popups, | 206 const NotificationList::PopupNotifications& popups, |
| 206 const std::string& id) { | 207 const std::string& id) { |
| 207 for (NotificationList::PopupNotifications::const_iterator iter = | 208 for (NotificationList::PopupNotifications::const_iterator iter = |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 // Then open the message center. | 1169 // Then open the message center. |
| 1169 message_center()->SetVisibility(VISIBILITY_MESSAGE_CENTER); | 1170 message_center()->SetVisibility(VISIBILITY_MESSAGE_CENTER); |
| 1170 | 1171 |
| 1171 // Then update a notification; the update should have propagated. | 1172 // Then update a notification; the update should have propagated. |
| 1172 message_center()->RemoveNotification(id, false); | 1173 message_center()->RemoveNotification(id, false); |
| 1173 EXPECT_FALSE(message_center()->FindVisibleNotificationById(id)); | 1174 EXPECT_FALSE(message_center()->FindVisibleNotificationById(id)); |
| 1174 } | 1175 } |
| 1175 | 1176 |
| 1176 } // namespace internal | 1177 } // namespace internal |
| 1177 } // namespace message_center | 1178 } // namespace message_center |
| OLD | NEW |