diff options
author | dewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 01:11:55 +0000 |
---|---|---|
committer | dewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 01:11:55 +0000 |
commit | edc76592019e1effb972c5757566e35ac6b1dfff (patch) | |
tree | 0212791c8b863a12cafae30ae206d1ce72f9bc7e | |
parent | 4aafebd3a96b854f6f5d6c06b5f0c0a0e7d3dea4 (diff) | |
download | chromium_src-edc76592019e1effb972c5757566e35ac6b1dfff.zip chromium_src-edc76592019e1effb972c5757566e35ac6b1dfff.tar.gz chromium_src-edc76592019e1effb972c5757566e35ac6b1dfff.tar.bz2 |
Fix popup crash on ChromeOS.
The popup collection was not handling correctly the case where it tells
the message center to mark its popups read, causing a NOTREACHED in
observer list.
BUG=324142
Review URL: https://codereview.chromium.org/99543003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238515 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 26 insertions, 5 deletions
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc index 09e615e..b0b75d8 100644 --- a/ash/system/web_notification/web_notification_tray.cc +++ b/ash/system/web_notification/web_notification_tray.cc @@ -416,6 +416,9 @@ bool WebNotificationTray::ShowPopups() { } void WebNotificationTray::HidePopups() { + DCHECK(popup_collection_.get()); + + popup_collection_->MarkAllPopupsShown(); popup_collection_.reset(); work_area_observer_->StopObserving(); } diff --git a/ash/system/web_notification/web_notification_tray_unittest.cc b/ash/system/web_notification/web_notification_tray_unittest.cc index 5ae2e49..b64e2b8 100644 --- a/ash/system/web_notification/web_notification_tray_unittest.cc +++ b/ash/system/web_notification/web_notification_tray_unittest.cc @@ -208,6 +208,16 @@ TEST_F(WebNotificationTrayTest, WebNotificationPopupBubble) { // Removing the visible notification should hide the popup bubble. RemoveNotification("test_id3"); EXPECT_FALSE(GetTray()->IsPopupVisible()); + + // Now test that we can show multiple popups and then show the message center. + AddNotification("test_id4"); + AddNotification("test_id5"); + EXPECT_TRUE(GetTray()->IsPopupVisible()); + + GetTray()->message_center_tray_->ShowMessageCenterBubble(); + GetTray()->message_center_tray_->HideMessageCenterBubble(); + + EXPECT_FALSE(GetTray()->IsPopupVisible()); } using message_center::NotificationList; diff --git a/chrome/browser/ui/views/message_center/web_notification_tray.cc b/chrome/browser/ui/views/message_center/web_notification_tray.cc index 6c6675f..88124f3 100644 --- a/chrome/browser/ui/views/message_center/web_notification_tray.cc +++ b/chrome/browser/ui/views/message_center/web_notification_tray.cc @@ -152,7 +152,12 @@ bool WebNotificationTray::ShowPopups() { return true; } -void WebNotificationTray::HidePopups() { popup_collection_.reset(); } +void WebNotificationTray::HidePopups() { + DCHECK(popup_collection_.get()); + + popup_collection_->MarkAllPopupsShown(); + popup_collection_.reset(); +} bool WebNotificationTray::ShowMessageCenter() { message_center_delegate_ = diff --git a/ui/message_center/message_center_tray.cc b/ui/message_center/message_center_tray.cc index 9a5ea56..f5bf22e 100644 --- a/ui/message_center/message_center_tray.cc +++ b/ui/message_center/message_center_tray.cc @@ -102,11 +102,8 @@ void MessageCenterTray::HidePopupBubbleInternal() { if (!popups_visible_) return; - // This is called before HidePopups so that we don't double-call this when we - // see the results of HidePopups via MessageCenterObserver. - popups_visible_ = false; - delegate_->HidePopups(); + popups_visible_ = false; } void MessageCenterTray::ShowNotifierSettingsBubble() { diff --git a/ui/message_center/views/message_popup_collection.cc b/ui/message_center/views/message_popup_collection.cc index 541963e..2474ad0 100644 --- a/ui/message_center/views/message_popup_collection.cc +++ b/ui/message_center/views/message_popup_collection.cc @@ -101,6 +101,10 @@ MessagePopupCollection::~MessagePopupCollection() { screen->RemoveObserver(this); message_center_->RemoveObserver(this); + CloseAllWidgets(); +} + +void MessagePopupCollection::MarkAllPopupsShown() { std::set<std::string> closed_ids = CloseAllWidgets(); for (std::set<std::string>::iterator iter = closed_ids.begin(); iter != closed_ids.end(); iter++) { diff --git a/ui/message_center/views/message_popup_collection.h b/ui/message_center/views/message_popup_collection.h index d5ab32b..9c7d617 100644 --- a/ui/message_center/views/message_popup_collection.h +++ b/ui/message_center/views/message_popup_collection.h @@ -68,6 +68,8 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection bool first_item_has_no_margin); virtual ~MessagePopupCollection(); + void MarkAllPopupsShown(); + // Since these events are really coming from individual toast widgets, // it helps to be able to keep track of the sender. void OnMouseEntered(ToastContentsView* toast_entered); |