| Index: ui/arc/notification/arc_custom_notification_view.cc
|
| diff --git a/ui/arc/notification/arc_custom_notification_view.cc b/ui/arc/notification/arc_custom_notification_view.cc
|
| index d4e2faae809e56a859dd488894794c3cc0df37ea..95a6c88e8e2021542f38ac3a36a8507e94a01974 100644
|
| --- a/ui/arc/notification/arc_custom_notification_view.cc
|
| +++ b/ui/arc/notification/arc_custom_notification_view.cc
|
| @@ -25,11 +25,14 @@ ArcCustomNotificationView::ArcCustomNotificationView(
|
| : item_(item), surface_(surface) {
|
| item_->AddObserver(this);
|
| OnItemPinnedChanged();
|
| + surface_->window()->AddObserver(this);
|
| }
|
|
|
| ArcCustomNotificationView::~ArcCustomNotificationView() {
|
| if (item_)
|
| item_->RemoveObserver(this);
|
| + if (surface_ && surface_->window())
|
| + surface_->window()->RemoveObserver(this);
|
| }
|
|
|
| void ArcCustomNotificationView::CreateFloatingCloseButton() {
|
| @@ -66,6 +69,18 @@ void ArcCustomNotificationView::CreateFloatingCloseButton() {
|
| Layout();
|
| }
|
|
|
| +void ArcCustomNotificationView::UpdatePreferredSize() {
|
| + gfx::Size preferred_size = surface_->GetSize();
|
| + if (preferred_size.width() != message_center::kNotificationWidth) {
|
| + const float scale = static_cast<float>(message_center::kNotificationWidth) /
|
| + preferred_size.width();
|
| + preferred_size.SetSize(message_center::kNotificationWidth,
|
| + preferred_size.height() * scale);
|
| + }
|
| +
|
| + SetPreferredSize(preferred_size);
|
| +}
|
| +
|
| void ArcCustomNotificationView::ViewHierarchyChanged(
|
| const views::View::ViewHierarchyChangedDetails& details) {
|
| views::Widget* widget = GetWidget();
|
| @@ -81,15 +96,7 @@ void ArcCustomNotificationView::ViewHierarchyChanged(
|
| if (!widget || !surface_ || !details.is_add)
|
| return;
|
|
|
| - gfx::Size preferred_size = surface_->GetSize();
|
| - if (preferred_size.width() != message_center::kNotificationWidth) {
|
| - const float scale = static_cast<float>(message_center::kNotificationWidth) /
|
| - preferred_size.width();
|
| - preferred_size.SetSize(message_center::kNotificationWidth,
|
| - preferred_size.height() * scale);
|
| - }
|
| -
|
| - SetPreferredSize(preferred_size);
|
| + UpdatePreferredSize();
|
| Attach(surface_->window());
|
| }
|
|
|
| @@ -128,6 +135,16 @@ void ArcCustomNotificationView::ButtonPressed(views::Button* sender,
|
| }
|
| }
|
|
|
| +void ArcCustomNotificationView::OnWindowBoundsChanged(aura::Window* window,
|
| + const gfx::Rect& old_bounds,
|
| + const gfx::Rect& new_bounds) {
|
| + UpdatePreferredSize();
|
| +}
|
| +
|
| +void ArcCustomNotificationView::OnWindowDestroying(aura::Window* window) {
|
| + window->RemoveObserver(this);
|
| +}
|
| +
|
| void ArcCustomNotificationView::OnItemDestroying() {
|
| item_->RemoveObserver(this);
|
| item_ = nullptr;
|
|
|