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