Commit 29d3361f authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

views: require anchor point in ToolbarActionsBarBubbleViews

This class now requires an anchor view (which in practice it always has) and
does not support having an anchor point.

Bug: 989080
Change-Id: I7c0b24e5cbe9794ef87c97ce5e6d174938192170
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1749308
Auto-Submit: Elly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Robert Liao <robliao@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686467}
parent 997634f5
...@@ -126,8 +126,7 @@ void ExtensionsToolbarContainer::ShowToolbarActionBubble( ...@@ -126,8 +126,7 @@ void ExtensionsToolbarContainer::ShowToolbarActionBubble(
anchor_view->SetVisible(true); anchor_view->SetVisible(true);
active_bubble_ = new ToolbarActionsBarBubbleViews( active_bubble_ = new ToolbarActionsBarBubbleViews(
anchor_view, gfx::Point(), anchor_view != extensions_button_, anchor_view, anchor_view != extensions_button_, std::move(controller));
std::move(controller));
views::BubbleDialogDelegateView::CreateBubble(active_bubble_) views::BubbleDialogDelegateView::CreateBubble(active_bubble_)
->AddObserver(this); ->AddObserver(this);
active_bubble_->Show(); active_bubble_->Show();
......
...@@ -319,8 +319,7 @@ void BrowserActionsContainer::ShowToolbarActionBubble( ...@@ -319,8 +319,7 @@ void BrowserActionsContainer::ShowToolbarActionBubble(
} }
ToolbarActionsBarBubbleViews* bubble = new ToolbarActionsBarBubbleViews( ToolbarActionsBarBubbleViews* bubble = new ToolbarActionsBarBubbleViews(
anchor_view, gfx::Point(), anchored_to_action_view, anchor_view, anchored_to_action_view, std::move(controller));
std::move(controller));
active_bubble_ = bubble; active_bubble_ = bubble;
views::BubbleDialogDelegateView::CreateBubble(bubble); views::BubbleDialogDelegateView::CreateBubble(bubble);
bubble->GetWidget()->AddObserver(this); bubble->GetWidget()->AddObserver(this);
......
...@@ -27,16 +27,14 @@ const int kBubbleExtraIconSize = 16; ...@@ -27,16 +27,14 @@ const int kBubbleExtraIconSize = 16;
ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews( ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews(
views::View* anchor_view, views::View* anchor_view,
const gfx::Point& anchor_point,
bool anchored_to_action, bool anchored_to_action,
std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate) std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate)
: views::BubbleDialogDelegateView(anchor_view, : views::BubbleDialogDelegateView(anchor_view,
views::BubbleBorder::TOP_RIGHT), views::BubbleBorder::TOP_RIGHT),
delegate_(std::move(delegate)), delegate_(std::move(delegate)),
anchored_to_action_(anchored_to_action) { anchored_to_action_(anchored_to_action) {
DCHECK(anchor_view);
set_close_on_deactivate(delegate_->ShouldCloseOnDeactivate()); set_close_on_deactivate(delegate_->ShouldCloseOnDeactivate());
if (!anchor_view)
SetAnchorRect(gfx::Rect(anchor_point, gfx::Size()));
chrome::RecordDialogCreation(chrome::DialogIdentifier::TOOLBAR_ACTIONS_BAR); chrome::RecordDialogCreation(chrome::DialogIdentifier::TOOLBAR_ACTIONS_BAR);
} }
......
...@@ -22,11 +22,9 @@ class Label; ...@@ -22,11 +22,9 @@ class Label;
class ToolbarActionsBarBubbleViews : public views::BubbleDialogDelegateView, class ToolbarActionsBarBubbleViews : public views::BubbleDialogDelegateView,
public views::ButtonListener { public views::ButtonListener {
public: public:
// Creates the bubble anchored to |anchor_view| or, if that is null, to // Creates the bubble anchored to |anchor_view|, which may not be nullptr.
// |anchor_point| in screen coordinates.
ToolbarActionsBarBubbleViews( ToolbarActionsBarBubbleViews(
views::View* anchor_view, views::View* anchor_view,
const gfx::Point& anchor_point,
bool anchored_to_action, bool anchored_to_action,
std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate); std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate);
~ToolbarActionsBarBubbleViews() override; ~ToolbarActionsBarBubbleViews() override;
......
...@@ -64,7 +64,7 @@ class ToolbarActionsBarBubbleViewsTest : public ChromeViewsTestBase { ...@@ -64,7 +64,7 @@ class ToolbarActionsBarBubbleViewsTest : public ChromeViewsTestBase {
anchor_widget_ = CreateAnchorWidget(); anchor_widget_ = CreateAnchorWidget();
bool anchored_to_action = false; bool anchored_to_action = false;
bubble_ = new ToolbarActionsBarBubbleViews( bubble_ = new ToolbarActionsBarBubbleViews(
anchor_widget_->GetContentsView(), gfx::Point(), anchored_to_action, anchor_widget_->GetContentsView(), anchored_to_action,
delegate->GetDelegate()); delegate->GetDelegate());
bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_); bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_);
bubble_->Show(); bubble_->Show();
...@@ -248,8 +248,7 @@ TEST_F(ToolbarActionsBarBubbleViewsTest, TestShowAndCloseBubble) { ...@@ -248,8 +248,7 @@ TEST_F(ToolbarActionsBarBubbleViewsTest, TestShowAndCloseBubble) {
ActionString()); ActionString());
delegate.set_dismiss_button_text(DismissString()); delegate.set_dismiss_button_text(DismissString());
ToolbarActionsBarBubbleViews* bubble = new ToolbarActionsBarBubbleViews( ToolbarActionsBarBubbleViews* bubble = new ToolbarActionsBarBubbleViews(
anchor_widget->GetContentsView(), gfx::Point(), false, anchor_widget->GetContentsView(), false, delegate.GetDelegate());
delegate.GetDelegate());
EXPECT_FALSE(delegate.shown()); EXPECT_FALSE(delegate.shown());
EXPECT_FALSE(delegate.close_action()); EXPECT_FALSE(delegate.close_action());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment