Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: ui/arc/notification/arc_custom_notification_view.cc

Issue 2223583002: Merge "arc: Support custom notification size change" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/arc/notification/arc_custom_notification_view.h ('k') | ui/message_center/views/message_center_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « ui/arc/notification/arc_custom_notification_view.h ('k') | ui/message_center/views/message_center_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698