Commit b5bbc014 authored by tsergeant's avatar tsergeant Committed by Commit bot

Remove default button highlighting from extension info dialog

This dialog does not have a single call-to-action button. Additionally,
the existing highlight implementation is a side-effect of using
DialogClientView, which is not well suited to this container. This CL
changes NativeDialogContainer to use a regular ClientView, removing the
default highlighting from the dialog, and refactors the two containers
to use a common base class.

BUG=445695

Review URL: https://codereview.chromium.org/933163002

Cr-Commit-Position: refs/heads/master@{#318206}
parent 179e3007
...@@ -53,22 +53,69 @@ class AppListOverlayBackground : public views::Background { ...@@ -53,22 +53,69 @@ class AppListOverlayBackground : public views::Background {
DISALLOW_COPY_AND_ASSIGN(AppListOverlayBackground); DISALLOW_COPY_AND_ASSIGN(AppListOverlayBackground);
}; };
// Base container for modal dialogs. Encases a content view in a modal dialog
// with an accelerator to close on escape.
class BaseDialogContainer : public views::DialogDelegateView {
public:
BaseDialogContainer(views::View* dialog_body,
const base::Closure& close_callback)
: dialog_body_(dialog_body),
close_callback_(close_callback) {
AddChildView(dialog_body_);
// 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);
}
~BaseDialogContainer() override {}
protected:
views::View* dialog_body() { return dialog_body_; }
private:
// Overridden from views::View:
void ViewHierarchyChanged(
const 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()->Close();
return true;
}
// Overridden from views::DialogDelegate:
int GetDialogButtons() const override { return ui::DIALOG_BUTTON_NONE; }
// Overridden from views::WidgetDelegate:
ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_WINDOW; }
void WindowClosing() override {
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_;
DISALLOW_COPY_AND_ASSIGN(BaseDialogContainer);
};
// The contents view for an App List Dialog, which covers the entire app list // The contents view for an App List Dialog, which covers the entire app list
// and adds a close button. // and adds a close button.
class AppListDialogContainer : public views::DialogDelegateView, class AppListDialogContainer : public BaseDialogContainer,
public views::ButtonListener { public views::ButtonListener {
public: public:
AppListDialogContainer(views::View* dialog_body, AppListDialogContainer(views::View* dialog_body,
const base::Closure& close_callback) const base::Closure& close_callback)
: dialog_body_(dialog_body), : BaseDialogContainer(dialog_body, close_callback) {
close_button_(NULL),
close_callback_(close_callback) {
set_background(new AppListOverlayBackground()); set_background(new AppListOverlayBackground());
AddChildView(dialog_body_);
close_button_ = views::BubbleFrameView::CreateCloseButton(this); close_button_ = views::BubbleFrameView::CreateCloseButton(this);
ui::Accelerator escape(ui::VKEY_ESCAPE, ui::EF_NONE);
close_button_->AddAccelerator(escape);
AddChildView(close_button_); AddChildView(close_button_);
} }
~AppListDialogContainer() override {} ~AppListDialogContainer() override {}
...@@ -83,26 +130,11 @@ class AppListDialogContainer : public views::DialogDelegateView, ...@@ -83,26 +130,11 @@ class AppListDialogContainer : public views::DialogDelegateView,
gfx::Point(width() - close_button_->width() - kCloseButtonDialogMargin, gfx::Point(width() - close_button_->width() - kCloseButtonDialogMargin,
kCloseButtonDialogMargin)); kCloseButtonDialogMargin));
dialog_body_->SetBoundsRect(GetContentsBounds()); dialog_body()->SetBoundsRect(GetContentsBounds());
views::DialogDelegateView::Layout(); views::DialogDelegateView::Layout();
} }
void ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) override {
views::DialogDelegateView::ViewHierarchyChanged(details);
if (details.is_add && details.child == this)
GetFocusManager()->AdvanceFocus(false);
}
// Overridden from views::WidgetDelegate: // Overridden from views::WidgetDelegate:
views::View* GetInitiallyFocusedView() override { return NULL; }
ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_WINDOW; }
void WindowClosing() override {
if (!close_callback_.is_null())
close_callback_.Run();
}
views::ClientView* CreateClientView(views::Widget* widget) override {
return new views::ClientView(widget, GetContentsView());
}
views::NonClientFrameView* CreateNonClientFrameView( views::NonClientFrameView* CreateNonClientFrameView(
views::Widget* widget) override { views::Widget* widget) override {
return new views::NativeFrameView(widget); return new views::NativeFrameView(widget);
...@@ -117,9 +149,7 @@ class AppListDialogContainer : public views::DialogDelegateView, ...@@ -117,9 +149,7 @@ class AppListDialogContainer : public views::DialogDelegateView,
} }
} }
views::View* dialog_body_;
views::LabelButton* close_button_; views::LabelButton* close_button_;
const base::Closure close_callback_;
DISALLOW_COPY_AND_ASSIGN(AppListDialogContainer); DISALLOW_COPY_AND_ASSIGN(AppListDialogContainer);
}; };
...@@ -150,38 +180,22 @@ class FullSizeBubbleFrameView : public views::BubbleFrameView { ...@@ -150,38 +180,22 @@ class FullSizeBubbleFrameView : public views::BubbleFrameView {
}; };
// A container view for a native dialog, which sizes to the given fixed |size|. // A container view for a native dialog, which sizes to the given fixed |size|.
class NativeDialogContainer : public views::DialogDelegateView { class NativeDialogContainer : public BaseDialogContainer {
public: public:
NativeDialogContainer(views::View* dialog_body, NativeDialogContainer(views::View* dialog_body,
const gfx::Size& size, const gfx::Size& size,
const base::Closure& close_callback) const base::Closure& close_callback)
: size_(size), : BaseDialogContainer(dialog_body, close_callback),
dialog_body_(dialog_body), size_(size) {
close_callback_(close_callback) {
SetLayoutManager(new views::FillLayout()); SetLayoutManager(new views::FillLayout());
AddChildView(dialog_body_);
} }
~NativeDialogContainer() override {} ~NativeDialogContainer() override {}
private: private:
// Overridden from views::View: // Overridden from views::View:
gfx::Size GetPreferredSize() const override { return size_; } gfx::Size GetPreferredSize() const override { return size_; }
void ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) override {
views::DialogDelegateView::ViewHierarchyChanged(details);
if (details.is_add && details.child == this)
GetFocusManager()->AdvanceFocus(false);
}
// Overridden from views::WidgetDelegate: // Overridden from views::WidgetDelegate:
ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_WINDOW; }
void WindowClosing() override {
if (!close_callback_.is_null())
close_callback_.Run();
}
// Overridden from views::DialogDelegate:
int GetDialogButtons() const override { return ui::DIALOG_BUTTON_NONE; }
views::NonClientFrameView* CreateNonClientFrameView( views::NonClientFrameView* CreateNonClientFrameView(
views::Widget* widget) override { views::Widget* widget) override {
FullSizeBubbleFrameView* frame = new FullSizeBubbleFrameView(); FullSizeBubbleFrameView* frame = new FullSizeBubbleFrameView();
...@@ -195,8 +209,6 @@ class NativeDialogContainer : public views::DialogDelegateView { ...@@ -195,8 +209,6 @@ class NativeDialogContainer : public views::DialogDelegateView {
} }
const gfx::Size size_; const gfx::Size size_;
views::View* dialog_body_;
const base::Closure close_callback_;
DISALLOW_COPY_AND_ASSIGN(NativeDialogContainer); DISALLOW_COPY_AND_ASSIGN(NativeDialogContainer);
}; };
......
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