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

Unified Diff: ui/views/bubble/tray_bubble_view.cc

Issue 2831233003: Remove ShouldBlockShelfAutoHide(). (Closed)
Patch Set: bubble lifetimes Created 3 years, 8 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
« ui/views/bubble/tray_bubble_view.h ('K') | « ui/views/bubble/tray_bubble_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« ui/views/bubble/tray_bubble_view.h ('K') | « ui/views/bubble/tray_bubble_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698