| 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/macros.h" | 10 #include "base/macros.h" |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 break; | 418 break; |
| 419 } | 419 } |
| 420 NotificationsChanged(); | 420 NotificationsChanged(); |
| 421 } | 421 } |
| 422 | 422 |
| 423 void MessageCenterView::OnNotificationRemoved(const std::string& id, | 423 void MessageCenterView::OnNotificationRemoved(const std::string& id, |
| 424 bool by_user) { | 424 bool by_user) { |
| 425 NotificationViewsMap::iterator view_iter = notification_views_.find(id); | 425 NotificationViewsMap::iterator view_iter = notification_views_.find(id); |
| 426 if (view_iter == notification_views_.end()) | 426 if (view_iter == notification_views_.end()) |
| 427 return; | 427 return; |
| 428 NotificationView* view = view_iter->second; | 428 MessageView* view = view_iter->second; |
| 429 int index = message_list_view_->GetIndexOf(view); | 429 int index = message_list_view_->GetIndexOf(view); |
| 430 DCHECK_LE(0, index); | 430 DCHECK_LE(0, index); |
| 431 if (by_user) { | 431 if (by_user) { |
| 432 message_list_view_->SetRepositionTarget(view->bounds()); | 432 message_list_view_->SetRepositionTarget(view->bounds()); |
| 433 // Moves the keyboard focus to the next notification if the removed | 433 // Moves the keyboard focus to the next notification if the removed |
| 434 // notification is focused so that the user can dismiss notifications | 434 // notification is focused so that the user can dismiss notifications |
| 435 // without re-focusing by tab key. | 435 // without re-focusing by tab key. |
| 436 if (view->IsCloseButtonFocused() || | 436 if (view->IsCloseButtonFocused() || |
| 437 view == GetFocusManager()->GetFocusedView()) { | 437 view == GetFocusManager()->GetFocusedView()) { |
| 438 views::View* next_focused_view = NULL; | 438 views::View* next_focused_view = NULL; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 460 void MessageCenterView::OnNotificationUpdated(const std::string& id) { | 460 void MessageCenterView::OnNotificationUpdated(const std::string& id) { |
| 461 NotificationViewsMap::const_iterator view_iter = notification_views_.find(id); | 461 NotificationViewsMap::const_iterator view_iter = notification_views_.find(id); |
| 462 if (view_iter == notification_views_.end()) | 462 if (view_iter == notification_views_.end()) |
| 463 return; | 463 return; |
| 464 | 464 |
| 465 // Set the item on the mouse cursor as the reposition target so that it | 465 // Set the item on the mouse cursor as the reposition target so that it |
| 466 // should stick to the current position over the update. | 466 // should stick to the current position over the update. |
| 467 bool set = false; | 467 bool set = false; |
| 468 if (message_list_view_->IsMouseHovered()) { | 468 if (message_list_view_->IsMouseHovered()) { |
| 469 for (const auto& hover_id_view : notification_views_) { | 469 for (const auto& hover_id_view : notification_views_) { |
| 470 NotificationView* hover_view = hover_id_view.second; | 470 MessageView* hover_view = hover_id_view.second; |
| 471 if (hover_view->IsMouseHovered()) { | 471 if (hover_view->IsMouseHovered()) { |
| 472 message_list_view_->SetRepositionTarget(hover_view->bounds()); | 472 message_list_view_->SetRepositionTarget(hover_view->bounds()); |
| 473 set = true; | 473 set = true; |
| 474 break; | 474 break; |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 } | 477 } |
| 478 if (!set) | 478 if (!set) |
| 479 message_list_view_->ResetRepositionSession(); | 479 message_list_view_->ResetRepositionSession(); |
| 480 | 480 |
| 481 // TODO(dimich): add MessageCenter::GetVisibleNotificationById(id) | 481 // TODO(dimich): add MessageCenter::GetVisibleNotificationById(id) |
| 482 NotificationView* view = view_iter->second; | 482 MessageView* view = view_iter->second; |
| 483 const NotificationList::Notifications& notifications = | 483 const NotificationList::Notifications& notifications = |
| 484 message_center_->GetVisibleNotifications(); | 484 message_center_->GetVisibleNotifications(); |
| 485 for (NotificationList::Notifications::const_iterator iter = | 485 for (NotificationList::Notifications::const_iterator iter = |
| 486 notifications.begin(); iter != notifications.end(); ++iter) { | 486 notifications.begin(); iter != notifications.end(); ++iter) { |
| 487 if ((*iter)->id() == id) { | 487 if ((*iter)->id() == id) { |
| 488 int old_width = view->width(); | 488 int old_width = view->width(); |
| 489 int old_height = view->GetHeightForWidth(old_width); | 489 int old_height = view->GetHeightForWidth(old_width); |
| 490 message_list_view_->UpdateNotification(view, **iter); | 490 message_list_view_->UpdateNotification(view, **iter); |
| 491 if (view->GetHeightForWidth(old_width) != old_height) | 491 if (view->GetHeightForWidth(old_width) != old_height) |
| 492 NotificationsChanged(); | 492 NotificationsChanged(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 } | 561 } |
| 562 } | 562 } |
| 563 | 563 |
| 564 void MessageCenterView::AnimationCanceled(const gfx::Animation* animation) { | 564 void MessageCenterView::AnimationCanceled(const gfx::Animation* animation) { |
| 565 DCHECK_EQ(animation, settings_transition_animation_.get()); | 565 DCHECK_EQ(animation, settings_transition_animation_.get()); |
| 566 AnimationEnded(animation); | 566 AnimationEnded(animation); |
| 567 } | 567 } |
| 568 | 568 |
| 569 void MessageCenterView::AddNotificationAt(const Notification& notification, | 569 void MessageCenterView::AddNotificationAt(const Notification& notification, |
| 570 int index) { | 570 int index) { |
| 571 NotificationView* view = | 571 MessageView* view = |
| 572 NotificationView::Create(this, notification, false); // Not top-level. | 572 NotificationView::Create(this, notification, false); // Not top-level. |
| 573 view->set_context_menu_controller(context_menu_controller_.get()); | 573 view->set_context_menu_controller(context_menu_controller_.get()); |
| 574 notification_views_[notification.id()] = view; | 574 notification_views_[notification.id()] = view; |
| 575 view->set_scroller(scroller_); | 575 view->set_scroller(scroller_); |
| 576 message_list_view_->AddNotificationAt(view, index); | 576 message_list_view_->AddNotificationAt(view, index); |
| 577 } | 577 } |
| 578 | 578 |
| 579 void MessageCenterView::NotificationsChanged() { | 579 void MessageCenterView::NotificationsChanged() { |
| 580 bool no_message_views = notification_views_.empty(); | 580 bool no_message_views = notification_views_.empty(); |
| 581 | 581 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 scroller_->InvalidateLayout(); | 618 scroller_->InvalidateLayout(); |
| 619 PreferredSizeChanged(); | 619 PreferredSizeChanged(); |
| 620 Layout(); | 620 Layout(); |
| 621 } | 621 } |
| 622 | 622 |
| 623 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { | 623 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { |
| 624 message_list_view_->AddNotificationAt(view, 0); | 624 message_list_view_->AddNotificationAt(view, 0); |
| 625 } | 625 } |
| 626 | 626 |
| 627 } // namespace message_center | 627 } // namespace message_center |
| OLD | NEW |