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

Unified Diff: ash/system/toast/toast_overlay.cc

Issue 1841563003: ARC Toast: Prevent onClosed event from being called multiple times (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « ash/system/toast/toast_overlay.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
}
« no previous file with comments | « ash/system/toast/toast_overlay.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698