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

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: Various fixes Created 4 years, 4 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);
103 const int kBorder = 25; 100 const int kBorder = 25;
101 const gfx::Size kMinDialogSize(438, 455);
102 // keeps Mac behavior the same as before new unclipped dialogs
Mike Wittman 2016/08/15 19:36:37 Can you provide more context here on the differenc
rbpotter 2016/08/15 21:32:54 Done.
103 #if defined(OS_MACOSX)
104 kMinDialogSize.set_width(800);
Mike Wittman 2016/08/15 19:36:37 I don't think this will compile on Mac. Better wou
rbpotter 2016/08/15 21:32:54 Done.
105 kMinDialogSize.set_height(480);
106 #endif
104 *size = kMinDialogSize; 107 *size = kMinDialogSize;
105
106 web_modal::WebContentsModalDialogHost* host = nullptr; 108 web_modal::WebContentsModalDialogHost* host = nullptr;
107 content::WebContents* outermost_web_contents = 109 content::WebContents* outermost_web_contents =
108 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_); 110 guest_view::GuestViewBase::GetTopLevelWebContents(initiator_);
109 Browser* browser = chrome::FindBrowserWithWebContents(outermost_web_contents); 111 Browser* browser = chrome::FindBrowserWithWebContents(outermost_web_contents);
110 if (browser) 112 if (browser)
111 host = browser->window()->GetWebContentsModalDialogHost(); 113 host = browser->window()->GetWebContentsModalDialogHost();
112 114
113 if (host) 115 if (host)
114 size->SetToMax(host->GetMaximumDialogSize()); 116 size->SetToMax(host->GetMaximumDialogSize());
115 else 117 else
116 size->SetToMax(outermost_web_contents->GetContainerBounds().size()); 118 size->SetToMax(outermost_web_contents->GetContainerBounds().size());
117 size->Enlarge(-2 * kBorder, -kBorder); 119 int expand_width =
118 120 std::min(size->width() - kMinDialogSize.width(), 2 * kBorder);
121 int expand_height =
122 std::min(size->height() - kMinDialogSize.height(), kBorder);
123 // keeps Mac behavior the same as before new unclipped dialogs
124 #if defined(OS_MACOSX)
125 expand_width = 2*kBorder;
Mike Wittman 2016/08/15 19:36:37 #ifdef's are much easier to understand when the pl
rbpotter 2016/08/15 21:32:54 Done.
126 expand_height = kBorder;
127 #endif
128 size->Enlarge(-expand_width, -expand_height);
119 #if defined(OS_MACOSX) 129 #if defined(OS_MACOSX)
120 // Limit the maximum size on MacOS X. 130 // Limit the maximum size on MacOS X.
121 // http://crbug.com/105815 131 // http://crbug.com/105815
122 const gfx::Size kMaxDialogSize(1000, 660); 132 const gfx::Size kMaxDialogSize(1000, 660);
123 size->SetToMin(kMaxDialogSize); 133 size->SetToMin(kMaxDialogSize);
124 #endif 134 #endif
125 } 135 }
126 136
127 std::string PrintPreviewDialogDelegate::GetDialogArgs() const { 137 std::string PrintPreviewDialogDelegate::GetDialogArgs() const {
128 return std::string(); 138 return std::string();
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 368
359 RemoveInitiator(contents); 369 RemoveInitiator(contents);
360 } 370 }
361 371
362 WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog( 372 WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog(
363 WebContents* initiator) { 373 WebContents* initiator) {
364 base::AutoReset<bool> auto_reset(&is_creating_print_preview_dialog_, true); 374 base::AutoReset<bool> auto_reset(&is_creating_print_preview_dialog_, true);
365 375
366 // The dialog delegates are deleted when the dialog is closed. 376 // The dialog delegates are deleted when the dialog is closed.
367 ConstrainedWebDialogDelegate* web_dialog_delegate = 377 ConstrainedWebDialogDelegate* web_dialog_delegate =
368 ShowConstrainedWebDialog(initiator->GetBrowserContext(), 378 ShowNonClippedConstrainedWebDialog(
369 new PrintPreviewDialogDelegate(initiator), 379 initiator->GetBrowserContext(),
370 initiator); 380 new PrintPreviewDialogDelegate(initiator), initiator);
371
372 WebContents* preview_dialog = web_dialog_delegate->GetWebContents(); 381 WebContents* preview_dialog = web_dialog_delegate->GetWebContents();
373 382
374 // Clear the zoom level for the print preview dialog so it isn't affected by 383 // Clear the zoom level for the print preview dialog so it isn't affected by
375 // the default zoom level. This also controls the zoom level of the OOP PDF 384 // the default zoom level. This also controls the zoom level of the OOP PDF
376 // extension when iframed by the print preview dialog. 385 // extension when iframed by the print preview dialog.
377 GURL print_url(chrome::kChromeUIPrintURL); 386 GURL print_url(chrome::kChromeUIPrintURL);
378 content::HostZoomMap::Get(preview_dialog->GetSiteInstance()) 387 content::HostZoomMap::Get(preview_dialog->GetSiteInstance())
379 ->SetZoomLevelForHostAndScheme(print_url.scheme(), print_url.host(), 0); 388 ->SetZoomLevelForHostAndScheme(print_url.scheme(), print_url.host(), 0);
380 PrintViewManager::CreateForWebContents(preview_dialog); 389 PrintViewManager::CreateForWebContents(preview_dialog);
381 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( 390 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 if (initiator) { 476 if (initiator) {
468 RemoveObservers(initiator); 477 RemoveObservers(initiator);
469 PrintViewManager::FromWebContents(initiator)->PrintPreviewDone(); 478 PrintViewManager::FromWebContents(initiator)->PrintPreviewDone();
470 } 479 }
471 480
472 preview_dialog_map_.erase(preview_dialog); 481 preview_dialog_map_.erase(preview_dialog);
473 RemoveObservers(preview_dialog); 482 RemoveObservers(preview_dialog);
474 } 483 }
475 484
476 } // namespace printing 485 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698