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

Side by Side Diff: chrome/browser/printing/print_preview_dialog_controller.cc

Issue 2172363002: Created min size for print preview dialog and modified to allow the Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reduced diff Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/printing/print_preview_dialog_controller.h" 5 #include "chrome/browser/printing/print_preview_dialog_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 }; 71 };
72 72
73 PrintPreviewDialogDelegate::PrintPreviewDialogDelegate(WebContents* initiator) 73 PrintPreviewDialogDelegate::PrintPreviewDialogDelegate(WebContents* initiator)
74 : initiator_(initiator) { 74 : initiator_(initiator) {
75 } 75 }
76 76
77 PrintPreviewDialogDelegate::~PrintPreviewDialogDelegate() { 77 PrintPreviewDialogDelegate::~PrintPreviewDialogDelegate() {
78 } 78 }
79 79
80 ui::ModalType PrintPreviewDialogDelegate::GetDialogModalType() const { 80 ui::ModalType PrintPreviewDialogDelegate::GetDialogModalType() const {
81 // Not used, returning dummy value. 81 return ui::MODAL_TYPE_CHILD;
82 NOTREACHED();
83 return ui::MODAL_TYPE_WINDOW;
84 } 82 }
85 83
86 base::string16 PrintPreviewDialogDelegate::GetDialogTitle() const { 84 base::string16 PrintPreviewDialogDelegate::GetDialogTitle() const {
87 // Only used on Windows? UI folks prefer no title. 85 // Only used on Windows? UI folks prefer no title.
88 return base::string16(); 86 return base::string16();
89 } 87 }
90 88
91 GURL PrintPreviewDialogDelegate::GetDialogContentURL() const { 89 GURL PrintPreviewDialogDelegate::GetDialogContentURL() const {
92 return GURL(chrome::kChromeUIPrintURL); 90 return GURL(chrome::kChromeUIPrintURL);
93 } 91 }
94 92
95 void PrintPreviewDialogDelegate::GetWebUIMessageHandlers( 93 void PrintPreviewDialogDelegate::GetWebUIMessageHandlers(
96 std::vector<WebUIMessageHandler*>* /* handlers */) const { 94 std::vector<WebUIMessageHandler*>* /* handlers */) const {
97 // PrintPreviewUI adds its own message handlers. 95 // PrintPreviewUI adds its own message handlers.
98 } 96 }
99 97
100 void PrintPreviewDialogDelegate::GetDialogSize(gfx::Size* size) const { 98 void PrintPreviewDialogDelegate::GetDialogSize(gfx::Size* size) const {
101 DCHECK(size); 99 DCHECK(size);
102 const gfx::Size kMinDialogSize(800, 480); 100 // Modified to match requested size. Previously: 800, 480.
101 const gfx::Size kMinDialogSize(438, 455);
103 const int kBorder = 25; 102 const int kBorder = 25;
104 *size = kMinDialogSize; 103 *size = kMinDialogSize;
105 104
106 web_modal::WebContentsModalDialogHost* host = nullptr; 105 web_modal::WebContentsModalDialogHost* host = nullptr;
107 content::WebContents* outermost_web_contents = 106 content::WebContents* outermost_web_contents =
108 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_); 107 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_);
109 Browser* browser = chrome::FindBrowserWithWebContents(outermost_web_contents); 108 Browser* browser = chrome::FindBrowserWithWebContents(outermost_web_contents);
110 if (browser) 109 if (browser)
111 host = browser->window()->GetWebContentsModalDialogHost(); 110 host = browser->window()->GetWebContentsModalDialogHost();
112 111
113 if (host) 112 if (host)
114 size->SetToMax(host->GetMaximumDialogSize()); 113 size->SetToMax(host->GetMaximumDialogSize());
115 else 114 else
116 size->SetToMax(outermost_web_contents->GetContainerBounds().size()); 115 size->SetToMax(outermost_web_contents->GetContainerBounds().size());
117 size->Enlarge(-2 * kBorder, -kBorder); 116 int expandWidth = 2*kBorder;
Lei Zhang 2016/07/25 21:35:10 Take a look at the Google C++ style guide. non-con
rbpotter 2016/07/26 21:48:19 Done.
117 int expandHeight = kBorder;
118 if (size->width() - kMinDialogSize.width() < 2*kBorder) {
Lei Zhang 2016/07/25 21:35:10 This can be combined into: int expand_width = std
rbpotter 2016/07/26 21:48:19 Done.
119 expandWidth = size->width() - kMinDialogSize.width();
120 }
121 if (size->height() - kMinDialogSize.height() < kBorder) {
122 expandHeight = size->height() - kMinDialogSize.height();
123 }
124 size->Enlarge(-1*expandWidth, -1*expandHeight);
Lei Zhang 2016/07/25 21:35:10 I think you can just write -var instead of -1 * va
rbpotter 2016/07/26 21:48:19 Done.
118 125
119 #if defined(OS_MACOSX) 126 #if defined(OS_MACOSX)
120 // Limit the maximum size on MacOS X. 127 // Limit the maximum size on MacOS X.
121 // http://crbug.com/105815 128 // http://crbug.com/105815
122 const gfx::Size kMaxDialogSize(1000, 660); 129 const gfx::Size kMaxDialogSize(1000, 660);
123 size->SetToMin(kMaxDialogSize); 130 size->SetToMin(kMaxDialogSize);
124 #endif 131 #endif
125 } 132 }
126 133
127 std::string PrintPreviewDialogDelegate::GetDialogArgs() const { 134 std::string PrintPreviewDialogDelegate::GetDialogArgs() const {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 357
351 RemoveInitiator(contents); 358 RemoveInitiator(contents);
352 } 359 }
353 360
354 WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog( 361 WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog(
355 WebContents* initiator) { 362 WebContents* initiator) {
356 base::AutoReset<bool> auto_reset(&is_creating_print_preview_dialog_, true); 363 base::AutoReset<bool> auto_reset(&is_creating_print_preview_dialog_, true);
357 364
358 // The dialog delegates are deleted when the dialog is closed. 365 // The dialog delegates are deleted when the dialog is closed.
359 ConstrainedWebDialogDelegate* web_dialog_delegate = 366 ConstrainedWebDialogDelegate* web_dialog_delegate =
360 ShowConstrainedWebDialog(initiator->GetBrowserContext(), 367 ShowTopLevelConstrainedWebDialog(initiator->GetBrowserContext(),
361 new PrintPreviewDialogDelegate(initiator), 368 new PrintPreviewDialogDelegate(initiator),
Mike Wittman 2016/07/26 17:27:35 nit: update indendation
362 initiator); 369 initiator);
363 370
364 WebContents* preview_dialog = web_dialog_delegate->GetWebContents(); 371 WebContents* preview_dialog = web_dialog_delegate->GetWebContents();
365 372
366 // Clear the zoom level for the print preview dialog so it isn't affected by 373 // Clear the zoom level for the print preview dialog so it isn't affected by
367 // the default zoom level. This also controls the zoom level of the OOP PDF 374 // the default zoom level. This also controls the zoom level of the OOP PDF
368 // extension when iframed by the print preview dialog. 375 // extension when iframed by the print preview dialog.
369 GURL print_url(chrome::kChromeUIPrintURL); 376 GURL print_url(chrome::kChromeUIPrintURL);
370 content::HostZoomMap::Get(preview_dialog->GetSiteInstance()) 377 content::HostZoomMap::Get(preview_dialog->GetSiteInstance())
371 ->SetZoomLevelForHostAndScheme(print_url.scheme(), print_url.host(), 0); 378 ->SetZoomLevelForHostAndScheme(print_url.scheme(), print_url.host(), 0);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (initiator) { 466 if (initiator) {
460 RemoveObservers(initiator); 467 RemoveObservers(initiator);
461 PrintViewManager::FromWebContents(initiator)->PrintPreviewDone(); 468 PrintViewManager::FromWebContents(initiator)->PrintPreviewDone();
462 } 469 }
463 470
464 preview_dialog_map_.erase(preview_dialog); 471 preview_dialog_map_.erase(preview_dialog);
465 RemoveObservers(preview_dialog); 472 RemoveObservers(preview_dialog);
466 } 473 }
467 474
468 } // namespace printing 475 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698