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_popup_collection.h" | 5 #include "ui/message_center/views/message_popup_collection.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // just closed, the timeout is shorter. | 41 // just closed, the timeout is shorter. |
42 const int kMouseExitedDeferTimeoutMs = 200; | 42 const int kMouseExitedDeferTimeoutMs = 200; |
43 | 43 |
44 // The margin between messages (and between the anchor unless | 44 // The margin between messages (and between the anchor unless |
45 // first_item_has_no_margin was specified). | 45 // first_item_has_no_margin was specified). |
46 const int kToastMarginY = kMarginBetweenItems; | 46 const int kToastMarginY = kMarginBetweenItems; |
47 | 47 |
48 } // namespace. | 48 } // namespace. |
49 | 49 |
50 MessagePopupCollection::MessagePopupCollection( | 50 MessagePopupCollection::MessagePopupCollection( |
51 gfx::NativeView parent, | |
52 MessageCenter* message_center, | 51 MessageCenter* message_center, |
53 MessageCenterTray* tray, | 52 MessageCenterTray* tray, |
54 PopupAlignmentDelegate* alignment_delegate) | 53 PopupAlignmentDelegate* alignment_delegate) |
55 : parent_(parent), | 54 : message_center_(message_center), |
56 message_center_(message_center), | |
57 tray_(tray), | 55 tray_(tray), |
58 alignment_delegate_(alignment_delegate), | 56 alignment_delegate_(alignment_delegate), |
59 defer_counter_(0), | 57 defer_counter_(0), |
60 latest_toast_entered_(NULL), | 58 latest_toast_entered_(NULL), |
61 user_is_closing_toasts_by_clicking_(false), | 59 user_is_closing_toasts_by_clicking_(false), |
| 60 target_top_edge_(0), |
62 context_menu_controller_(new MessageViewContextMenuController(this)), | 61 context_menu_controller_(new MessageViewContextMenuController(this)), |
63 weak_factory_(this) { | 62 weak_factory_(this) { |
64 DCHECK(message_center_); | 63 DCHECK(message_center_); |
65 defer_timer_.reset(new base::OneShotTimer); | 64 defer_timer_.reset(new base::OneShotTimer); |
66 message_center_->AddObserver(this); | 65 message_center_->AddObserver(this); |
67 alignment_delegate_->set_collection(this); | 66 alignment_delegate_->set_collection(this); |
68 } | 67 } |
69 | 68 |
70 MessagePopupCollection::~MessagePopupCollection() { | 69 MessagePopupCollection::~MessagePopupCollection() { |
71 weak_factory_.InvalidateWeakPtrs(); | 70 weak_factory_.InvalidateWeakPtrs(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 view->set_context_menu_controller(context_menu_controller_.get()); | 174 view->set_context_menu_controller(context_menu_controller_.get()); |
176 int view_height = ToastContentsView::GetToastSizeForView(view).height(); | 175 int view_height = ToastContentsView::GetToastSizeForView(view).height(); |
177 int height_available = | 176 int height_available = |
178 top_down ? alignment_delegate_->GetWorkAreaBottom() - base : base; | 177 top_down ? alignment_delegate_->GetWorkAreaBottom() - base : base; |
179 | 178 |
180 if (height_available - view_height - kToastMarginY < 0) { | 179 if (height_available - view_height - kToastMarginY < 0) { |
181 delete view; | 180 delete view; |
182 break; | 181 break; |
183 } | 182 } |
184 | 183 |
185 ToastContentsView* toast = | 184 ToastContentsView* toast = new ToastContentsView( |
186 new ToastContentsView((*iter)->id(), weak_factory_.GetWeakPtr()); | 185 (*iter)->id(), alignment_delegate_, weak_factory_.GetWeakPtr()); |
187 // There will be no contents already since this is a new ToastContentsView. | 186 // There will be no contents already since this is a new ToastContentsView. |
188 toast->SetContents(view, /*a11y_feedback_for_updates=*/false); | 187 toast->SetContents(view, /*a11y_feedback_for_updates=*/false); |
189 toasts_.push_back(toast); | 188 toasts_.push_back(toast); |
190 view->set_controller(toast); | 189 view->set_controller(toast); |
191 | 190 |
192 gfx::Size preferred_size = toast->GetPreferredSize(); | 191 gfx::Size preferred_size = toast->GetPreferredSize(); |
193 gfx::Point origin( | 192 gfx::Point origin( |
194 alignment_delegate_->GetToastOriginX(gfx::Rect(preferred_size)), base); | 193 alignment_delegate_->GetToastOriginX(gfx::Rect(preferred_size)), base); |
195 // The toast slides in from the edge of the screen horizontally. | 194 // The toast slides in from the edge of the screen horizontally. |
196 if (alignment_delegate_->IsFromLeft()) | 195 if (alignment_delegate_->IsFromLeft()) |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 views::Widget* widget = (*iter)->GetWidget(); | 537 views::Widget* widget = (*iter)->GetWidget(); |
539 if (widget) | 538 if (widget) |
540 return widget->GetWindowBoundsInScreen(); | 539 return widget->GetWindowBoundsInScreen(); |
541 break; | 540 break; |
542 } | 541 } |
543 } | 542 } |
544 return gfx::Rect(); | 543 return gfx::Rect(); |
545 } | 544 } |
546 | 545 |
547 } // namespace message_center | 546 } // namespace message_center |
OLD | NEW |