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( |