Commit 01409da0 authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Add anchor and arrow to BubbleDialogModelHost ctor

These arguments are essentially mandatory and call sites set both of
them.

Bug: 1106422
Change-Id: I85483306b70509e3b5cd0db5559179c88bc97b03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2417062
Auto-Submit: Peter Boström <pbos@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808355}
parent ee903703
......@@ -220,12 +220,10 @@ void BookmarkBubbleView::ShowBubble(
// views:: land below, there's no agnostic reference to arrow / anchors /
// bubbles.
auto bubble =
std::make_unique<views::BubbleDialogModelHost>(std::move(dialog_model));
auto bubble = std::make_unique<views::BubbleDialogModelHost>(
std::move(dialog_model), anchor_view, views::BubbleBorder::TOP_RIGHT);
bubble->SelectAllText(kBookmarkName);
bookmark_bubble_ = bubble.get();
bubble->SetAnchorView(anchor_view);
bubble->SetArrow(views::BubbleBorder::TOP_RIGHT);
if (highlighted_button)
bubble->SetHighlightedButton(highlighted_button);
......
......@@ -160,10 +160,8 @@ void OutdatedUpgradeBubbleView::ShowBubble(views::View* anchor_view,
base::UserMetricsAction("OutdatedUpgradeBubble.Later")))
.Build();
auto bubble =
std::make_unique<views::BubbleDialogModelHost>(std::move(dialog_model));
bubble->SetAnchorView(anchor_view);
bubble->SetArrow(views::BubbleBorder::TOP_RIGHT);
auto bubble = std::make_unique<views::BubbleDialogModelHost>(
std::move(dialog_model), anchor_view, views::BubbleBorder::TOP_RIGHT);
views::BubbleDialogDelegateView::CreateBubble(std::move(bubble))->Show();
chrome::RecordDialogCreation(chrome::DialogIdentifier::OUTDATED_UPGRADE);
......
......@@ -263,10 +263,8 @@ views::BubbleDialogDelegateView* SessionCrashedBubbleView::ShowBubble(
base::Unretained(bubble_delegate), browser),
l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON));
auto bubble =
std::make_unique<views::BubbleDialogModelHost>(dialog_builder.Build());
bubble->SetAnchorView(anchor_view);
bubble->SetArrow(views::BubbleBorder::TOP_RIGHT);
auto bubble = std::make_unique<views::BubbleDialogModelHost>(
dialog_builder.Build(), anchor_view, views::BubbleBorder::TOP_RIGHT);
views::BubbleDialogDelegateView* bubble_ptr = bubble.get();
views::BubbleDialogDelegateView::CreateBubble(bubble.release())->Show();
......
......@@ -74,8 +74,10 @@ std::unique_ptr<View> CreateCheckboxControl(std::unique_ptr<Checkbox> checkbox,
} // namespace
BubbleDialogModelHost::BubbleDialogModelHost(
std::unique_ptr<ui::DialogModel> model)
: model_(std::move(model)) {
std::unique_ptr<ui::DialogModel> model,
View* anchor_view,
BubbleBorder::Arrow arrow)
: BubbleDialogDelegateView(anchor_view, arrow), model_(std::move(model)) {
model_->set_host(GetPassKey(), this);
ConfigureGridLayout();
......
......@@ -18,14 +18,13 @@ class GridLayout;
class Textfield;
// BubbleDialogModelHost is a views implementation of ui::DialogModelHost which
// hosts a ui::DialogModel as a BubbleDialogDelegateView. This exposes
// views-specific methods such as SetAnchorView(), SetArrow() and
// SetHighlightedButton(). For methods that are reflected in ui::DialogModelHost
// (such as ::Close()), prefer using the ui::DialogModelHost to avoid
// platform-specific code (GetWidget()->Close()) where unnecessary. For those
// methods, note that this can be retrieved as a ui::DialogModelHost through
// DialogModel::host(). This helps minimize platform-specific code from
// platform-agnostic model-delegate code.
// hosts a ui::DialogModel as a BubbleDialogDelegateView. This exposes such as
// SetAnchorView(), SetArrow() and SetHighlightedButton(). For methods that are
// reflected in ui::DialogModelHost (such as ::Close()), prefer using the
// ui::DialogModelHost to avoid platform-specific code (GetWidget()->Close())
// where unnecessary. For those methods, note that this can be retrieved as a
// ui::DialogModelHost through DialogModel::host(). This helps minimize
// platform-specific code from platform-agnostic model-delegate code.
class VIEWS_EXPORT BubbleDialogModelHost : public BubbleDialogDelegateView,
public ui::DialogModelHost {
public:
......@@ -33,7 +32,9 @@ class VIEWS_EXPORT BubbleDialogModelHost : public BubbleDialogDelegateView,
// BubbleDialogDelegateView. The BubbleDialogDelegateView is nominally handed
// to BubbleDialogDelegateView::CreateBubble() which returns a Widget that has
// taken ownership of the bubble. Widget::Show() finally shows the bubble.
explicit BubbleDialogModelHost(std::unique_ptr<ui::DialogModel> model);
BubbleDialogModelHost(std::unique_ptr<ui::DialogModel> model,
View* anchor_view,
BubbleBorder::Arrow arrow);
~BubbleDialogModelHost() override;
// BubbleDialogDelegateView:
......
......@@ -59,9 +59,9 @@ TEST_F(BubbleDialogModelHostTest, CloseIsSynchronousAndCallsWindowClosing) {
auto delegate = std::make_unique<TestModelDelegate>(&stats);
auto weak_delegate = delegate->GetWeakPtr();
auto host = std::make_unique<views::BubbleDialogModelHost>(
TestModelDelegate::BuildModel(std::move(delegate)));
host->SetAnchorView(anchor_widget->GetContentsView());
auto host = std::make_unique<BubbleDialogModelHost>(
TestModelDelegate::BuildModel(std::move(delegate)),
anchor_widget->GetContentsView(), BubbleBorder::Arrow::TOP_RIGHT);
auto* host_ptr = host.get();
Widget* bubble_widget =
......
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