OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/message_center/views/message_center_view.h" | 5 #include "ui/message_center/views/message_center_view.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
881 } | 881 } |
882 if (message_views_.size() >= kMaxVisibleMessageCenterNotifications) | 882 if (message_views_.size() >= kMaxVisibleMessageCenterNotifications) |
883 break; | 883 break; |
884 } | 884 } |
885 NotificationsChanged(); | 885 NotificationsChanged(); |
886 } | 886 } |
887 | 887 |
888 void MessageCenterView::OnNotificationRemoved(const std::string& id, | 888 void MessageCenterView::OnNotificationRemoved(const std::string& id, |
889 bool by_user) { | 889 bool by_user) { |
890 for (size_t i = 0; i < message_views_.size(); ++i) { | 890 for (size_t i = 0; i < message_views_.size(); ++i) { |
891 if (message_views_[i]->notification_id() == id) { | 891 MessageView* message_view = message_views_[i]; |
892 if (message_view->GetType() == NOTIFICATION_VIEW && | |
893 static_cast<NotificationView*>(message_view)->notification_id() == id) { | |
dewittj
2013/11/19 01:44:04
static_cast? Any way to get around this?
| |
892 if (by_user) { | 894 if (by_user) { |
893 message_list_view_->SetRepositionTarget(message_views_[i]->bounds()); | 895 message_list_view_->SetRepositionTarget(message_views_[i]->bounds()); |
894 // Moves the keyboard focus to the next notification if the removed | 896 // Moves the keyboard focus to the next notification if the removed |
895 // notification is focused so that the user can dismiss notifications | 897 // notification is focused so that the user can dismiss notifications |
896 // without re-focusing by tab key. | 898 // without re-focusing by tab key. |
897 if (message_views_.size() > 1) { | 899 if (message_views_.size() > 1) { |
898 views::View* focused_view = GetFocusManager()->GetFocusedView(); | 900 views::View* focused_view = GetFocusManager()->GetFocusedView(); |
899 if (message_views_[i]->IsCloseButtonFocused() || | 901 if (message_views_[i]->IsCloseButtonFocused() || |
900 focused_view == message_views_[i]) { | 902 focused_view == message_views_[i]) { |
901 size_t next_index = i + 1; | 903 size_t next_index = i + 1; |
(...skipping 15 matching lines...) Expand all Loading... | |
917 } | 919 } |
918 | 920 |
919 void MessageCenterView::OnNotificationUpdated(const std::string& id) { | 921 void MessageCenterView::OnNotificationUpdated(const std::string& id) { |
920 const NotificationList::Notifications& notifications = | 922 const NotificationList::Notifications& notifications = |
921 message_center_->GetVisibleNotifications(); | 923 message_center_->GetVisibleNotifications(); |
922 size_t index = 0; | 924 size_t index = 0; |
923 for (NotificationList::Notifications::const_iterator iter = | 925 for (NotificationList::Notifications::const_iterator iter = |
924 notifications.begin(); | 926 notifications.begin(); |
925 iter != notifications.end() && index < message_views_.size(); | 927 iter != notifications.end() && index < message_views_.size(); |
926 ++iter, ++index) { | 928 ++iter, ++index) { |
927 DCHECK((*iter)->id() == message_views_[index]->notification_id()); | 929 // TODO(dimich): This fails if there are GROUP_VIEWs around, |
930 // they break the iter/index sync which is assumed here. | |
931 DCHECK(message_views_[index]->GetType() != NOTIFICATION_VIEW || | |
932 (*iter)->id() == static_cast<NotificationView*>( | |
933 message_views_[index])->notification_id()); | |
928 if ((*iter)->id() == id) { | 934 if ((*iter)->id() == id) { |
929 bool expanded = true; | 935 bool expanded = true; |
930 if (IsExperimentalNotificationUIEnabled()) | 936 if (IsExperimentalNotificationUIEnabled()) |
931 expanded = (*iter)->is_expanded(); | 937 expanded = (*iter)->is_expanded(); |
932 MessageView* view = | 938 MessageView* view = |
933 NotificationView::Create(*(*iter), | 939 NotificationView::Create(*(*iter), |
934 message_center_, | 940 message_center_, |
935 tray_, | 941 tray_, |
936 expanded, | 942 expanded, |
937 false); // Not creating a top-level | 943 false); // Not creating a top-level |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1018 scroller_->InvalidateLayout(); | 1024 scroller_->InvalidateLayout(); |
1019 PreferredSizeChanged(); | 1025 PreferredSizeChanged(); |
1020 Layout(); | 1026 Layout(); |
1021 } | 1027 } |
1022 | 1028 |
1023 void MessageCenterView::SetNotificationViewForTest(views::View* view) { | 1029 void MessageCenterView::SetNotificationViewForTest(views::View* view) { |
1024 message_list_view_->AddNotificationAt(view, 0); | 1030 message_list_view_->AddNotificationAt(view, 0); |
1025 } | 1031 } |
1026 | 1032 |
1027 } // namespace message_center | 1033 } // namespace message_center |
OLD | NEW |