Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Side by Side Diff: ui/message_center/message_center_impl.cc

Issue 2424603002: Remove usage of FOR_EACH_OBSERVER macro in ui/message_center (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/message_center/notification_blocker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 // Do not call MessageCenterImpl::MarkSinglePopupAsShown() directly here 411 // Do not call MessageCenterImpl::MarkSinglePopupAsShown() directly here
412 // just for performance reason. MessageCenterImpl::MarkSinglePopupAsShown() 412 // just for performance reason. MessageCenterImpl::MarkSinglePopupAsShown()
413 // calls NotificationList::MarkSinglePopupAsShown() and then updates the 413 // calls NotificationList::MarkSinglePopupAsShown() and then updates the
414 // unread count, but the whole cache will be recreated below. 414 // unread count, but the whole cache will be recreated below.
415 notification_list_->MarkSinglePopupAsShown(id, true); 415 notification_list_->MarkSinglePopupAsShown(id, true);
416 } 416 }
417 notification_cache_.Rebuild( 417 notification_cache_.Rebuild(
418 notification_list_->GetVisibleNotifications(blockers_)); 418 notification_list_->GetVisibleNotifications(blockers_));
419 419
420 for (const auto& id : blocked_ids) { 420 for (const auto& id : blocked_ids) {
421 FOR_EACH_OBSERVER(MessageCenterObserver, 421 for (auto& observer : observer_list_)
422 observer_list_, 422 observer.OnNotificationUpdated(id);
423 OnNotificationUpdated(id));
424 } 423 }
425 FOR_EACH_OBSERVER(MessageCenterObserver, 424 for (auto& observer : observer_list_)
426 observer_list_, 425 observer.OnBlockingStateChanged(blocker);
427 OnBlockingStateChanged(blocker));
428 } 426 }
429 427
430 void MessageCenterImpl::UpdateIconImage( 428 void MessageCenterImpl::UpdateIconImage(
431 const NotifierId& notifier_id, const gfx::Image& icon) {} 429 const NotifierId& notifier_id, const gfx::Image& icon) {}
432 430
433 void MessageCenterImpl::NotifierGroupChanged() {} 431 void MessageCenterImpl::NotifierGroupChanged() {}
434 432
435 void MessageCenterImpl::NotifierEnabledChanged( 433 void MessageCenterImpl::NotifierEnabledChanged(
436 const NotifierId& notifier_id, bool enabled) { 434 const NotifierId& notifier_id, bool enabled) {
437 if (!enabled) { 435 if (!enabled) {
438 RemoveNotificationsForNotifierId(notifier_id); 436 RemoveNotificationsForNotifierId(notifier_id);
439 } 437 }
440 } 438 }
441 439
442 void MessageCenterImpl::SetVisibility(Visibility visibility) { 440 void MessageCenterImpl::SetVisibility(Visibility visibility) {
443 visible_ = (visibility == VISIBILITY_MESSAGE_CENTER); 441 visible_ = (visibility == VISIBILITY_MESSAGE_CENTER);
444 442
445 if (visible_ && !locked_) { 443 if (visible_ && !locked_) {
446 std::set<std::string> updated_ids; 444 std::set<std::string> updated_ids;
447 notification_list_->SetNotificationsShown(blockers_, &updated_ids); 445 notification_list_->SetNotificationsShown(blockers_, &updated_ids);
448 notification_cache_.RecountUnread(); 446 notification_cache_.RecountUnread();
449 447
450 for (const auto& id : updated_ids) { 448 for (const auto& id : updated_ids) {
451 FOR_EACH_OBSERVER( 449 for (auto& observer : observer_list_)
452 MessageCenterObserver, observer_list_, OnNotificationUpdated(id)); 450 observer.OnNotificationUpdated(id);
453 } 451 }
454 } 452 }
455 453
456 if (notification_queue_ && 454 if (notification_queue_ &&
457 visibility == VISIBILITY_TRANSIENT) { 455 visibility == VISIBILITY_TRANSIENT) {
458 notification_queue_->ApplyChanges(this); 456 notification_queue_->ApplyChanges(this);
459 } 457 }
460 458
461 FOR_EACH_OBSERVER(MessageCenterObserver, 459 for (auto& observer : observer_list_)
462 observer_list_, 460 observer.OnCenterVisibilityChanged(visibility);
463 OnCenterVisibilityChanged(visibility));
464 } 461 }
465 462
466 bool MessageCenterImpl::IsMessageCenterVisible() const { 463 bool MessageCenterImpl::IsMessageCenterVisible() const {
467 return visible_; 464 return visible_;
468 } 465 }
469 466
470 size_t MessageCenterImpl::NotificationCount() const { 467 size_t MessageCenterImpl::NotificationCount() const {
471 return notification_cache_.visible_notifications.size(); 468 return notification_cache_.visible_notifications.size();
472 } 469 }
473 470
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 534
538 // Sometimes the notification can be added with the same id and the 535 // Sometimes the notification can be added with the same id and the
539 // |notification_list| will replace the notification instead of adding new. 536 // |notification_list| will replace the notification instead of adding new.
540 // This is essentially an update rather than addition. 537 // This is essentially an update rather than addition.
541 bool already_exists = (notification_list_->GetNotificationById(id) != NULL); 538 bool already_exists = (notification_list_->GetNotificationById(id) != NULL);
542 notification_list_->AddNotification(std::move(notification)); 539 notification_list_->AddNotification(std::move(notification));
543 notification_cache_.Rebuild( 540 notification_cache_.Rebuild(
544 notification_list_->GetVisibleNotifications(blockers_)); 541 notification_list_->GetVisibleNotifications(blockers_));
545 542
546 if (already_exists) { 543 if (already_exists) {
547 FOR_EACH_OBSERVER( 544 for (auto& observer : observer_list_)
548 MessageCenterObserver, observer_list_, OnNotificationUpdated(id)); 545 observer.OnNotificationUpdated(id);
549 } else { 546 } else {
550 FOR_EACH_OBSERVER( 547 for (auto& observer : observer_list_)
551 MessageCenterObserver, observer_list_, OnNotificationAdded(id)); 548 observer.OnNotificationAdded(id);
552 } 549 }
553 } 550 }
554 551
555 void MessageCenterImpl::UpdateNotification( 552 void MessageCenterImpl::UpdateNotification(
556 const std::string& old_id, 553 const std::string& old_id,
557 std::unique_ptr<Notification> new_notification) { 554 std::unique_ptr<Notification> new_notification) {
558 for (size_t i = 0; i < blockers_.size(); ++i) 555 for (size_t i = 0; i < blockers_.size(); ++i)
559 blockers_[i]->CheckState(); 556 blockers_[i]->CheckState();
560 557
561 if (notification_queue_ && visible_) { 558 if (notification_queue_ && visible_) {
(...skipping 25 matching lines...) Expand all
587 584
588 void MessageCenterImpl::UpdateNotificationImmediately( 585 void MessageCenterImpl::UpdateNotificationImmediately(
589 const std::string& old_id, 586 const std::string& old_id,
590 std::unique_ptr<Notification> new_notification) { 587 std::unique_ptr<Notification> new_notification) {
591 std::string new_id = new_notification->id(); 588 std::string new_id = new_notification->id();
592 notification_list_->UpdateNotificationMessage(old_id, 589 notification_list_->UpdateNotificationMessage(old_id,
593 std::move(new_notification)); 590 std::move(new_notification));
594 notification_cache_.Rebuild( 591 notification_cache_.Rebuild(
595 notification_list_->GetVisibleNotifications(blockers_)); 592 notification_list_->GetVisibleNotifications(blockers_));
596 if (old_id == new_id) { 593 if (old_id == new_id) {
597 FOR_EACH_OBSERVER( 594 for (auto& observer : observer_list_)
598 MessageCenterObserver, observer_list_, OnNotificationUpdated(new_id)); 595 observer.OnNotificationUpdated(new_id);
599 } else { 596 } else {
600 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 597 for (auto& observer : observer_list_)
601 OnNotificationRemoved(old_id, false)); 598 observer.OnNotificationRemoved(old_id, false);
602 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 599 for (auto& observer : observer_list_)
603 OnNotificationAdded(new_id)); 600 observer.OnNotificationAdded(new_id);
604 } 601 }
605 } 602 }
606 603
607 void MessageCenterImpl::RemoveNotification(const std::string& id, 604 void MessageCenterImpl::RemoveNotification(const std::string& id,
608 bool by_user) { 605 bool by_user) {
609 if (notification_queue_ && !by_user && visible_) { 606 if (notification_queue_ && !by_user && visible_) {
610 notification_queue_->EraseNotification(id, by_user); 607 notification_queue_->EraseNotification(id, by_user);
611 return; 608 return;
612 } 609 }
613 610
(...skipping 15 matching lines...) Expand all
629 std::string copied_id(id); 626 std::string copied_id(id);
630 627
631 scoped_refptr<NotificationDelegate> delegate = 628 scoped_refptr<NotificationDelegate> delegate =
632 notification_list_->GetNotificationDelegate(copied_id); 629 notification_list_->GetNotificationDelegate(copied_id);
633 if (delegate.get()) 630 if (delegate.get())
634 delegate->Close(by_user); 631 delegate->Close(by_user);
635 632
636 notification_list_->RemoveNotification(copied_id); 633 notification_list_->RemoveNotification(copied_id);
637 notification_cache_.Rebuild( 634 notification_cache_.Rebuild(
638 notification_list_->GetVisibleNotifications(blockers_)); 635 notification_list_->GetVisibleNotifications(blockers_));
639 FOR_EACH_OBSERVER(MessageCenterObserver, 636 for (auto& observer : observer_list_)
640 observer_list_, 637 observer.OnNotificationRemoved(copied_id, by_user);
641 OnNotificationRemoved(copied_id, by_user));
642 } 638 }
643 639
644 void MessageCenterImpl::RemoveNotificationsForNotifierId( 640 void MessageCenterImpl::RemoveNotificationsForNotifierId(
645 const NotifierId& notifier_id) { 641 const NotifierId& notifier_id) {
646 NotificationList::Notifications notifications = 642 NotificationList::Notifications notifications =
647 notification_list_->GetNotificationsByNotifierId(notifier_id); 643 notification_list_->GetNotificationsByNotifierId(notifier_id);
648 for (auto* notification : notifications) 644 for (auto* notification : notifications)
649 RemoveNotification(notification->id(), false); 645 RemoveNotification(notification->id(), false);
650 if (!notifications.empty()) { 646 if (!notifications.empty()) {
651 notification_cache_.Rebuild( 647 notification_cache_.Rebuild(
(...skipping 20 matching lines...) Expand all
672 if (delegate.get()) 668 if (delegate.get())
673 delegate->Close(by_user); 669 delegate->Close(by_user);
674 notification_list_->RemoveNotification(notification->id()); 670 notification_list_->RemoveNotification(notification->id());
675 } 671 }
676 672
677 if (!ids.empty()) { 673 if (!ids.empty()) {
678 notification_cache_.Rebuild( 674 notification_cache_.Rebuild(
679 notification_list_->GetVisibleNotifications(blockers_)); 675 notification_list_->GetVisibleNotifications(blockers_));
680 } 676 }
681 for (const auto& id : ids) { 677 for (const auto& id : ids) {
682 FOR_EACH_OBSERVER(MessageCenterObserver, 678 for (auto& observer : observer_list_)
683 observer_list_, 679 observer.OnNotificationRemoved(id, by_user);
684 OnNotificationRemoved(id, by_user));
685 } 680 }
686 } 681 }
687 682
688 void MessageCenterImpl::SetNotificationIcon(const std::string& notification_id, 683 void MessageCenterImpl::SetNotificationIcon(const std::string& notification_id,
689 const gfx::Image& image) { 684 const gfx::Image& image) {
690 bool updated = false; 685 bool updated = false;
691 Notification* queue_notification = 686 Notification* queue_notification =
692 notification_queue_ 687 notification_queue_
693 ? notification_queue_->GetLatestNotification(notification_id) 688 ? notification_queue_->GetLatestNotification(notification_id)
694 : NULL; 689 : NULL;
695 690
696 if (queue_notification) { 691 if (queue_notification) {
697 queue_notification->set_icon(image); 692 queue_notification->set_icon(image);
698 updated = true; 693 updated = true;
699 } else { 694 } else {
700 updated = notification_list_->SetNotificationIcon(notification_id, image); 695 updated = notification_list_->SetNotificationIcon(notification_id, image);
701 } 696 }
702 697
703 if (updated) { 698 if (updated) {
704 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 699 for (auto& observer : observer_list_)
705 OnNotificationUpdated(notification_id)); 700 observer.OnNotificationUpdated(notification_id);
706 } 701 }
707 } 702 }
708 703
709 void MessageCenterImpl::SetNotificationImage(const std::string& notification_id, 704 void MessageCenterImpl::SetNotificationImage(const std::string& notification_id,
710 const gfx::Image& image) { 705 const gfx::Image& image) {
711 bool updated = false; 706 bool updated = false;
712 Notification* queue_notification = 707 Notification* queue_notification =
713 notification_queue_ 708 notification_queue_
714 ? notification_queue_->GetLatestNotification(notification_id) 709 ? notification_queue_->GetLatestNotification(notification_id)
715 : NULL; 710 : NULL;
716 711
717 if (queue_notification) { 712 if (queue_notification) {
718 queue_notification->set_image(image); 713 queue_notification->set_image(image);
719 updated = true; 714 updated = true;
720 } else { 715 } else {
721 updated = notification_list_->SetNotificationImage(notification_id, image); 716 updated = notification_list_->SetNotificationImage(notification_id, image);
722 } 717 }
723 718
724 if (updated) { 719 if (updated) {
725 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 720 for (auto& observer : observer_list_)
726 OnNotificationUpdated(notification_id)); 721 observer.OnNotificationUpdated(notification_id);
727 } 722 }
728 } 723 }
729 724
730 void MessageCenterImpl::SetNotificationButtonIcon( 725 void MessageCenterImpl::SetNotificationButtonIcon(
731 const std::string& notification_id, int button_index, 726 const std::string& notification_id, int button_index,
732 const gfx::Image& image) { 727 const gfx::Image& image) {
733 bool updated = false; 728 bool updated = false;
734 Notification* queue_notification = 729 Notification* queue_notification =
735 notification_queue_ 730 notification_queue_
736 ? notification_queue_->GetLatestNotification(notification_id) 731 ? notification_queue_->GetLatestNotification(notification_id)
737 : NULL; 732 : NULL;
738 733
739 if (queue_notification) { 734 if (queue_notification) {
740 queue_notification->SetButtonIcon(button_index, image); 735 queue_notification->SetButtonIcon(button_index, image);
741 updated = true; 736 updated = true;
742 } else { 737 } else {
743 updated = notification_list_->SetNotificationButtonIcon( 738 updated = notification_list_->SetNotificationButtonIcon(
744 notification_id, button_index, image); 739 notification_id, button_index, image);
745 } 740 }
746 741
747 if (updated) { 742 if (updated) {
748 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 743 for (auto& observer : observer_list_)
749 OnNotificationUpdated(notification_id)); 744 observer.OnNotificationUpdated(notification_id);
750 } 745 }
751 } 746 }
752 747
753 void MessageCenterImpl::DisableNotificationsByNotifier( 748 void MessageCenterImpl::DisableNotificationsByNotifier(
754 const NotifierId& notifier_id) { 749 const NotifierId& notifier_id) {
755 if (settings_provider_) { 750 if (settings_provider_) {
756 // TODO(mukai): SetNotifierEnabled can just accept notifier_id? 751 // TODO(mukai): SetNotifierEnabled can just accept notifier_id?
757 Notifier notifier(notifier_id, base::string16(), true); 752 Notifier notifier(notifier_id, base::string16(), true);
758 settings_provider_->SetNotifierEnabled(notifier, false); 753 settings_provider_->SetNotifierEnabled(notifier, false);
759 // The settings provider will call back to remove the notifications 754 // The settings provider will call back to remove the notifications
760 // belonging to the notifier id. 755 // belonging to the notifier id.
761 } else { 756 } else {
762 RemoveNotificationsForNotifierId(notifier_id); 757 RemoveNotificationsForNotifierId(notifier_id);
763 } 758 }
764 } 759 }
765 760
766 void MessageCenterImpl::ClickOnNotification(const std::string& id) { 761 void MessageCenterImpl::ClickOnNotification(const std::string& id) {
767 if (FindVisibleNotificationById(id) == NULL) 762 if (FindVisibleNotificationById(id) == NULL)
768 return; 763 return;
769 #if defined(OS_CHROMEOS) 764 #if defined(OS_CHROMEOS)
770 if (HasPopupNotifications()) 765 if (HasPopupNotifications())
771 MarkSinglePopupAsShown(id, true); 766 MarkSinglePopupAsShown(id, true);
772 #endif 767 #endif
773 scoped_refptr<NotificationDelegate> delegate = 768 scoped_refptr<NotificationDelegate> delegate =
774 notification_list_->GetNotificationDelegate(id); 769 notification_list_->GetNotificationDelegate(id);
775 if (delegate.get()) 770 if (delegate.get())
776 delegate->Click(); 771 delegate->Click();
777 FOR_EACH_OBSERVER( 772 for (auto& observer : observer_list_)
778 MessageCenterObserver, observer_list_, OnNotificationClicked(id)); 773 observer.OnNotificationClicked(id);
779 } 774 }
780 775
781 void MessageCenterImpl::ClickOnNotificationButton(const std::string& id, 776 void MessageCenterImpl::ClickOnNotificationButton(const std::string& id,
782 int button_index) { 777 int button_index) {
783 if (FindVisibleNotificationById(id) == NULL) 778 if (FindVisibleNotificationById(id) == NULL)
784 return; 779 return;
785 #if defined(OS_CHROMEOS) 780 #if defined(OS_CHROMEOS)
786 if (HasPopupNotifications()) 781 if (HasPopupNotifications())
787 MarkSinglePopupAsShown(id, true); 782 MarkSinglePopupAsShown(id, true);
788 #endif 783 #endif
789 scoped_refptr<NotificationDelegate> delegate = 784 scoped_refptr<NotificationDelegate> delegate =
790 notification_list_->GetNotificationDelegate(id); 785 notification_list_->GetNotificationDelegate(id);
791 if (delegate.get()) 786 if (delegate.get())
792 delegate->ButtonClick(button_index); 787 delegate->ButtonClick(button_index);
793 FOR_EACH_OBSERVER( 788 for (auto& observer : observer_list_)
794 MessageCenterObserver, observer_list_, OnNotificationButtonClicked( 789 observer.OnNotificationButtonClicked(id, button_index);
795 id, button_index));
796 } 790 }
797 791
798 void MessageCenterImpl::ClickOnSettingsButton(const std::string& id) { 792 void MessageCenterImpl::ClickOnSettingsButton(const std::string& id) {
799 scoped_refptr<NotificationDelegate> delegate = 793 scoped_refptr<NotificationDelegate> delegate =
800 notification_list_->GetNotificationDelegate(id); 794 notification_list_->GetNotificationDelegate(id);
801 if (delegate.get()) 795 if (delegate.get())
802 delegate->SettingsClick(); 796 delegate->SettingsClick();
803 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 797 for (auto& observer : observer_list_)
804 OnNotificationSettingsClicked()); 798 observer.OnNotificationSettingsClicked();
805 } 799 }
806 800
807 void MessageCenterImpl::MarkSinglePopupAsShown(const std::string& id, 801 void MessageCenterImpl::MarkSinglePopupAsShown(const std::string& id,
808 bool mark_notification_as_read) { 802 bool mark_notification_as_read) {
809 if (FindVisibleNotificationById(id) == NULL) 803 if (FindVisibleNotificationById(id) == NULL)
810 return; 804 return;
811 #if !defined(OS_CHROMEOS) 805 #if !defined(OS_CHROMEOS)
812 return this->RemoveNotification(id, false); 806 return this->RemoveNotification(id, false);
813 #else 807 #else
814 notification_list_->MarkSinglePopupAsShown(id, mark_notification_as_read); 808 notification_list_->MarkSinglePopupAsShown(id, mark_notification_as_read);
815 notification_cache_.RecountUnread(); 809 notification_cache_.RecountUnread();
816 FOR_EACH_OBSERVER( 810 for (auto& observer : observer_list_)
817 MessageCenterObserver, observer_list_, OnNotificationUpdated(id)); 811 observer.OnNotificationUpdated(id);
818 #endif // defined(OS_CHROMEOS) 812 #endif // defined(OS_CHROMEOS)
819 } 813 }
820 814
821 void MessageCenterImpl::DisplayedNotification( 815 void MessageCenterImpl::DisplayedNotification(
822 const std::string& id, 816 const std::string& id,
823 const DisplaySource source) { 817 const DisplaySource source) {
824 if (FindVisibleNotificationById(id) == NULL) 818 if (FindVisibleNotificationById(id) == NULL)
825 return; 819 return;
826 820
827 if (HasPopupNotifications()) 821 if (HasPopupNotifications())
828 notification_list_->MarkSinglePopupAsDisplayed(id); 822 notification_list_->MarkSinglePopupAsDisplayed(id);
829 notification_cache_.RecountUnread(); 823 notification_cache_.RecountUnread();
830 scoped_refptr<NotificationDelegate> delegate = 824 scoped_refptr<NotificationDelegate> delegate =
831 notification_list_->GetNotificationDelegate(id); 825 notification_list_->GetNotificationDelegate(id);
832 if (delegate.get()) 826 if (delegate.get())
833 delegate->Display(); 827 delegate->Display();
834 FOR_EACH_OBSERVER( 828 for (auto& observer : observer_list_)
835 MessageCenterObserver, 829 observer.OnNotificationDisplayed(id, source);
836 observer_list_,
837 OnNotificationDisplayed(id, source));
838 } 830 }
839 831
840 void MessageCenterImpl::SetNotifierSettingsProvider( 832 void MessageCenterImpl::SetNotifierSettingsProvider(
841 NotifierSettingsProvider* provider) { 833 NotifierSettingsProvider* provider) {
842 if (settings_provider_) { 834 if (settings_provider_) {
843 settings_provider_->RemoveObserver(this); 835 settings_provider_->RemoveObserver(this);
844 settings_provider_ = NULL; 836 settings_provider_ = NULL;
845 } 837 }
846 settings_provider_ = provider; 838 settings_provider_ = provider;
847 if (settings_provider_) 839 if (settings_provider_)
848 settings_provider_->AddObserver(this); 840 settings_provider_->AddObserver(this);
849 } 841 }
850 842
851 NotifierSettingsProvider* MessageCenterImpl::GetNotifierSettingsProvider() { 843 NotifierSettingsProvider* MessageCenterImpl::GetNotifierSettingsProvider() {
852 return settings_provider_; 844 return settings_provider_;
853 } 845 }
854 846
855 void MessageCenterImpl::SetQuietMode(bool in_quiet_mode) { 847 void MessageCenterImpl::SetQuietMode(bool in_quiet_mode) {
856 if (in_quiet_mode != notification_list_->quiet_mode()) { 848 if (in_quiet_mode != notification_list_->quiet_mode()) {
857 notification_list_->SetQuietMode(in_quiet_mode); 849 notification_list_->SetQuietMode(in_quiet_mode);
858 FOR_EACH_OBSERVER(MessageCenterObserver, 850 for (auto& observer : observer_list_)
859 observer_list_, 851 observer.OnQuietModeChanged(in_quiet_mode);
860 OnQuietModeChanged(in_quiet_mode));
861 } 852 }
862 quiet_mode_timer_.reset(); 853 quiet_mode_timer_.reset();
863 } 854 }
864 855
865 void MessageCenterImpl::SetLockedState(bool locked) { 856 void MessageCenterImpl::SetLockedState(bool locked) {
866 if (locked != locked_) { 857 if (locked != locked_) {
867 locked_ = locked; 858 locked_ = locked;
868 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 859 for (auto& observer : observer_list_)
869 OnLockedStateChanged(locked)); 860 observer.OnLockedStateChanged(locked);
870 } 861 }
871 } 862 }
872 863
873 void MessageCenterImpl::EnterQuietModeWithExpire( 864 void MessageCenterImpl::EnterQuietModeWithExpire(
874 const base::TimeDelta& expires_in) { 865 const base::TimeDelta& expires_in) {
875 if (quiet_mode_timer_) { 866 if (quiet_mode_timer_) {
876 // Note that the capital Reset() is the method to restart the timer, not 867 // Note that the capital Reset() is the method to restart the timer, not
877 // scoped_ptr::reset(). 868 // scoped_ptr::reset().
878 quiet_mode_timer_->Reset(); 869 quiet_mode_timer_->Reset();
879 } else { 870 } else {
880 notification_list_->SetQuietMode(true); 871 notification_list_->SetQuietMode(true);
881 FOR_EACH_OBSERVER( 872 for (auto& observer : observer_list_)
882 MessageCenterObserver, observer_list_, OnQuietModeChanged(true)); 873 observer.OnQuietModeChanged(true);
883 874
884 quiet_mode_timer_.reset(new base::OneShotTimer); 875 quiet_mode_timer_.reset(new base::OneShotTimer);
885 quiet_mode_timer_->Start( 876 quiet_mode_timer_->Start(
886 FROM_HERE, 877 FROM_HERE,
887 expires_in, 878 expires_in,
888 base::Bind( 879 base::Bind(
889 &MessageCenterImpl::SetQuietMode, base::Unretained(this), false)); 880 &MessageCenterImpl::SetQuietMode, base::Unretained(this), false));
890 } 881 }
891 } 882 }
892 883
(...skipping 12 matching lines...) Expand all
905 } 896 }
906 897
907 void MessageCenterImpl::EnableChangeQueueForTest(bool enable) { 898 void MessageCenterImpl::EnableChangeQueueForTest(bool enable) {
908 if (enable) 899 if (enable)
909 notification_queue_.reset(new internal::ChangeQueue()); 900 notification_queue_.reset(new internal::ChangeQueue());
910 else 901 else
911 notification_queue_.reset(); 902 notification_queue_.reset();
912 } 903 }
913 904
914 } // namespace message_center 905 } // namespace message_center
OLDNEW
« no previous file with comments | « no previous file | ui/message_center/notification_blocker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698