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

Unified Diff: ui/message_center/message_center_impl.cc

Issue 288033014: Remove Notifications Associated with an Extension When the Extension is Unchecked from the Message … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Unit Test That Left Dangling Pointer Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/message_center/message_center_impl.h ('k') | ui/message_center/message_center_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « ui/message_center/message_center_impl.h ('k') | ui/message_center/message_center_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698