Skip to content

Commit

Permalink
Merge "arc: Fix CreateFloatingCloseButton crash"
Browse files Browse the repository at this point in the history
> Move UpdatePinnedState into AttachSurface since floating close button
> participates in the focus chain of the hosting widget now. To create it,
> both |surface_| and the hosting widget needs to be present.
>
> BUG=682868
>
> Review-Url: https://codereview.chromium.org/2646143002
> Cr-Commit-Position: refs/heads/master@{#445754}
> (cherry picked from commit 57d39ed)

Review-Url: https://codereview.chromium.org/2649133009 .
Cr-Commit-Position: refs/branch-heads/2987@{#61}
Cr-Branched-From: ad51088-refs/heads/master@{#444943}
  • Loading branch information
Xiyuan Xia committed Jan 24, 2017
1 parent 1901480 commit 1b0254b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ui/arc/notification/arc_custom_notification_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -301,9 +304,6 @@ void ArcCustomNotificationView::SetSurface(exo::NotificationSurface* surface) {

if (GetWidget())
AttachSurface();

if (item_)
UpdatePinnedState();
}
}

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 1b0254b

Please sign in to comment.