Commit edc76592 authored by dewittj@chromium.org's avatar dewittj@chromium.org

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
parent 4aafebd3
......@@ -416,6 +416,9 @@ bool WebNotificationTray::ShowPopups() {
}
void WebNotificationTray::HidePopups() {
DCHECK(popup_collection_.get());
popup_collection_->MarkAllPopupsShown();
popup_collection_.reset();
work_area_observer_->StopObserving();
}
......
......@@ -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;
......
......@@ -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_ =
......
......@@ -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() {
......
......@@ -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++) {
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment