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..5ef22644ee86920a9bfa74f34de86779c8cea3b6 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; |
sky
2017/04/24 15:32:40
optional: name this g_current_tray_showing_count (
Evan Stade
2017/04/27 01:33:48
Done.
|
+ |
} // namespace |
namespace internal { |
@@ -225,6 +229,11 @@ TrayBubbleView::~TrayBubbleView() { |
delegate_->BubbleViewDestroyed(); |
} |
+// static |
+bool TrayBubbleView::IsATrayBubbleOpen() { |
+ return g_current_tray_bubble_view_count_ > 0; |
+} |
+ |
void TrayBubbleView::InitializeAndShowBubble() { |
layer()->parent()->SetMaskLayer(bubble_content_mask_->layer()); |
@@ -232,6 +241,8 @@ void TrayBubbleView::InitializeAndShowBubble() { |
GetWidget()->GetNativeWindow()->SetEventTargeter( |
std::unique_ptr<ui::EventTargeter>(new BubbleWindowTargeter(this))); |
UpdateBubble(); |
+ |
+ ++g_current_tray_bubble_view_count_; |
} |
void TrayBubbleView::UpdateBubble() { |
@@ -278,6 +289,12 @@ void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params, |
params->shadow_elevation = wm::ShadowElevation::LARGE; |
} |
+void TrayBubbleView::OnWidgetClosing(Widget* widget) { |
+ BubbleDialogDelegateView::OnWidgetClosing(widget); |
+ --g_current_tray_bubble_view_count_; |
+ DCHECK_GE(g_current_tray_bubble_view_count_, 0); |
+} |
+ |
NonClientFrameView* TrayBubbleView::CreateNonClientFrameView(Widget* widget) { |
BubbleFrameView* frame = static_cast<BubbleFrameView*>( |
BubbleDialogDelegateView::CreateNonClientFrameView(widget)); |