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(
anchor_view->SetVisible(true);
active_bubble_ = new ToolbarActionsBarBubbleViews(
anchor_view, gfx::Point(), anchor_view != extensions_button_,
std::move(controller));
anchor_view, anchor_view != extensions_button_, std::move(controller));
views::BubbleDialogDelegateView::CreateBubble(active_bubble_)
->AddObserver(this);
active_bubble_->Show();
......
......@@ -319,8 +319,7 @@ void BrowserActionsContainer::ShowToolbarActionBubble(
}
ToolbarActionsBarBubbleViews* bubble = new ToolbarActionsBarBubbleViews(
anchor_view, gfx::Point(), anchored_to_action_view,
std::move(controller));
anchor_view, anchored_to_action_view, std::move(controller));
active_bubble_ = bubble;
views::BubbleDialogDelegateView::CreateBubble(bubble);
bubble->GetWidget()->AddObserver(this);
......
......@@ -27,16 +27,14 @@ const int kBubbleExtraIconSize = 16;
ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews(
views::View* anchor_view,
const gfx::Point& anchor_point,
bool anchored_to_action,
std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate)
: views::BubbleDialogDelegateView(anchor_view,
views::BubbleBorder::TOP_RIGHT),
delegate_(std::move(delegate)),
anchored_to_action_(anchored_to_action) {
DCHECK(anchor_view);
set_close_on_deactivate(delegate_->ShouldCloseOnDeactivate());
if (!anchor_view)
SetAnchorRect(gfx::Rect(anchor_point, gfx::Size()));
chrome::RecordDialogCreation(chrome::DialogIdentifier::TOOLBAR_ACTIONS_BAR);
}
......
......@@ -22,11 +22,9 @@ class Label;
class ToolbarActionsBarBubbleViews : public views::BubbleDialogDelegateView,
public views::ButtonListener {
public:
// Creates the bubble anchored to |anchor_view| or, if that is null, to
// |anchor_point| in screen coordinates.
// Creates the bubble anchored to |anchor_view|, which may not be nullptr.
ToolbarActionsBarBubbleViews(
views::View* anchor_view,
const gfx::Point& anchor_point,
bool anchored_to_action,
std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate);
~ToolbarActionsBarBubbleViews() override;
......
......@@ -64,7 +64,7 @@ class ToolbarActionsBarBubbleViewsTest : public ChromeViewsTestBase {
anchor_widget_ = CreateAnchorWidget();
bool anchored_to_action = false;
bubble_ = new ToolbarActionsBarBubbleViews(
anchor_widget_->GetContentsView(), gfx::Point(), anchored_to_action,
anchor_widget_->GetContentsView(), anchored_to_action,
delegate->GetDelegate());
bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_);
bubble_->Show();
......@@ -248,8 +248,7 @@ TEST_F(ToolbarActionsBarBubbleViewsTest, TestShowAndCloseBubble) {
ActionString());
delegate.set_dismiss_button_text(DismissString());
ToolbarActionsBarBubbleViews* bubble = new ToolbarActionsBarBubbleViews(
anchor_widget->GetContentsView(), gfx::Point(), false,
delegate.GetDelegate());
anchor_widget->GetContentsView(), false, delegate.GetDelegate());
EXPECT_FALSE(delegate.shown());
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