| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 434 |
| 435 void MessageCenterImpl::NotifierEnabledChanged( | 435 void MessageCenterImpl::NotifierEnabledChanged( |
| 436 const NotifierId& notifier_id, bool enabled) { | 436 const NotifierId& notifier_id, bool enabled) { |
| 437 if (!enabled) { | 437 if (!enabled) { |
| 438 RemoveNotificationsForNotifierId(notifier_id); | 438 RemoveNotificationsForNotifierId(notifier_id); |
| 439 } | 439 } |
| 440 } | 440 } |
| 441 | 441 |
| 442 void MessageCenterImpl::SetVisibility(Visibility visibility) { | 442 void MessageCenterImpl::SetVisibility(Visibility visibility) { |
| 443 std::set<std::string> updated_ids; | 443 std::set<std::string> updated_ids; |
| 444 notification_list_->SetMessageCenterVisible( | 444 bool visible = visibility == VISIBILITY_MESSAGE_CENTER; |
| 445 (visibility == VISIBILITY_MESSAGE_CENTER), &updated_ids); | |
| 446 notification_cache_.RecountUnread(); | |
| 447 | 445 |
| 448 for (const auto& id : updated_ids) { | 446 notification_list_->SetMessageCenterVisible(visible); |
| 449 FOR_EACH_OBSERVER( | 447 if (visible && !locked_) { |
| 450 MessageCenterObserver, observer_list_, OnNotificationUpdated(id)); | 448 notification_list_->SetNotificationsShown(blockers_, &updated_ids); |
| 449 notification_cache_.RecountUnread(); |
| 450 |
| 451 for (const auto& id : updated_ids) { |
| 452 FOR_EACH_OBSERVER( |
| 453 MessageCenterObserver, observer_list_, OnNotificationUpdated(id)); |
| 454 } |
| 451 } | 455 } |
| 452 | 456 |
| 453 if (notification_queue_ && | 457 if (notification_queue_ && |
| 454 visibility == VISIBILITY_TRANSIENT) { | 458 visibility == VISIBILITY_TRANSIENT) { |
| 455 notification_queue_->ApplyChanges(this); | 459 notification_queue_->ApplyChanges(this); |
| 456 } | 460 } |
| 457 | 461 |
| 458 FOR_EACH_OBSERVER(MessageCenterObserver, | 462 FOR_EACH_OBSERVER(MessageCenterObserver, |
| 459 observer_list_, | 463 observer_list_, |
| 460 OnCenterVisibilityChanged(visibility)); | 464 OnCenterVisibilityChanged(visibility)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 474 | 478 |
| 475 bool MessageCenterImpl::HasPopupNotifications() const { | 479 bool MessageCenterImpl::HasPopupNotifications() const { |
| 476 return !IsMessageCenterVisible() && | 480 return !IsMessageCenterVisible() && |
| 477 notification_list_->HasPopupNotifications(blockers_); | 481 notification_list_->HasPopupNotifications(blockers_); |
| 478 } | 482 } |
| 479 | 483 |
| 480 bool MessageCenterImpl::IsQuietMode() const { | 484 bool MessageCenterImpl::IsQuietMode() const { |
| 481 return notification_list_->quiet_mode(); | 485 return notification_list_->quiet_mode(); |
| 482 } | 486 } |
| 483 | 487 |
| 488 bool MessageCenterImpl::IsLockedState() const { |
| 489 return locked_; |
| 490 } |
| 491 |
| 484 bool MessageCenterImpl::HasClickedListener(const std::string& id) { | 492 bool MessageCenterImpl::HasClickedListener(const std::string& id) { |
| 485 scoped_refptr<NotificationDelegate> delegate = | 493 scoped_refptr<NotificationDelegate> delegate = |
| 486 notification_list_->GetNotificationDelegate(id); | 494 notification_list_->GetNotificationDelegate(id); |
| 487 return delegate.get() && delegate->HasClickedListener(); | 495 return delegate.get() && delegate->HasClickedListener(); |
| 488 } | 496 } |
| 489 | 497 |
| 490 message_center::Notification* MessageCenterImpl::FindVisibleNotificationById( | 498 message_center::Notification* MessageCenterImpl::FindVisibleNotificationById( |
| 491 const std::string& id) { | 499 const std::string& id) { |
| 492 return notification_list_->GetNotificationById(id); | 500 return notification_list_->GetNotificationById(id); |
| 493 } | 501 } |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 void MessageCenterImpl::SetQuietMode(bool in_quiet_mode) { | 855 void MessageCenterImpl::SetQuietMode(bool in_quiet_mode) { |
| 848 if (in_quiet_mode != notification_list_->quiet_mode()) { | 856 if (in_quiet_mode != notification_list_->quiet_mode()) { |
| 849 notification_list_->SetQuietMode(in_quiet_mode); | 857 notification_list_->SetQuietMode(in_quiet_mode); |
| 850 FOR_EACH_OBSERVER(MessageCenterObserver, | 858 FOR_EACH_OBSERVER(MessageCenterObserver, |
| 851 observer_list_, | 859 observer_list_, |
| 852 OnQuietModeChanged(in_quiet_mode)); | 860 OnQuietModeChanged(in_quiet_mode)); |
| 853 } | 861 } |
| 854 quiet_mode_timer_.reset(); | 862 quiet_mode_timer_.reset(); |
| 855 } | 863 } |
| 856 | 864 |
| 865 void MessageCenterImpl::SetLockedState(bool locked) { |
| 866 if (locked != locked_) { |
| 867 locked_ = locked; |
| 868 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, |
| 869 OnLockedStateChanged(locked)); |
| 870 } |
| 871 } |
| 872 |
| 857 void MessageCenterImpl::EnterQuietModeWithExpire( | 873 void MessageCenterImpl::EnterQuietModeWithExpire( |
| 858 const base::TimeDelta& expires_in) { | 874 const base::TimeDelta& expires_in) { |
| 859 if (quiet_mode_timer_) { | 875 if (quiet_mode_timer_) { |
| 860 // Note that the capital Reset() is the method to restart the timer, not | 876 // Note that the capital Reset() is the method to restart the timer, not |
| 861 // scoped_ptr::reset(). | 877 // scoped_ptr::reset(). |
| 862 quiet_mode_timer_->Reset(); | 878 quiet_mode_timer_->Reset(); |
| 863 } else { | 879 } else { |
| 864 notification_list_->SetQuietMode(true); | 880 notification_list_->SetQuietMode(true); |
| 865 FOR_EACH_OBSERVER( | 881 FOR_EACH_OBSERVER( |
| 866 MessageCenterObserver, observer_list_, OnQuietModeChanged(true)); | 882 MessageCenterObserver, observer_list_, OnQuietModeChanged(true)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 889 } | 905 } |
| 890 | 906 |
| 891 void MessageCenterImpl::EnableChangeQueueForTest(bool enable) { | 907 void MessageCenterImpl::EnableChangeQueueForTest(bool enable) { |
| 892 if (enable) | 908 if (enable) |
| 893 notification_queue_.reset(new internal::ChangeQueue()); | 909 notification_queue_.reset(new internal::ChangeQueue()); |
| 894 else | 910 else |
| 895 notification_queue_.reset(); | 911 notification_queue_.reset(); |
| 896 } | 912 } |
| 897 | 913 |
| 898 } // namespace message_center | 914 } // namespace message_center |
| OLD | NEW |