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

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: Change to CrOS only. 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); 100 // Modified to match requested size. Previously: 800, 480.
Mike Wittman 2016/08/12 22:51:34 This comment likely can be removed. Anyone who wan
rbpotter 2016/08/15 18:03:45 Done.
101 const gfx::Size kMinDialogSize(438, 455);
Mike Wittman 2016/08/12 22:51:34 Should this be sized differently depending on whet
rbpotter 2016/08/15 18:03:45 If there's not independent bounds key, the dialog
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 expand_width =
Mike Wittman 2016/08/12 22:51:34 Same question here.
rbpotter 2016/08/15 18:03:45 See above
117 std::min(size->width() - kMinDialogSize.width(), 2 * kBorder);
118 int expand_height =
119 std::min(size->height() - kMinDialogSize.height(), kBorder);
120 size->Enlarge(-expand_width, -expand_height);
118 121
119 #if defined(OS_MACOSX) 122 #if defined(OS_MACOSX)
120 // Limit the maximum size on MacOS X. 123 // Limit the maximum size on MacOS X.
121 // http://crbug.com/105815 124 // http://crbug.com/105815
122 const gfx::Size kMaxDialogSize(1000, 660); 125 const gfx::Size kMaxDialogSize(1000, 660);
123 size->SetToMin(kMaxDialogSize); 126 size->SetToMin(kMaxDialogSize);
124 #endif 127 #endif
125 } 128 }
126 129
127 std::string PrintPreviewDialogDelegate::GetDialogArgs() const { 130 std::string PrintPreviewDialogDelegate::GetDialogArgs() const {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 360 }
358 361
359 RemoveInitiator(contents); 362 RemoveInitiator(contents);
360 } 363 }
361 364
362 WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog( 365 WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog(
363 WebContents* initiator) { 366 WebContents* initiator) {
364 base::AutoReset<bool> auto_reset(&is_creating_print_preview_dialog_, true); 367 base::AutoReset<bool> auto_reset(&is_creating_print_preview_dialog_, true);
365 368
366 // The dialog delegates are deleted when the dialog is closed. 369 // The dialog delegates are deleted when the dialog is closed.
370 #if defined(OS_MACOSX)
Mike Wittman 2016/08/12 22:51:34 Can we drop the #if part here and just have ShowTo
rbpotter 2016/08/15 18:03:45 Done.
371 ConstrainedWebDialogDelegate* web_dialog_delegate = ShowConstrainedWebDialog(
372 initiator->GetBrowserContext(), new PrintPreviewDialogDelegate(initiator),
373 initiator);
374 #else
367 ConstrainedWebDialogDelegate* web_dialog_delegate = 375 ConstrainedWebDialogDelegate* web_dialog_delegate =
368 ShowConstrainedWebDialog(initiator->GetBrowserContext(), 376 ShowTopLevelConstrainedWebDialog(
369 new PrintPreviewDialogDelegate(initiator), 377 initiator->GetBrowserContext(),
370 initiator); 378 new PrintPreviewDialogDelegate(initiator), initiator);
379 #endif
371 380
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);
(...skipping 86 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