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

Unified Diff: chrome/browser/printing/print_preview_dialog_controller.cc

Issue 23460022: Fix print preview size calculation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: comment Created 7 years, 3 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/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 542d2d24345c1c4ffc52463fd10fccf60204dcac..f847e77c6144876cd0d92ed385fe8efe206f1912 100644
--- a/chrome/browser/printing/print_preview_dialog_controller.cc
+++ b/chrome/browser/printing/print_preview_dialog_controller.cc
@@ -27,6 +27,7 @@
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
+#include "components/web_modal/web_contents_modal_dialog_host.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
@@ -124,19 +125,22 @@ void PrintPreviewDialogDelegate::GetDialogSize(gfx::Size* size) const {
DCHECK(size);
const gfx::Size kMinDialogSize(800, 480);
const int kBorder = 25;
- const int kConstrainedWindowOverlap = 3;
- gfx::Rect rect;
- initiator_->GetView()->GetContainerBounds(&rect);
- size->set_width(std::max(rect.width(), kMinDialogSize.width()) - 2 * kBorder);
- size->set_height(std::max(rect.height(), kMinDialogSize.height()) - kBorder +
- kConstrainedWindowOverlap);
+
+ Browser* browser = chrome::FindBrowserWithWebContents(initiator_);
+ if (!browser) {
+ *size = kMinDialogSize;
+ return;
+ }
+ *size = browser->window()->GetWebContentsModalDialogHost()->
Mike Wittman 2013/09/06 22:37:31 Probably should check the value returned from GetW
Rune Fevang 2013/09/06 22:53:07 OK, fixed and added a comment to GetWebContentsMod
+ GetMaximumDialogSize();
+ size->SetToMax(kMinDialogSize);
+ size->Enlarge(-2 * kBorder, -kBorder);
#if defined(OS_MACOSX)
// Limit the maximum size on MacOS X.
// http://crbug.com/105815
const gfx::Size kMaxDialogSize(1000, 660);
- size->set_width(std::min(size->width(), kMaxDialogSize.width()));
- size->set_height(std::min(size->height(), kMaxDialogSize.height()));
+ size->SetToMin(kMaxDialogSize);
#endif
}
« 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