Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Unified Diff: chrome/browser/ui/views/app_list/app_list_dialog_container.cc

Issue 933163002: Remove default button highlighting from extension info dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove GetInitiallyFocusedView Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/app_list/app_list_dialog_container.cc
diff --git a/chrome/browser/ui/views/app_list/app_list_dialog_container.cc b/chrome/browser/ui/views/app_list/app_list_dialog_container.cc
index c60e48d0372c1bc85dca11960e0ce35eb52aa320..e86ca7dfb8b4cd3123b0e655d15638abc6cb4562 100644
--- a/chrome/browser/ui/views/app_list/app_list_dialog_container.cc
+++ b/chrome/browser/ui/views/app_list/app_list_dialog_container.cc
@@ -53,22 +53,69 @@ class AppListOverlayBackground : public views::Background {
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
// and adds a close button.
-class AppListDialogContainer : public views::DialogDelegateView,
+class AppListDialogContainer : public BaseDialogContainer,
public views::ButtonListener {
public:
AppListDialogContainer(views::View* dialog_body,
const base::Closure& close_callback)
- : dialog_body_(dialog_body),
- close_button_(NULL),
- close_callback_(close_callback) {
+ : BaseDialogContainer(dialog_body, close_callback) {
set_background(new AppListOverlayBackground());
- AddChildView(dialog_body_);
-
close_button_ = views::BubbleFrameView::CreateCloseButton(this);
- ui::Accelerator escape(ui::VKEY_ESCAPE, ui::EF_NONE);
- close_button_->AddAccelerator(escape);
AddChildView(close_button_);
}
~AppListDialogContainer() override {}
@@ -83,26 +130,11 @@ class AppListDialogContainer : public views::DialogDelegateView,
gfx::Point(width() - close_button_->width() - kCloseButtonDialogMargin,
kCloseButtonDialogMargin));
- dialog_body_->SetBoundsRect(GetContentsBounds());
+ dialog_body()->SetBoundsRect(GetContentsBounds());
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:
- 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::Widget* widget) override {
return new views::NativeFrameView(widget);
@@ -117,9 +149,7 @@ class AppListDialogContainer : public views::DialogDelegateView,
}
}
- views::View* dialog_body_;
views::LabelButton* close_button_;
- const base::Closure close_callback_;
DISALLOW_COPY_AND_ASSIGN(AppListDialogContainer);
};
@@ -150,38 +180,22 @@ class FullSizeBubbleFrameView : public views::BubbleFrameView {
};
// A container view for a native dialog, which sizes to the given fixed |size|.
-class NativeDialogContainer : public views::DialogDelegateView {
+class NativeDialogContainer : public BaseDialogContainer {
public:
NativeDialogContainer(views::View* dialog_body,
const gfx::Size& size,
const base::Closure& close_callback)
- : size_(size),
- dialog_body_(dialog_body),
- close_callback_(close_callback) {
+ : BaseDialogContainer(dialog_body, close_callback),
+ size_(size) {
SetLayoutManager(new views::FillLayout());
- AddChildView(dialog_body_);
}
~NativeDialogContainer() override {}
private:
// Overridden from views::View:
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:
- 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::Widget* widget) override {
FullSizeBubbleFrameView* frame = new FullSizeBubbleFrameView();
@@ -195,8 +209,6 @@ class NativeDialogContainer : public views::DialogDelegateView {
}
const gfx::Size size_;
- views::View* dialog_body_;
- const base::Closure close_callback_;
DISALLOW_COPY_AND_ASSIGN(NativeDialogContainer);
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698