Chromium Code Reviews| Index: ui/views/window/dialog_delegate.cc |
| diff --git a/ui/views/window/dialog_delegate.cc b/ui/views/window/dialog_delegate.cc |
| index 81f636723102cb125094045070ea489f5d154ff3..26560cec471be337d83e410f51edc4a1421aa7ff 100644 |
| --- a/ui/views/window/dialog_delegate.cc |
| +++ b/ui/views/window/dialog_delegate.cc |
| @@ -10,6 +10,7 @@ |
| #include "build/build_config.h" |
| #include "ui/accessibility/ax_view_state.h" |
| #include "ui/base/l10n/l10n_util.h" |
| +#include "ui/base/material_design/material_design_controller.h" |
| #include "ui/gfx/color_palette.h" |
| #include "ui/strings/grit/ui_strings.h" |
| #include "ui/views/bubble/bubble_border.h" |
| @@ -128,6 +129,10 @@ void DialogDelegate::UpdateButton(LabelButton* button, ui::DialogButton type) { |
| button->SetIsDefault(is_default); |
| } |
| +DialogDelegate::DialogWidth DialogDelegate::GetDialogWidth() const { |
| + return DIALOG_WIDTH_DEFAULT; |
| +} |
| + |
| int DialogDelegate::GetDialogButtons() const { |
| return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; |
| } |
| @@ -268,4 +273,28 @@ void DialogDelegateView::ViewHierarchyChanged( |
| NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| } |
| +gfx::Size DialogDelegateView::GetPreferredSize() const { |
| + DialogDelegate::DialogWidth width = DialogDelegate::DIALOG_WIDTH_DEFAULT; |
|
Evan Stade
2016/09/28 21:12:38
maybe cleaner (especially when it comes time to re
Elly Fong-Jones
2016/10/03 13:34:44
Done.
|
| + int width_px = 0; |
| + if (ui::MaterialDesignController::IsSecondaryUiMaterial()) |
| + width = GetDialogWidth(); |
| + switch (width) { |
| + // TODO(ellyjones): eventually remove support for DIALOG_WIDTH_DEFAULT once |
| + // all DialogDelegate implementations have GetDefaultDialogWidth(). |
| + case DialogDelegate::DIALOG_WIDTH_DEFAULT: |
|
Evan Stade
2016/09/28 21:12:38
nit: maybe DIALOG_WIDTH_UNSPECIFIED?
Elly Fong-Jones
2016/10/03 13:34:44
Done.
|
| + return View::GetPreferredSize(); |
| + break; |
| + case DialogDelegate::DIALOG_WIDTH_SMALL: |
|
Evan Stade
2016/09/28 21:12:38
perhaps the enum should be:
enum WidthFactor {
Elly Fong-Jones
2016/10/03 13:34:44
Oh, that's really clever! Done.
|
| + width_px = 320; |
| + break; |
| + case DialogDelegate::DIALOG_WIDTH_MEDIUM: |
|
Evan Stade
2016/09/28 21:12:38
nit: don't need to qualify these constants with Di
Elly Fong-Jones
2016/10/03 13:34:44
Done.
|
| + width_px = 448; |
| + break; |
| + case DialogDelegate::DIALOG_WIDTH_LARGE: |
| + width_px = 512; |
| + break; |
| + } |
| + return gfx::Size(width_px, GetHeightForWidth(width_px)); |
| +} |
| + |
| } // namespace views |