diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-09 02:02:30 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-09 02:02:30 +0000 |
commit | 7363a623e3a95c92173e99aa2b09f2dbe828d9fd (patch) | |
tree | eec3bda39dea5788e3725eaaaff0859f739c07eb /ui | |
parent | bc77dcbe7c78533f34490c2d6046bc2892aa5dc4 (diff) | |
download | chromium_src-7363a623e3a95c92173e99aa2b09f2dbe828d9fd.zip chromium_src-7363a623e3a95c92173e99aa2b09f2dbe828d9fd.tar.gz chromium_src-7363a623e3a95c92173e99aa2b09f2dbe828d9fd.tar.bz2 |
Changes the OnClick behavior in message center.
Now it doesn't dismiss the item. When click happens in the toast, it will hide from the popup but remain in the center.
BUG=165576
Review URL: https://codereview.chromium.org/11778012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175669 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/message_center/message_center.cc | 4 | ||||
-rw-r--r-- | ui/message_center/notification_list.cc | 26 | ||||
-rw-r--r-- | ui/message_center/notification_list.h | 3 | ||||
-rw-r--r-- | ui/message_center/notification_list_unittest.cc | 51 |
4 files changed, 84 insertions, 0 deletions
diff --git a/ui/message_center/message_center.cc b/ui/message_center/message_center.cc index 917d498..5486b22 100644 --- a/ui/message_center/message_center.cc +++ b/ui/message_center/message_center.cc @@ -146,6 +146,10 @@ void MessageCenter::ShowNotificationSettings(const std::string& id) { void MessageCenter::OnNotificationClicked(const std::string& id) { if (delegate_) delegate_->OnClicked(id); + if (HasPopupNotifications()) { + notification_list_->MarkSinglePopupAsShown(id); + NotifyMessageCenterChanged(false); + } } void MessageCenter::OnQuietModeChanged(bool quiet_mode) { diff --git a/ui/message_center/notification_list.cc b/ui/message_center/notification_list.cc index d92051a7e..9425454 100644 --- a/ui/message_center/notification_list.cc +++ b/ui/message_center/notification_list.cc @@ -261,6 +261,32 @@ void NotificationList::MarkPopupsAsShown(int priority) { iter->shown_as_popup = true; } +void NotificationList::MarkSinglePopupAsShown(const std::string& id) { + Notifications::iterator iter; + if (!GetNotification(id, &iter)) + return; + + if (iter->shown_as_popup) + return; + + // Moves the item to the beginning of the already-shown items. + Notification notification = *iter; + notification.shown_as_popup = true; + notifications_[notification.priority].erase(iter); + for (Notifications::iterator iter2 = + notifications_[notification.priority].begin(); + iter2 != notifications_[notification.priority].end(); iter2++) { + if (iter2->shown_as_popup) { + notifications_[notification.priority].insert(iter2, notification); + return; + } + } + + // No notifications are already shown as popup, so just re-adding at the end + // of the list. + notifications_[notification.priority].push_back(notification); +} + void NotificationList::SetQuietMode(bool quiet_mode) { SetQuietModeInternal(quiet_mode); quiet_mode_timer_.reset(); diff --git a/ui/message_center/notification_list.h b/ui/message_center/notification_list.h index 87cf509..7bc1e87 100644 --- a/ui/message_center/notification_list.h +++ b/ui/message_center/notification_list.h @@ -149,6 +149,9 @@ class MESSAGE_CENTER_EXPORT NotificationList { // Marks the popups for the |priority| as shown. void MarkPopupsAsShown(int priority); + // Marks a specific popup item as shown. + void MarkSinglePopupAsShown(const std::string& id); + bool quiet_mode() const { return quiet_mode_; } // Sets the current quiet mode status to |quiet_mode|. The new status is not diff --git a/ui/message_center/notification_list_unittest.cc b/ui/message_center/notification_list_unittest.cc index 4244d11..f863280 100644 --- a/ui/message_center/notification_list_unittest.cc +++ b/ui/message_center/notification_list_unittest.cc @@ -317,6 +317,57 @@ TEST_F(NotificationListTest, NotificationOrderAndPriority) { EXPECT_EQ(default_id, iter->id); } +TEST_F(NotificationListTest, MarkSinglePopupAsShown) { + std::string id1 = AddNotification(NULL); + std::string id2 = AddNotification(NULL); + ASSERT_EQ(2u, notification_list()->NotificationCount()); + ASSERT_EQ(2u, GetPopupCounts()); + + notification_list()->MarkSinglePopupAsShown(id2); + EXPECT_EQ(2u, notification_list()->NotificationCount()); + EXPECT_EQ(1u, GetPopupCounts()); + NotificationList::Notifications popups; + notification_list()->GetPopupNotifications(&popups); + EXPECT_EQ(id1, popups.begin()->id); + + // Reorder happens -- popup-notifications should be at the beginning of the + // list. + // TODO(mukai): confirm this behavior is expected. + NotificationList::Notifications notifications; + notification_list()->GetNotifications(¬ifications); + NotificationList::Notifications::const_iterator iter = notifications.begin(); + EXPECT_EQ(id1, iter->id); + iter++; + EXPECT_EQ(id2, iter->id); + + // Trickier scenario. + notification_list()->MarkPopupsAsShown(ui::notifications::DEFAULT_PRIORITY); + std::string id3 = AddNotification(NULL); + std::string id4 = AddNotification(NULL); + std::string id5 = AddNotification(NULL); + notification_list()->MarkSinglePopupAsShown(id4); + popups.clear(); + notifications.clear(); + notification_list()->GetPopupNotifications(&popups); + notification_list()->GetNotifications(¬ifications); + EXPECT_EQ(2u, popups.size()); + iter = popups.begin(); + EXPECT_EQ(id5, iter->id); + iter++; + EXPECT_EQ(id3, iter->id); + EXPECT_EQ(5u, notifications.size()); + iter = notifications.begin(); + EXPECT_EQ(id5, iter->id); + iter++; + EXPECT_EQ(id3, iter->id); + iter++; + EXPECT_EQ(id4, iter->id); + iter++; + EXPECT_EQ(id1, iter->id); + iter++; + EXPECT_EQ(id2, iter->id); +} + TEST_F(NotificationListTest, QuietMode) { notification_list()->SetQuietMode(true); AddNotification(NULL); |