Commit 253a4890 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

views: de-virtualize GetDialogButtons

Removes the remaining overrides (which are just tests inside Views) and marks
the method not virtual. It should probably be renamed to something like just
'buttons()' at some point.

Bug: 1011446
Change-Id: I8affaf1e80d7f0c2c8245edcd419f3dab14d9472
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2075078
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745081}
parent 32deb2f2
......@@ -68,13 +68,11 @@ class TestBubbleDialogDelegateView : public BubbleDialogDelegateView {
return should_show_close_button_;
}
int GetDialogButtons() const override { return buttons_; }
void set_title_view(View* title_view) { title_view_.reset(title_view); }
void show_close_button() { should_show_close_button_ = true; }
void hide_buttons() {
should_show_close_button_ = false;
buttons_ = ui::DIALOG_BUTTON_NONE;
DialogDelegate::set_buttons(ui::DIALOG_BUTTON_NONE);
}
void set_should_show_window_title(bool should_show_window_title) {
should_show_window_title_ = should_show_window_title;
......@@ -87,7 +85,6 @@ class TestBubbleDialogDelegateView : public BubbleDialogDelegateView {
private:
View* view_ = new View;
std::unique_ptr<View> title_view_;
int buttons_ = ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
bool should_show_close_button_ = false;
bool should_show_window_title_ = true;
......
......@@ -907,6 +907,7 @@ class TestBubbleDialogDelegateView : public BubbleDialogDelegateView {
: BubbleDialogDelegateView(nullptr, BubbleBorder::NONE) {
set_shadow(BubbleBorder::NO_ASSETS);
SetAnchorRect(gfx::Rect());
DialogDelegate::set_buttons(ui::DIALOG_BUTTON_OK);
}
~TestBubbleDialogDelegateView() override = default;
......@@ -938,7 +939,6 @@ class TestBubbleDialogDelegateView : public BubbleDialogDelegateView {
// itself here. But DialogDelegates shouldn't be reused, so check for that.
destroyed_ = true;
}
int GetDialogButtons() const override { return ui::DIALOG_BUTTON_OK; }
gfx::Size CalculatePreferredSize() const override {
return gfx::Size(200, 200);
}
......@@ -977,8 +977,9 @@ class TestAnchor {
// BubbleDialogDelegate with no margins to test width snapping.
class TestWidthSnapDelegate : public TestBubbleDialogDelegateView {
public:
TestWidthSnapDelegate(TestAnchor* anchor, bool should_snap)
: should_snap_(should_snap) {
TestWidthSnapDelegate(TestAnchor* anchor, bool should_snap) {
DialogDelegate::set_buttons(should_snap ? ui::DIALOG_BUTTON_OK
: ui::DIALOG_BUTTON_NONE);
SetAnchorView(anchor->widget().GetContentsView());
set_margins(gfx::Insets());
BubbleDialogDelegateView::CreateBubble(this);
......@@ -987,15 +988,7 @@ class TestWidthSnapDelegate : public TestBubbleDialogDelegateView {
~TestWidthSnapDelegate() override { GetWidget()->CloseNow(); }
// TestBubbleDialogDelegateView:
int GetDialogButtons() const override {
// Only dialogs with buttons get snapped by BubbleFrameView.
return should_snap_ ? ui::DIALOG_BUTTON_OK : ui::DIALOG_BUTTON_NONE;
}
private:
bool should_snap_;
DISALLOW_COPY_AND_ASSIGN(TestWidthSnapDelegate);
};
......
......@@ -728,7 +728,11 @@ TEST_F(RootViewTest, DeleteWidgetOnMouseExitDispatchFromChild) {
namespace {
class RootViewTestDialogDelegate : public DialogDelegateView {
public:
RootViewTestDialogDelegate() = default;
RootViewTestDialogDelegate() {
// Ensure that buttons don't influence the layout.
DialogDelegate::set_buttons(ui::DIALOG_BUTTON_NONE);
}
~RootViewTestDialogDelegate() override = default;
int layout_count() const { return layout_count_; }
......@@ -738,9 +742,6 @@ class RootViewTestDialogDelegate : public DialogDelegateView {
EXPECT_EQ(size(), preferred_size_);
++layout_count_;
}
int GetDialogButtons() const override {
return ui::DIALOG_BUTTON_NONE; // Ensure buttons do not influence size.
}
private:
const gfx::Size preferred_size_ = gfx::Size(111, 111);
......
......@@ -106,10 +106,6 @@ Widget::InitParams DialogDelegate::GetDialogWidgetInitParams(
return params;
}
int DialogDelegate::GetDialogButtons() const {
return params_.buttons;
}
int DialogDelegate::GetDefaultDialogButton() const {
if (GetParams().default_button.has_value())
return *GetParams().default_button;
......
......@@ -89,10 +89,9 @@ class VIEWS_EXPORT DialogDelegate : public WidgetDelegate {
virtual void OnDialogInitialized() {}
// Returns a mask specifying which of the available DialogButtons are visible
// for the dialog. Note: Dialogs with just an OK button are frowned upon.
// DEPRECATED: Prefer to use set_buttons() below; this method is being
// removed. See https://crbug.com/1011446.
virtual int GetDialogButtons() const;
// for the dialog.
// TODO(https://crbug.com/1011446): Rename this to buttons().
int GetDialogButtons() const { return params_.buttons; }
// Returns the default dialog button. This should not be a mask as only
// one button should ever be the default button. Return
......
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