Index: ash/common/shelf/overflow_bubble.cc |
diff --git a/ash/common/shelf/overflow_bubble.cc b/ash/common/shelf/overflow_bubble.cc |
index fccafd0496dfa5e88b841da3fb0a65053a125c15..9ad6f350813b32e352325df6c31f396b3b87fc8d 100644 |
--- a/ash/common/shelf/overflow_bubble.cc |
+++ b/ash/common/shelf/overflow_bubble.cc |
@@ -5,6 +5,7 @@ |
#include "ash/common/shelf/overflow_bubble.h" |
#include "ash/common/shelf/overflow_bubble_view.h" |
+#include "ash/common/shelf/overflow_button.h" |
#include "ash/common/shelf/shelf_view.h" |
#include "ash/common/shelf/wm_shelf.h" |
#include "ash/common/system/tray/tray_background_view.h" |
@@ -17,7 +18,7 @@ namespace ash { |
OverflowBubble::OverflowBubble(WmShelf* wm_shelf) |
: wm_shelf_(wm_shelf), |
bubble_(nullptr), |
- anchor_(nullptr), |
+ button_(nullptr), |
shelf_view_(nullptr) { |
const bool wants_moves = false; |
WmShell::Get()->AddPointerWatcher(this, wants_moves); |
@@ -28,50 +29,45 @@ OverflowBubble::~OverflowBubble() { |
WmShell::Get()->RemovePointerWatcher(this); |
} |
-void OverflowBubble::Show(views::View* anchor, ShelfView* shelf_view) { |
- DCHECK(anchor); |
+void OverflowBubble::Show(OverflowButton* button, ShelfView* shelf_view) { |
+ DCHECK(button); |
DCHECK(shelf_view); |
Hide(); |
bubble_ = new OverflowBubbleView(wm_shelf_); |
- bubble_->InitOverflowBubble(anchor, shelf_view); |
+ bubble_->InitOverflowBubble(button, shelf_view); |
shelf_view_ = shelf_view; |
- anchor_ = anchor; |
+ button_ = button; |
TrayBackgroundView::InitializeBubbleAnimations(bubble_->GetWidget()); |
bubble_->GetWidget()->AddObserver(this); |
bubble_->GetWidget()->Show(); |
+ |
+ button->OnOverflowBubbleShown(); |
} |
void OverflowBubble::Hide() { |
if (!IsShowing()) |
return; |
+ OverflowButton* button = button_; |
+ |
bubble_->GetWidget()->RemoveObserver(this); |
bubble_->GetWidget()->Close(); |
- bubble_ = NULL; |
- anchor_ = NULL; |
- shelf_view_ = NULL; |
-} |
- |
-void OverflowBubble::HideBubbleAndRefreshButton() { |
- if (!IsShowing()) |
- return; |
+ bubble_ = nullptr; |
+ button_ = nullptr; |
+ shelf_view_ = nullptr; |
- views::View* anchor = anchor_; |
- Hide(); |
- // Update overflow button (|anchor|) status when overflow bubble is hidden |
- // by outside event of overflow button. |
- anchor->SchedulePaint(); |
+ button->OnOverflowBubbleHidden(); |
} |
void OverflowBubble::ProcessPressedEvent( |
const gfx::Point& event_location_in_screen) { |
if (IsShowing() && !shelf_view_->IsShowingMenu() && |
!bubble_->GetBoundsInScreen().Contains(event_location_in_screen) && |
- !anchor_->GetBoundsInScreen().Contains(event_location_in_screen)) { |
- HideBubbleAndRefreshButton(); |
+ !button_->GetBoundsInScreen().Contains(event_location_in_screen)) { |
+ Hide(); |
} |
} |
@@ -86,9 +82,9 @@ void OverflowBubble::OnPointerEventObserved( |
void OverflowBubble::OnWidgetDestroying(views::Widget* widget) { |
DCHECK(widget == bubble_->GetWidget()); |
// Update the overflow button in the parent ShelfView. |
- anchor_->SchedulePaint(); |
+ button_->SchedulePaint(); |
bubble_ = nullptr; |
- anchor_ = nullptr; |
+ button_ = nullptr; |
shelf_view_ = nullptr; |
} |