| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 view = MessageViewFactory::Create(NULL, notification, true); | 167 view = MessageViewFactory::Create(NULL, notification, true); |
| 168 } else | 168 } else |
| 169 #endif // defined(OS_CHROMEOS) | 169 #endif // defined(OS_CHROMEOS) |
| 170 { | 170 { |
| 171 view = MessageViewFactory::Create(NULL, *(*iter), true); | 171 view = MessageViewFactory::Create(NULL, *(*iter), true); |
| 172 } | 172 } |
| 173 | 173 |
| 174 view->set_context_menu_controller(context_menu_controller_.get()); | 174 view->set_context_menu_controller(context_menu_controller_.get()); |
| 175 int view_height = ToastContentsView::GetToastSizeForView(view).height(); | 175 int view_height = ToastContentsView::GetToastSizeForView(view).height(); |
| 176 int height_available = | 176 int height_available = |
| 177 top_down ? alignment_delegate_->GetWorkAreaBottom() - base : base; | 177 top_down ? alignment_delegate_->GetWorkArea().bottom() - base |
| 178 : base - alignment_delegate_->GetWorkArea().y(); |
| 178 | 179 |
| 179 if (height_available - view_height - kToastMarginY < 0) { | 180 if (height_available - view_height - kToastMarginY < 0) { |
| 180 delete view; | 181 delete view; |
| 181 break; | 182 break; |
| 182 } | 183 } |
| 183 | 184 |
| 184 ToastContentsView* toast = new ToastContentsView( | 185 ToastContentsView* toast = new ToastContentsView( |
| 185 (*iter)->id(), alignment_delegate_, weak_factory_.GetWeakPtr()); | 186 (*iter)->id(), alignment_delegate_, weak_factory_.GetWeakPtr()); |
| 186 // There will be no contents already since this is a new ToastContentsView. | 187 // There will be no contents already since this is a new ToastContentsView. |
| 187 toast->SetContents(view, /*a11y_feedback_for_updates=*/false); | 188 toast->SetContents(view, /*a11y_feedback_for_updates=*/false); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 for (Toasts::const_iterator iter = toasts_.begin(); iter != toasts_.end();) { | 289 for (Toasts::const_iterator iter = toasts_.begin(); iter != toasts_.end();) { |
| 289 Toasts::const_iterator curr = iter++; | 290 Toasts::const_iterator curr = iter++; |
| 290 gfx::Rect bounds((*curr)->bounds()); | 291 gfx::Rect bounds((*curr)->bounds()); |
| 291 bounds.set_x(alignment_delegate_->GetToastOriginX(bounds)); | 292 bounds.set_x(alignment_delegate_->GetToastOriginX(bounds)); |
| 292 bounds.set_y(top_down ? base : base - bounds.height()); | 293 bounds.set_y(top_down ? base : base - bounds.height()); |
| 293 | 294 |
| 294 // The notification may scrolls the boundary of the screen due to image | 295 // The notification may scrolls the boundary of the screen due to image |
| 295 // load and such notifications should disappear. Do not call | 296 // load and such notifications should disappear. Do not call |
| 296 // CloseWithAnimation, we don't want to show the closing animation, and we | 297 // CloseWithAnimation, we don't want to show the closing animation, and we |
| 297 // don't want to mark such notifications as shown. See crbug.com/233424 | 298 // don't want to mark such notifications as shown. See crbug.com/233424 |
| 298 if ((top_down ? alignment_delegate_->GetWorkAreaBottom() - bounds.bottom() | 299 if ((top_down |
| 299 : bounds.y()) >= 0) | 300 ? alignment_delegate_->GetWorkArea().bottom() - bounds.bottom() |
| 301 : bounds.y() - alignment_delegate_->GetWorkArea().y()) >= 0) |
| 300 (*curr)->SetBoundsWithAnimation(bounds); | 302 (*curr)->SetBoundsWithAnimation(bounds); |
| 301 else | 303 else |
| 302 RemoveToast(*curr, /*mark_as_shown=*/false); | 304 RemoveToast(*curr, /*mark_as_shown=*/false); |
| 303 | 305 |
| 304 // Shift the base line to be a few pixels above the last added toast or (few | 306 // Shift the base line to be a few pixels above the last added toast or (few |
| 305 // pixels below last added toast if top-aligned). | 307 // pixels below last added toast if top-aligned). |
| 306 if (top_down) | 308 if (top_down) |
| 307 base += bounds.height() + kToastMarginY; | 309 base += bounds.height() + kToastMarginY; |
| 308 else | 310 else |
| 309 base -= bounds.height() + kToastMarginY; | 311 base -= bounds.height() + kToastMarginY; |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 views::Widget* widget = (*iter)->GetWidget(); | 539 views::Widget* widget = (*iter)->GetWidget(); |
| 538 if (widget) | 540 if (widget) |
| 539 return widget->GetWindowBoundsInScreen(); | 541 return widget->GetWindowBoundsInScreen(); |
| 540 break; | 542 break; |
| 541 } | 543 } |
| 542 } | 544 } |
| 543 return gfx::Rect(); | 545 return gfx::Rect(); |
| 544 } | 546 } |
| 545 | 547 |
| 546 } // namespace message_center | 548 } // namespace message_center |
| OLD | NEW |