| 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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 void MessagePopupCollection::SetDisplayInfo(const gfx::Rect& work_area, | 554 void MessagePopupCollection::SetDisplayInfo(const gfx::Rect& work_area, |
| 555 const gfx::Rect& screen_bounds) { | 555 const gfx::Rect& screen_bounds) { |
| 556 if (work_area_ == work_area) | 556 if (work_area_ == work_area) |
| 557 return; | 557 return; |
| 558 | 558 |
| 559 work_area_ = work_area; | 559 work_area_ = work_area; |
| 560 ComputePopupAlignment(work_area, screen_bounds); | 560 ComputePopupAlignment(work_area, screen_bounds); |
| 561 RepositionWidgets(); | 561 RepositionWidgets(); |
| 562 } | 562 } |
| 563 | 563 |
| 564 void MessagePopupCollection::OnDisplayBoundsChanged( | |
| 565 const gfx::Display& display) { | |
| 566 if (display.id() != display_id_) | |
| 567 return; | |
| 568 | |
| 569 SetDisplayInfo(display.work_area(), display.bounds()); | |
| 570 } | |
| 571 | |
| 572 void MessagePopupCollection::OnDisplayAdded(const gfx::Display& new_display) { | 564 void MessagePopupCollection::OnDisplayAdded(const gfx::Display& new_display) { |
| 573 } | 565 } |
| 574 | 566 |
| 575 void MessagePopupCollection::OnDisplayRemoved(const gfx::Display& old_display) { | 567 void MessagePopupCollection::OnDisplayRemoved(const gfx::Display& old_display) { |
| 576 if (display_id_ == old_display.id() && !parent_) { | 568 if (display_id_ == old_display.id() && !parent_) { |
| 577 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 569 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 578 display_id_ = display.id(); | 570 display_id_ = display.id(); |
| 579 SetDisplayInfo(display.work_area(), display.bounds()); | 571 SetDisplayInfo(display.work_area(), display.bounds()); |
| 580 } | 572 } |
| 581 } | 573 } |
| 582 | 574 |
| 575 void MessagePopupCollection::OnDisplayMetricsChanged( |
| 576 const gfx::Display& display, |
| 577 DisplayObserver::DisplayMetrics metrics) { |
| 578 if (display.id() != display_id_) |
| 579 return; |
| 580 |
| 581 if (metrics & DISPLAY_METRICS_BOUNDS || metrics & DISPLAY_METRICS_WORK_AREA) |
| 582 SetDisplayInfo(display.work_area(), display.bounds()); |
| 583 } |
| 584 |
| 583 views::Widget* MessagePopupCollection::GetWidgetForTest(const std::string& id) | 585 views::Widget* MessagePopupCollection::GetWidgetForTest(const std::string& id) |
| 584 const { | 586 const { |
| 585 for (Toasts::const_iterator iter = toasts_.begin(); iter != toasts_.end(); | 587 for (Toasts::const_iterator iter = toasts_.begin(); iter != toasts_.end(); |
| 586 ++iter) { | 588 ++iter) { |
| 587 if ((*iter)->id() == id) | 589 if ((*iter)->id() == id) |
| 588 return (*iter)->GetWidget(); | 590 return (*iter)->GetWidget(); |
| 589 } | 591 } |
| 590 return NULL; | 592 return NULL; |
| 591 } | 593 } |
| 592 | 594 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 608 views::Widget* widget = (*iter)->GetWidget(); | 610 views::Widget* widget = (*iter)->GetWidget(); |
| 609 if (widget) | 611 if (widget) |
| 610 return widget->GetWindowBoundsInScreen(); | 612 return widget->GetWindowBoundsInScreen(); |
| 611 break; | 613 break; |
| 612 } | 614 } |
| 613 } | 615 } |
| 614 return gfx::Rect(); | 616 return gfx::Rect(); |
| 615 } | 617 } |
| 616 | 618 |
| 617 } // namespace message_center | 619 } // namespace message_center |
| OLD | NEW |