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

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

Issue 2649133009: Merge "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 8e33e369cb25f1de5a8c3a22c3d447bc86426a0f..027fd2a0f15ad4271163795de80f157e6dc09fc3 100644
--- a/ui/arc/notification/arc_custom_notification_view.cc
+++ b/ui/arc/notification/arc_custom_notification_view.cc
@@ -259,7 +259,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);
@@ -301,9 +304,6 @@ void ArcCustomNotificationView::SetSurface(exo::NotificationSurface* surface) {
if (GetWidget())
AttachSurface();
-
- if (item_)
- UpdatePinnedState();
}
}
@@ -377,6 +377,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