Chromium Code Reviews| Index: chrome/browser/printing/print_preview_dialog_controller.cc |
| diff --git a/chrome/browser/printing/print_preview_dialog_controller.cc b/chrome/browser/printing/print_preview_dialog_controller.cc |
| index 6211d5c39e99661f74f0542e1160510e06b3018d..19b350146c2c2def6c364ec7bffb0c249b4d0a95 100644 |
| --- a/chrome/browser/printing/print_preview_dialog_controller.cc |
| +++ b/chrome/browser/printing/print_preview_dialog_controller.cc |
| @@ -78,9 +78,7 @@ PrintPreviewDialogDelegate::~PrintPreviewDialogDelegate() { |
| } |
| ui::ModalType PrintPreviewDialogDelegate::GetDialogModalType() const { |
| - // Not used, returning dummy value. |
| - NOTREACHED(); |
| - return ui::MODAL_TYPE_WINDOW; |
| + return ui::MODAL_TYPE_CHILD; |
| } |
| base::string16 PrintPreviewDialogDelegate::GetDialogTitle() const { |
| @@ -99,10 +97,16 @@ void PrintPreviewDialogDelegate::GetWebUIMessageHandlers( |
| void PrintPreviewDialogDelegate::GetDialogSize(gfx::Size* size) const { |
| DCHECK(size); |
| - const gfx::Size kMinDialogSize(800, 480); |
| const int kBorder = 25; |
| +// Gives ChromeOS dialogs the requested minimum size of 438x455 without changing |
| +// the existing behavior on Mac OSX. For all other platforms, the min size |
| +// is later overriden by the size of the parent window. |
|
Lei Zhang
2016/08/18 20:30:57
overridden?
rbpotter
2016/08/19 01:59:09
Done.
|
| +#if defined(OS_MACOSX) |
| + const gfx::Size kMinDialogSize(800, 480); |
| +#else |
| + const gfx::Size kMinDialogSize(438, 455); |
|
Lei Zhang
2016/08/18 20:30:57
So no behavior changes on Windows/Linux, right?
rbpotter
2016/08/19 01:59:09
There will be no behavior changes in terms of the
Lei Zhang
2016/08/19 03:28:46
No, seems ok.
|
| +#endif |
| *size = kMinDialogSize; |
| - |
| web_modal::WebContentsModalDialogHost* host = nullptr; |
| content::WebContents* outermost_web_contents = |
| guest_view::GuestViewBase::GetTopLevelWebContents(initiator_); |
| @@ -114,8 +118,15 @@ void PrintPreviewDialogDelegate::GetDialogSize(gfx::Size* size) const { |
| size->SetToMax(host->GetMaximumDialogSize()); |
| else |
| size->SetToMax(outermost_web_contents->GetContainerBounds().size()); |
| +#if defined(OS_MACOSX) |
| size->Enlarge(-2 * kBorder, -kBorder); |
| - |
| +#else |
| + int expand_width = |
| + std::min(size->width() - kMinDialogSize.width(), 2 * kBorder); |
| + int expand_height = |
| + std::min(size->height() - kMinDialogSize.height(), kBorder); |
| + size->Enlarge(-expand_width, -expand_height); |
|
Lei Zhang
2016/08/18 20:30:57
Why not just calculate |expand_width| so it's nega
rbpotter
2016/08/19 01:59:09
Done. I thought it was more readable to take the m
Lei Zhang
2016/08/19 03:28:46
*shrug* If you like it better the other way, feel
|
| +#endif |
| #if defined(OS_MACOSX) |
| // Limit the maximum size on MacOS X. |
| // http://crbug.com/105815 |
| @@ -365,10 +376,9 @@ WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog( |
| // The dialog delegates are deleted when the dialog is closed. |
| ConstrainedWebDialogDelegate* web_dialog_delegate = |
| - ShowConstrainedWebDialog(initiator->GetBrowserContext(), |
| - new PrintPreviewDialogDelegate(initiator), |
| - initiator); |
| - |
| + ShowNonClippedConstrainedWebDialog( |
| + initiator->GetBrowserContext(), |
| + new PrintPreviewDialogDelegate(initiator), initiator); |
| WebContents* preview_dialog = web_dialog_delegate->GetWebContents(); |
| // Clear the zoom level for the print preview dialog so it isn't affected by |