| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); | 98 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); |
| 99 scroller_->SetHorizontalScrollBar(new views::OverlayScrollBar(true)); | 99 scroller_->SetHorizontalScrollBar(new views::OverlayScrollBar(true)); |
| 100 scroller_->set_background( | 100 scroller_->set_background( |
| 101 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor)); | 101 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor)); |
| 102 | 102 |
| 103 scroller_->SetPaintToLayer(); | 103 scroller_->SetPaintToLayer(); |
| 104 scroller_->layer()->SetFillsBoundsOpaquely(false); | 104 scroller_->layer()->SetFillsBoundsOpaquely(false); |
| 105 scroller_->layer()->SetMasksToBounds(true); | 105 scroller_->layer()->SetMasksToBounds(true); |
| 106 | 106 |
| 107 message_list_view_.reset(new MessageListView()); | 107 message_list_view_.reset(new MessageListView()); |
| 108 message_list_view_->set_scroller(scroller_); |
| 108 message_list_view_->set_owned_by_client(); | 109 message_list_view_->set_owned_by_client(); |
| 109 message_list_view_->AddObserver(this); | 110 message_list_view_->AddObserver(this); |
| 110 | 111 |
| 111 // We want to swap the contents of the scroll view between the empty list | 112 // We want to swap the contents of the scroll view between the empty list |
| 112 // view and the message list view, without constructing them afresh each | 113 // view and the message list view, without constructing them afresh each |
| 113 // time. So, since the scroll view deletes old contents each time you | 114 // time. So, since the scroll view deletes old contents each time you |
| 114 // set the contents (regardless of the |owned_by_client_| setting) we need | 115 // set the contents (regardless of the |owned_by_client_| setting) we need |
| 115 // an intermediate view for the contents whose children we can swap in and | 116 // an intermediate view for the contents whose children we can swap in and |
| 116 // out. | 117 // out. |
| 117 views::View* scroller_contents = new views::View(); | 118 views::View* scroller_contents = new views::View(); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 Update(true /* animate */); | 389 Update(true /* animate */); |
| 389 } | 390 } |
| 390 | 391 |
| 391 // This is a separate function so we can override it in tests. | 392 // This is a separate function so we can override it in tests. |
| 392 bool MessageCenterView::SetRepositionTarget() { | 393 bool MessageCenterView::SetRepositionTarget() { |
| 393 // Set the item on the mouse cursor as the reposition target so that it | 394 // Set the item on the mouse cursor as the reposition target so that it |
| 394 // should stick to the current position over the update. | 395 // should stick to the current position over the update. |
| 395 if (message_list_view_->IsMouseHovered()) { | 396 if (message_list_view_->IsMouseHovered()) { |
| 396 for (const auto& hover_id_view : notification_views_) { | 397 for (const auto& hover_id_view : notification_views_) { |
| 397 MessageView* hover_view = hover_id_view.second; | 398 MessageView* hover_view = hover_id_view.second; |
| 399 |
| 398 if (hover_view->IsMouseHovered()) { | 400 if (hover_view->IsMouseHovered()) { |
| 399 message_list_view_->SetRepositionTarget(hover_view->bounds()); | 401 message_list_view_->SetRepositionTarget(hover_view->bounds()); |
| 400 return true; | 402 return true; |
| 401 } | 403 } |
| 402 } | 404 } |
| 403 } | 405 } |
| 404 return false; | 406 return false; |
| 405 } | 407 } |
| 406 | 408 |
| 407 void MessageCenterView::OnNotificationUpdated(const std::string& id) { | 409 void MessageCenterView::OnNotificationUpdated(const std::string& id) { |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 // Disable the close-all button since no notification is visible. | 667 // Disable the close-all button since no notification is visible. |
| 666 button_bar_->SetCloseAllButtonEnabled(false); | 668 button_bar_->SetCloseAllButtonEnabled(false); |
| 667 } | 669 } |
| 668 } | 670 } |
| 669 | 671 |
| 670 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { | 672 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { |
| 671 message_list_view_->AddNotificationAt(view, 0); | 673 message_list_view_->AddNotificationAt(view, 0); |
| 672 } | 674 } |
| 673 | 675 |
| 674 } // namespace message_center | 676 } // namespace message_center |
| OLD | NEW |