Chromium Code Reviews| Index: ui/views/bubble/tray_bubble_view.cc |
| diff --git a/ui/views/bubble/tray_bubble_view.cc b/ui/views/bubble/tray_bubble_view.cc |
| index 3d7a93eecae09d4b4d6f03ab71aef2e27a33c54c..f8f937e33c3fe23f0ffd697b23c917ffafe54eb9 100644 |
| --- a/ui/views/bubble/tray_bubble_view.cc |
| +++ b/ui/views/bubble/tray_bubble_view.cc |
| @@ -49,6 +49,10 @@ BubbleBorder::Arrow GetArrowAlignment( |
| return BubbleBorder::RIGHT_BOTTOM; |
| } |
| +// Only one TrayBubbleView is visible at a time, but there are cases where the |
| +// lifetimes of two different bubbles can overlap briefly. |
| +int g_current_tray_bubble_view_count_ = 0; |
| + |
| } // namespace |
| namespace internal { |
| @@ -181,6 +185,11 @@ TrayBubbleView::InitParams::InitParams(AnchorAlignment anchor_alignment, |
| TrayBubbleView::InitParams::InitParams(const InitParams& other) = default; |
| // static |
| +bool TrayBubbleView::IsATrayBubbleOpen() { |
| + return g_current_tray_bubble_view_count_ > 0; |
| +} |
| + |
| +// static |
| TrayBubbleView* TrayBubbleView::Create(View* anchor, |
| Delegate* delegate, |
| InitParams* init_params) { |
| @@ -219,6 +228,9 @@ TrayBubbleView::TrayBubbleView(View* anchor, |
| } |
| TrayBubbleView::~TrayBubbleView() { |
| + --g_current_tray_bubble_view_count_; |
| + DCHECK_GE(g_current_tray_bubble_view_count_, 0); |
| + |
| mouse_watcher_.reset(); |
| // Inform host items (models) that their views are being destroyed. |
| if (delegate_) |
| @@ -232,6 +244,8 @@ void TrayBubbleView::InitializeAndShowBubble() { |
| GetWidget()->GetNativeWindow()->SetEventTargeter( |
| std::unique_ptr<ui::EventTargeter>(new BubbleWindowTargeter(this))); |
| UpdateBubble(); |
| + |
| + ++g_current_tray_bubble_view_count_; |
|
sky
2017/04/21 20:43:49
Is there a reason you like this here rather than t
Evan Stade
2017/04/22 00:10:25
yes. In fact the decrement needs to come earlier,
|
| } |
| void TrayBubbleView::UpdateBubble() { |