Chromium Code Reviews| Index: ash/system/toast/toast_overlay.cc |
| diff --git a/ash/system/toast/toast_overlay.cc b/ash/system/toast/toast_overlay.cc |
| index 3864c9c3eaa06119bac3d5ed622393614d1b9679..0222f4adf822adde43fd70a78dade6ad06928afd 100644 |
| --- a/ash/system/toast/toast_overlay.cc |
| +++ b/ash/system/toast/toast_overlay.cc |
| @@ -222,10 +222,12 @@ void ToastOverlay::Show(bool visible) { |
| overlay_widget_->GetLayer()->GetAnimator()->AddObserver(this); |
| - if (is_visible_) |
| + if (is_visible_) { |
| overlay_widget_->Show(); |
| - else |
| + } else { |
| overlay_widget_->Hide(); |
| + close_event_fired_ = false; |
|
oshima
2016/03/30 19:11:50
(if you still need this)
move this before Hide bec
yoshiki
2016/04/01 18:32:35
Done.
|
| + } |
| } |
| gfx::Rect ToastOverlay::CalculateOverlayBounds() { |
| @@ -244,13 +246,16 @@ void ToastOverlay::OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) { |
| ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); |
| if (animator) |
| animator->RemoveObserver(this); |
| - if (!is_visible_) { |
| + if (!is_visible_ && !close_event_fired_) { |
|
oshima
2016/03/30 19:11:50
can't you just check overlay_widget_'s visibility?
yoshiki
2016/04/01 18:32:35
Here overlay_widget_'s visibility is synced with |
oshima
2016/04/01 19:15:10
My question was do you even need is_visible_. Can'
yoshiki
2016/04/06 17:34:07
Sorry I was wrong. When this method is called, wid
|
| // Acync operation, since delegate may remove this instance and removing |
| // this here causes crash. |
| base::ThreadTaskRunnerHandle::Get()->PostTask( |
| FROM_HERE, |
| base::Bind(&Delegate::OnClosed, |
| base::Unretained(delegate_) /* |delegate| lives longer */)); |
| + |
| + // Prevent tha handler calling multiple times. |
| + close_event_fired_ = true; |
| } |
| } |