| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/observer_list.h" | 7 #include "base/observer_list.h" |
| 8 #include "ui/message_center/message_center_style.h" | 8 #include "ui/message_center/message_center_style.h" |
| 9 #include "ui/message_center/notification.h" | 9 #include "ui/message_center/notification.h" |
| 10 #include "ui/message_center/notification_list.h" | 10 #include "ui/message_center/notification_list.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 187 } |
| 188 | 188 |
| 189 } // namespace internal | 189 } // namespace internal |
| 190 | 190 |
| 191 //////////////////////////////////////////////////////////////////////////////// | 191 //////////////////////////////////////////////////////////////////////////////// |
| 192 // MessageCenterImpl | 192 // MessageCenterImpl |
| 193 | 193 |
| 194 MessageCenterImpl::MessageCenterImpl() | 194 MessageCenterImpl::MessageCenterImpl() |
| 195 : MessageCenter(), | 195 : MessageCenter(), |
| 196 popup_timers_controller_(new internal::PopupTimersController(this)), | 196 popup_timers_controller_(new internal::PopupTimersController(this)), |
| 197 delegate_(NULL), | |
| 198 settings_provider_(NULL) { | 197 settings_provider_(NULL) { |
| 199 notification_list_.reset(new NotificationList()); | 198 notification_list_.reset(new NotificationList()); |
| 200 } | 199 } |
| 201 | 200 |
| 202 MessageCenterImpl::~MessageCenterImpl() { | 201 MessageCenterImpl::~MessageCenterImpl() { |
| 203 notification_list_.reset(); | 202 notification_list_.reset(); |
| 204 } | 203 } |
| 205 | 204 |
| 206 void MessageCenterImpl::AddObserver(MessageCenterObserver* observer) { | 205 void MessageCenterImpl::AddObserver(MessageCenterObserver* observer) { |
| 207 observer_list_.AddObserver(observer); | 206 observer_list_.AddObserver(observer); |
| 208 } | 207 } |
| 209 | 208 |
| 210 void MessageCenterImpl::RemoveObserver(MessageCenterObserver* observer) { | 209 void MessageCenterImpl::RemoveObserver(MessageCenterObserver* observer) { |
| 211 observer_list_.RemoveObserver(observer); | 210 observer_list_.RemoveObserver(observer); |
| 212 } | 211 } |
| 213 | 212 |
| 214 void MessageCenterImpl::SetDelegate(Delegate* delegate) { | 213 void MessageCenterImpl::SetVisibility(Visibility visibility) { |
| 215 delegate_ = delegate; | 214 std::set<std::string> updated_ids; |
| 216 } | 215 notification_list_->SetMessageCenterVisible( |
| 216 (visibility == VISIBILITY_MESSAGE_CENTER), &updated_ids); |
| 217 | 217 |
| 218 void MessageCenterImpl::SetMessageCenterVisible(bool visible) { | |
| 219 std::set<std::string> updated_ids; | |
| 220 notification_list_->SetMessageCenterVisible(visible, &updated_ids); | |
| 221 for (std::set<std::string>::const_iterator iter = updated_ids.begin(); | 218 for (std::set<std::string>::const_iterator iter = updated_ids.begin(); |
| 222 iter != updated_ids.end(); | 219 iter != updated_ids.end(); |
| 223 ++iter) { | 220 ++iter) { |
| 224 FOR_EACH_OBSERVER( | 221 FOR_EACH_OBSERVER( |
| 225 MessageCenterObserver, observer_list_, OnNotificationUpdated(*iter)); | 222 MessageCenterObserver, observer_list_, OnNotificationUpdated(*iter)); |
| 226 } | 223 } |
| 227 | 224 |
| 228 if (!visible) { | 225 FOR_EACH_OBSERVER(MessageCenterObserver, |
| 229 FOR_EACH_OBSERVER( | 226 observer_list_, |
| 230 MessageCenterObserver, observer_list_, OnNotificationCenterClosed()); | 227 OnCenterVisibilityChanged(visibility)); |
| 231 } | |
| 232 } | 228 } |
| 233 | 229 |
| 234 bool MessageCenterImpl::IsMessageCenterVisible() { | 230 bool MessageCenterImpl::IsMessageCenterVisible() { |
| 235 return notification_list_->is_message_center_visible(); | 231 return notification_list_->is_message_center_visible(); |
| 236 } | 232 } |
| 237 | 233 |
| 238 size_t MessageCenterImpl::NotificationCount() const { | 234 size_t MessageCenterImpl::NotificationCount() const { |
| 239 return notification_list_->NotificationCount(); | 235 return notification_list_->NotificationCount(); |
| 240 } | 236 } |
| 241 | 237 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 NotificationList::Notifications notifications = | 384 NotificationList::Notifications notifications = |
| 389 notification_list_->GetNotificationsByNotifierId(notifier_id); | 385 notification_list_->GetNotificationsByNotifierId(notifier_id); |
| 390 for (NotificationList::Notifications::const_iterator iter = | 386 for (NotificationList::Notifications::const_iterator iter = |
| 391 notifications.begin(); iter != notifications.end();) { | 387 notifications.begin(); iter != notifications.end();) { |
| 392 std::string id = (*iter)->id(); | 388 std::string id = (*iter)->id(); |
| 393 iter++; | 389 iter++; |
| 394 RemoveNotification(id, false); | 390 RemoveNotification(id, false); |
| 395 } | 391 } |
| 396 } | 392 } |
| 397 | 393 |
| 398 void MessageCenterImpl::ShowNotificationSettings(const std::string& id) { | |
| 399 if (delegate_) | |
| 400 delegate_->ShowSettings(id); | |
| 401 } | |
| 402 | |
| 403 void MessageCenterImpl::ExpandNotification(const std::string& id) { | 394 void MessageCenterImpl::ExpandNotification(const std::string& id) { |
| 404 if (!HasNotification(id)) | 395 if (!HasNotification(id)) |
| 405 return; | 396 return; |
| 406 notification_list_->MarkNotificationAsExpanded(id); | 397 notification_list_->MarkNotificationAsExpanded(id); |
| 407 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, | 398 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, |
| 408 OnNotificationUpdated(id)); | 399 OnNotificationUpdated(id)); |
| 409 } | 400 } |
| 410 | 401 |
| 411 void MessageCenterImpl::ClickOnNotification(const std::string& id) { | 402 void MessageCenterImpl::ClickOnNotification(const std::string& id) { |
| 412 if (!HasNotification(id)) | 403 if (!HasNotification(id)) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 void MessageCenterImpl::PausePopupTimers() { | 497 void MessageCenterImpl::PausePopupTimers() { |
| 507 if (popup_timers_controller_.get()) | 498 if (popup_timers_controller_.get()) |
| 508 popup_timers_controller_->PauseAll(); | 499 popup_timers_controller_->PauseAll(); |
| 509 } | 500 } |
| 510 | 501 |
| 511 void MessageCenterImpl::DisableTimersForTest() { | 502 void MessageCenterImpl::DisableTimersForTest() { |
| 512 popup_timers_controller_.reset(); | 503 popup_timers_controller_.reset(); |
| 513 } | 504 } |
| 514 | 505 |
| 515 } // namespace message_center | 506 } // namespace message_center |
| OLD | NEW |