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

Unified Diff: ui/message_center/message_center_impl.cc

Issue 14320008: Fixes crash for operations on non-existing notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 7 years, 8 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 | « no previous file | no next file » | 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 8d8b6d2d1b08e331a96abf6edcb39c7dcde7675e..3ffb3f8ba43b5ad88a4f2d8b83432900f4946322 100644
--- a/ui/message_center/message_center_impl.cc
+++ b/ui/message_center/message_center_impl.cc
@@ -112,6 +112,9 @@ void MessageCenterImpl::UpdateNotification(
void MessageCenterImpl::RemoveNotification(const std::string& id,
bool by_user) {
+ if (!HasNotification(id))
+ return;
+
// In many cases |id| is a reference to an existing notification instance
// but the instance can be destructed in RemoveNotification(). Hence
// copies the id explicitly here.
@@ -157,6 +160,8 @@ void MessageCenterImpl::SetNotificationImage(const std::string& notification_id,
void MessageCenterImpl::SetNotificationButtonIcon(
const std::string& notification_id, int button_index,
const gfx::Image& image) {
+ if (!HasNotification(notification_id))
+ return;
if (notification_list_->SetNotificationButtonIcon(notification_id,
button_index, image)) {
FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
@@ -205,12 +210,16 @@ void MessageCenterImpl::ShowNotificationSettingsDialog(
}
void MessageCenterImpl::ExpandNotification(const std::string& id) {
+ if (!HasNotification(id))
+ return;
notification_list_->MarkNotificationAsExpanded(id);
FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
OnNotificationUpdated(id));
}
void MessageCenterImpl::ClickOnNotification(const std::string& id) {
+ if (!HasNotification(id))
+ return;
if (HasPopupNotifications())
MarkSinglePopupAsShown(id, true);
FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
@@ -219,6 +228,8 @@ void MessageCenterImpl::ClickOnNotification(const std::string& id) {
void MessageCenterImpl::ClickOnNotificationButton(const std::string& id,
int button_index) {
+ if (!HasNotification(id))
+ return;
if (HasPopupNotifications())
MarkSinglePopupAsShown(id, true);
FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
@@ -227,6 +238,8 @@ void MessageCenterImpl::ClickOnNotificationButton(const std::string& id,
void MessageCenterImpl::MarkSinglePopupAsShown(const std::string& id,
bool mark_notification_as_read) {
+ if (!HasNotification(id))
+ return;
notification_list_->MarkSinglePopupAsShown(id, mark_notification_as_read);
FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
OnNotificationUpdated(id));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698