Chromium Code Reviews| Index: chrome/browser/notifications/message_center_notification_manager.cc |
| diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc |
| index 0d92a79f08dfebd924e07a6b5811bbd2c8b4652d..e087a7c7f33ee8cf6ac4bcd9c9591e620e6a3ce3 100644 |
| --- a/chrome/browser/notifications/message_center_notification_manager.cc |
| +++ b/chrome/browser/notifications/message_center_notification_manager.cc |
| @@ -164,6 +164,9 @@ void MessageCenterNotificationManager::DisableExtension( |
| const std::string& notification_id) { |
| ProfileNotification* profile_notification = |
| FindProfileNotification(notification_id); |
| + if (!profile_notification) |
| + return; |
| + |
| std::string extension_id = profile_notification->GetExtensionId(); |
| DCHECK(!extension_id.empty()); // or UI should not have enabled the command. |
| DesktopNotificationService* service = |
| @@ -176,6 +179,9 @@ void MessageCenterNotificationManager::DisableNotificationsFromSource( |
| const std::string& notification_id) { |
| ProfileNotification* profile_notification = |
| FindProfileNotification(notification_id); |
| + if (!profile_notification) |
| + return; |
| + |
| // UI should not have enabled the command if there is no valid source. |
| DCHECK(profile_notification->notification().origin_url().is_valid()); |
| DesktopNotificationService* service = |
| @@ -194,6 +200,9 @@ void MessageCenterNotificationManager::ShowSettings( |
| ProfileNotification* profile_notification = |
| FindProfileNotification(notification_id); |
| + if (!profile_notification) |
| + return; |
| + |
| Browser* browser = |
| chrome::FindOrCreateTabbedBrowser(profile_notification->profile(), |
| chrome::HOST_DESKTOP_TYPE_NATIVE); |
| @@ -224,13 +233,20 @@ void MessageCenterNotificationManager::OnNotificationRemoved( |
| void MessageCenterNotificationManager::OnNotificationClicked( |
| const std::string& notification_id) { |
| - FindProfileNotification(notification_id)->notification().Click(); |
| + ProfileNotification* profile_notification = |
| + FindProfileNotification(notification_id); |
| + if (!profile_notification) |
| + return; |
| + profile_notification->notification().Click(); |
| } |
| void MessageCenterNotificationManager::OnNotificationButtonClicked( |
| const std::string& notification_id, |
| int button_index) { |
| - FindProfileNotification(notification_id)->notification().ButtonClick( |
| - button_index); |
| + ProfileNotification* profile_notification = |
| + FindProfileNotification(notification_id); |
| + if (!profile_notification) |
| + return; |
| + profile_notification->notification().ButtonClick(button_index); |
| } |
| @@ -409,8 +425,11 @@ MessageCenterNotificationManager::ProfileNotification* |
| MessageCenterNotificationManager::FindProfileNotification( |
| const std::string& id) const { |
| NotificationMap::const_iterator iter = profile_notifications_.find(id); |
| - // If the notification is shown in UI, it must be in the map. |
| - DCHECK(iter != profile_notifications_.end()); |
| - DCHECK((*iter).second); |
| + if (iter == profile_notifications_.end() || !(*iter).second) |
|
Dmitry Titov
2013/04/17 21:58:52
I think we don't need the second part of the check
Jun Mukai
2013/04/18 03:08:10
removed. thanks!
|
| + LOG(ERROR) << "Missing ProfileNotification for " << id; |
| + |
| + if (iter == profile_notifications_.end()) |
| + return NULL; |
| + |
| return (*iter).second; |
| } |