| Index: ui/message_center/message_center_impl.cc
|
| diff --git a/ui/message_center/message_center_impl.cc b/ui/message_center/message_center_impl.cc
|
| index 06a04611514ce0837d61e6da1f97a324dceb367a..67d62d40cce2c2ecc21d762b0e8ac152c2441a39 100644
|
| --- a/ui/message_center/message_center_impl.cc
|
| +++ b/ui/message_center/message_center_impl.cc
|
| @@ -356,7 +356,7 @@ MessageCenterImpl::MessageCenterImpl()
|
| : MessageCenter(),
|
| popup_timers_controller_(new PopupTimersController(this)),
|
| settings_provider_(NULL) {
|
| - notification_list_.reset(new NotificationList());
|
| + notification_list_.reset(new NotificationList(this));
|
|
|
| bool enable_message_center_changes_while_open = true; // enable by default
|
| std::string arg = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
| @@ -440,14 +440,17 @@ void MessageCenterImpl::NotifierEnabledChanged(
|
| }
|
|
|
| void MessageCenterImpl::SetVisibility(Visibility visibility) {
|
| - std::set<std::string> updated_ids;
|
| - notification_list_->SetMessageCenterVisible(
|
| - (visibility == VISIBILITY_MESSAGE_CENTER), &updated_ids);
|
| - notification_cache_.RecountUnread();
|
| + visible_ = (visibility == VISIBILITY_MESSAGE_CENTER);
|
|
|
| - for (const auto& id : updated_ids) {
|
| - FOR_EACH_OBSERVER(
|
| - MessageCenterObserver, observer_list_, OnNotificationUpdated(id));
|
| + if (visible_ && !locked_) {
|
| + std::set<std::string> updated_ids;
|
| + notification_list_->SetNotificationsShown(blockers_, &updated_ids);
|
| + notification_cache_.RecountUnread();
|
| +
|
| + for (const auto& id : updated_ids) {
|
| + FOR_EACH_OBSERVER(
|
| + MessageCenterObserver, observer_list_, OnNotificationUpdated(id));
|
| + }
|
| }
|
|
|
| if (notification_queue_ &&
|
| @@ -461,7 +464,7 @@ void MessageCenterImpl::SetVisibility(Visibility visibility) {
|
| }
|
|
|
| bool MessageCenterImpl::IsMessageCenterVisible() const {
|
| - return notification_list_->is_message_center_visible();
|
| + return visible_;
|
| }
|
|
|
| size_t MessageCenterImpl::NotificationCount() const {
|
| @@ -481,6 +484,10 @@ bool MessageCenterImpl::IsQuietMode() const {
|
| return notification_list_->quiet_mode();
|
| }
|
|
|
| +bool MessageCenterImpl::IsLockedState() const {
|
| + return locked_;
|
| +}
|
| +
|
| bool MessageCenterImpl::HasClickedListener(const std::string& id) {
|
| scoped_refptr<NotificationDelegate> delegate =
|
| notification_list_->GetNotificationDelegate(id);
|
| @@ -516,8 +523,7 @@ void MessageCenterImpl::AddNotification(
|
| for (size_t i = 0; i < blockers_.size(); ++i)
|
| blockers_[i]->CheckState();
|
|
|
| - if (notification_queue_ &&
|
| - notification_list_->is_message_center_visible()) {
|
| + if (notification_queue_ && visible_) {
|
| notification_queue_->AddNotification(std::move(notification));
|
| return;
|
| }
|
| @@ -552,8 +558,7 @@ void MessageCenterImpl::UpdateNotification(
|
| for (size_t i = 0; i < blockers_.size(); ++i)
|
| blockers_[i]->CheckState();
|
|
|
| - if (notification_queue_ &&
|
| - notification_list_->is_message_center_visible()) {
|
| + if (notification_queue_ && visible_) {
|
| // We will allow notifications that are progress types (and stay progress
|
| // types) to be updated even if the message center is open. There are 3
|
| // requirements here:
|
| @@ -601,8 +606,7 @@ void MessageCenterImpl::UpdateNotificationImmediately(
|
|
|
| void MessageCenterImpl::RemoveNotification(const std::string& id,
|
| bool by_user) {
|
| - if (notification_queue_ && !by_user &&
|
| - notification_list_->is_message_center_visible()) {
|
| + if (notification_queue_ && !by_user && visible_) {
|
| notification_queue_->EraseNotification(id, by_user);
|
| return;
|
| }
|
| @@ -854,6 +858,14 @@ void MessageCenterImpl::SetQuietMode(bool in_quiet_mode) {
|
| quiet_mode_timer_.reset();
|
| }
|
|
|
| +void MessageCenterImpl::SetLockedState(bool locked) {
|
| + if (locked != locked_) {
|
| + locked_ = locked;
|
| + FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
|
| + OnLockedStateChanged(locked));
|
| + }
|
| +}
|
| +
|
| void MessageCenterImpl::EnterQuietModeWithExpire(
|
| const base::TimeDelta& expires_in) {
|
| if (quiet_mode_timer_) {
|
|
|