Commit 1ca121dc authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

views: remove some overrides of DialogDelegate::CreateClientView

One override of this method was a replacement with an
identical implementation in BubbleDialogDelegateView. The other was
BaseDialogContainer, which is part of the app info dialog.

BaseDialogContainer originally moved *from* using a DialogClientView *to* using
its own ClientView to fix https://crbug.com/445695, which was about the dialog
having a strange default button. Since that time, DialogClientView became
perfectly happy to have no default button, so I think that fix is now obsolete.
That allows BaseDialogContainer to use DialogClientView again, which means most
of the reimplementation of DialogClientView there can be removed.

Unfortunately there is one remaining override of this method, in
AssistantContainerView, so it can't yet be marked final.

Bug: 1011446
Change-Id: I9331e847ec2572b4d6dc5e5e2909882ececd9da8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1856538Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705575}
parent e6d08aad
......@@ -80,32 +80,13 @@ class BaseDialogContainer : public views::DialogDelegateView {
BaseDialogContainer(std::unique_ptr<views::View> dialog_body,
const base::Closure& close_callback)
: dialog_body_(AddChildView(std::move(dialog_body))),
close_callback_(close_callback) {
// Since we are using a ClientView instead of a DialogClientView, we need to
// manually bind the escape key to close the dialog.
ui::Accelerator escape(ui::VKEY_ESCAPE, ui::EF_NONE);
AddAccelerator(escape);
}
close_callback_(close_callback) {}
~BaseDialogContainer() override {}
protected:
views::View* dialog_body() { return dialog_body_; }
private:
// Overridden from views::View:
void ViewHierarchyChanged(
const views::ViewHierarchyChangedDetails& details) override {
views::DialogDelegateView::ViewHierarchyChanged(details);
if (details.is_add && details.child == this)
GetFocusManager()->AdvanceFocus(false);
}
bool AcceleratorPressed(const ui::Accelerator& accelerator) override {
DCHECK_EQ(accelerator.key_code(), ui::VKEY_ESCAPE);
GetWidget()->CloseWithReason(views::Widget::ClosedReason::kEscKeyPressed);
return true;
}
// Overridden from views::DialogDelegate:
int GetDialogButtons() const override { return ui::DIALOG_BUTTON_NONE; }
......@@ -115,9 +96,6 @@ class BaseDialogContainer : public views::DialogDelegateView {
if (!close_callback_.is_null())
close_callback_.Run();
}
views::ClientView* CreateClientView(views::Widget* widget) override {
return new views::ClientView(widget, GetContentsView());
}
views::View* dialog_body_;
const base::Closure close_callback_;
......
......@@ -154,11 +154,6 @@ bool BubbleDialogDelegateView::ShouldShowCloseButton() const {
return false;
}
ClientView* BubbleDialogDelegateView::CreateClientView(Widget* widget) {
DialogClientView* client = new DialogClientView(widget, GetContentsView());
return client;
}
NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView(
Widget* widget) {
BubbleFrameView* frame = new BubbleDialogFrameView(title_margins_);
......
......@@ -59,7 +59,6 @@ class VIEWS_EXPORT BubbleDialogDelegateView : public DialogDelegateView,
// DialogDelegateView:
BubbleDialogDelegateView* AsBubbleDialogDelegate() override;
bool ShouldShowCloseButton() const override;
ClientView* CreateClientView(Widget* widget) override;
NonClientFrameView* CreateNonClientFrameView(Widget* widget) override;
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
......
......@@ -59,10 +59,6 @@ class DialogClientViewTest : public test::WidgetTest,
gfx::Size CalculatePreferredSize() const override { return preferred_size_; }
gfx::Size GetMinimumSize() const override { return min_size_; }
gfx::Size GetMaximumSize() const override { return max_size_; }
ClientView* CreateClientView(Widget* widget) override {
client_view_ = new DialogClientView(widget, this);
return client_view_;
}
void DeleteDelegate() override {
// DialogDelegateView would delete this, but |this| is owned by the test.
......@@ -87,9 +83,9 @@ class DialogClientViewTest : public test::WidgetTest,
protected:
gfx::Rect GetUpdatedClientBounds() {
client_view_->SizeToPreferredSize();
client_view_->Layout();
return client_view_->bounds();
client_view()->SizeToPreferredSize();
client_view()->Layout();
return client_view()->bounds();
}
// Makes sure that the content view is sized correctly. Width must be at least
......@@ -148,7 +144,9 @@ class DialogClientViewTest : public test::WidgetTest,
cancel_label_ = base::ASCIIToUTF16("Cancel Cancel Cancel");
}
DialogClientView* client_view() { return client_view_; }
DialogClientView* client_view() {
return static_cast<DialogClientView*>(widget_->client_view());
}
Widget* widget() { return widget_; }
......@@ -156,9 +154,6 @@ class DialogClientViewTest : public test::WidgetTest,
// The dialog Widget.
Widget* widget_ = nullptr;
// The DialogClientView that's being tested. Owned by |widget_|.
DialogClientView* client_view_;
// The bitmask of buttons to show in the dialog.
int dialog_buttons_ = ui::DIALOG_BUTTON_NONE;
......
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