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

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

Issue 2646143002: arc: Fix CreateFloatingCloseButton crash (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | no next file » | 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 f28246e65a5a959456a666176cfb8e7f0b4e9ab3..81868cc2b32da30cd3acfad7603bc6c4da84954c 100644
--- a/ui/arc/notification/arc_custom_notification_view.cc
+++ b/ui/arc/notification/arc_custom_notification_view.cc
@@ -258,7 +258,10 @@ ArcCustomNotificationView::CreateContentViewDelegate() {
}
void ArcCustomNotificationView::CreateFloatingCloseButton() {
- if (!surface_)
+ // Floating close button is a transient child of |surface_| and also part
+ // of the hosting widget's focus chain. It could only be created when both
+ // are present.
+ if (!surface_ || !GetWidget())
return;
floating_close_button_ = new CloseButton(this);
@@ -300,9 +303,6 @@ void ArcCustomNotificationView::SetSurface(exo::NotificationSurface* surface) {
if (GetWidget())
AttachSurface();
-
- if (item_)
- UpdatePinnedState();
}
}
@@ -371,6 +371,11 @@ void ArcCustomNotificationView::AttachSurface() {
// Invokes Update() in case surface is attached during a slide.
slide_helper_->Update();
+
+ // Updates pinned state to create or destroy the floating close button
+ // after |surface_| is attached to a widget.
+ if (item_)
+ UpdatePinnedState();
}
void ArcCustomNotificationView::ViewHierarchyChanged(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698