| 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 c45cb94987954d2570eaebffeb22422a8ee7aec7..dbcbbe2e3e19f10d9da19ae6f83fc42773b091fe 100644
|
| --- a/ui/message_center/message_center_impl.cc
|
| +++ b/ui/message_center/message_center_impl.cc
|
| @@ -428,7 +428,9 @@ MessageCenterImpl::MessageCenterImpl()
|
| notification_queue_.reset(new internal::ChangeQueue());
|
| }
|
|
|
| -MessageCenterImpl::~MessageCenterImpl() {}
|
| +MessageCenterImpl::~MessageCenterImpl() {
|
| + SetNotifierSettingsProvider(NULL);
|
| +}
|
|
|
| void MessageCenterImpl::AddObserver(MessageCenterObserver* observer) {
|
| observer_list_.AddObserver(observer);
|
| @@ -480,6 +482,18 @@ void MessageCenterImpl::OnBlockingStateChanged(NotificationBlocker* blocker) {
|
| OnBlockingStateChanged(blocker));
|
| }
|
|
|
| +void MessageCenterImpl::UpdateIconImage(
|
| + const NotifierId& notifier_id,const gfx::Image& icon) {}
|
| +
|
| +void MessageCenterImpl::NotifierGroupChanged() {}
|
| +
|
| +void MessageCenterImpl::NotifierEnabledChanged(
|
| + const NotifierId& notifier_id, bool enabled) {
|
| + if (!enabled) {
|
| + RemoveNotificationsForNotifierId(notifier_id);
|
| + }
|
| +}
|
| +
|
| void MessageCenterImpl::SetVisibility(Visibility visibility) {
|
| std::set<std::string> updated_ids;
|
| notification_list_->SetMessageCenterVisible(
|
| @@ -650,6 +664,20 @@ void MessageCenterImpl::RemoveNotification(const std::string& id,
|
| OnNotificationRemoved(copied_id, by_user));
|
| }
|
|
|
| +void MessageCenterImpl::RemoveNotificationsForNotifierId(
|
| + const NotifierId& notifier_id) {
|
| + NotificationList::Notifications notifications =
|
| + notification_list_->GetNotificationsByNotifierId(notifier_id);
|
| + for (NotificationList::Notifications::const_iterator iter =
|
| + notifications.begin(); iter != notifications.end(); ++iter) {
|
| + RemoveNotification((*iter)->id(), false);
|
| + }
|
| + if (!notifications.empty()) {
|
| + notification_cache_.Rebuild(
|
| + notification_list_->GetVisibleNotifications(blockers_));
|
| + }
|
| +}
|
| +
|
| void MessageCenterImpl::RemoveAllNotifications(bool by_user) {
|
| // Using not |blockers_| but an empty list since it wants to remove literally
|
| // all notifications.
|
| @@ -752,19 +780,10 @@ void MessageCenterImpl::DisableNotificationsByNotifier(
|
| // TODO(mukai): SetNotifierEnabled can just accept notifier_id?
|
| Notifier notifier(notifier_id, base::string16(), true);
|
| settings_provider_->SetNotifierEnabled(notifier, false);
|
| - }
|
| -
|
| - NotificationList::Notifications notifications =
|
| - notification_list_->GetNotificationsByNotifierId(notifier_id);
|
| - for (NotificationList::Notifications::const_iterator iter =
|
| - notifications.begin(); iter != notifications.end();) {
|
| - std::string id = (*iter)->id();
|
| - iter++;
|
| - RemoveNotification(id, false);
|
| - }
|
| - if (!notifications.empty()) {
|
| - notification_cache_.Rebuild(
|
| - notification_list_->GetVisibleNotifications(blockers_));
|
| + // The settings provider will call back to remove the notifications
|
| + // belonging to the notifier id.
|
| + } else {
|
| + RemoveNotificationsForNotifierId(notifier_id);
|
| }
|
| }
|
|
|
| @@ -827,7 +846,13 @@ void MessageCenterImpl::DisplayedNotification(
|
|
|
| void MessageCenterImpl::SetNotifierSettingsProvider(
|
| NotifierSettingsProvider* provider) {
|
| + if (settings_provider_) {
|
| + settings_provider_->RemoveObserver(this);
|
| + settings_provider_ = NULL;
|
| + }
|
| settings_provider_ = provider;
|
| + if (settings_provider_)
|
| + settings_provider_->AddObserver(this);
|
| }
|
|
|
| NotifierSettingsProvider* MessageCenterImpl::GetNotifierSettingsProvider() {
|
|
|