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

Side by Side 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: WebContentsModalDialogHost can be NULL 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/browser_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" 16 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
17 #include "chrome/browser/printing/print_view_manager.h" 17 #include "chrome/browser/printing/print_view_manager.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/browser_navigator.h" 21 #include "chrome/browser/ui/browser_navigator.h"
22 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/browser/ui/host_desktop.h" 23 #include "chrome/browser/ui/host_desktop.h"
24 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" 24 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
25 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" 25 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
26 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" 26 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
27 #include "chrome/common/chrome_content_client.h" 27 #include "chrome/common/chrome_content_client.h"
28 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
29 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
30 #include "components/web_modal/web_contents_modal_dialog_host.h"
30 #include "content/public/browser/navigation_controller.h" 31 #include "content/public/browser/navigation_controller.h"
31 #include "content/public/browser/navigation_details.h" 32 #include "content/public/browser/navigation_details.h"
32 #include "content/public/browser/navigation_entry.h" 33 #include "content/public/browser/navigation_entry.h"
33 #include "content/public/browser/notification_details.h" 34 #include "content/public/browser/notification_details.h"
34 #include "content/public/browser/notification_source.h" 35 #include "content/public/browser/notification_source.h"
35 #include "content/public/browser/plugin_service.h" 36 #include "content/public/browser/plugin_service.h"
36 #include "content/public/browser/render_process_host.h" 37 #include "content/public/browser/render_process_host.h"
37 #include "content/public/browser/render_view_host.h" 38 #include "content/public/browser/render_view_host.h"
38 #include "content/public/browser/web_contents.h" 39 #include "content/public/browser/web_contents.h"
39 #include "content/public/browser/web_contents_delegate.h" 40 #include "content/public/browser/web_contents_delegate.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 118
118 void PrintPreviewDialogDelegate::GetWebUIMessageHandlers( 119 void PrintPreviewDialogDelegate::GetWebUIMessageHandlers(
119 std::vector<WebUIMessageHandler*>* /* handlers */) const { 120 std::vector<WebUIMessageHandler*>* /* handlers */) const {
120 // PrintPreviewUI adds its own message handlers. 121 // PrintPreviewUI adds its own message handlers.
121 } 122 }
122 123
123 void PrintPreviewDialogDelegate::GetDialogSize(gfx::Size* size) const { 124 void PrintPreviewDialogDelegate::GetDialogSize(gfx::Size* size) const {
124 DCHECK(size); 125 DCHECK(size);
125 const gfx::Size kMinDialogSize(800, 480); 126 const gfx::Size kMinDialogSize(800, 480);
126 const int kBorder = 25; 127 const int kBorder = 25;
127 const int kConstrainedWindowOverlap = 3; 128 *size = kMinDialogSize;
128 gfx::Rect rect; 129
129 initiator_->GetView()->GetContainerBounds(&rect); 130 Browser* browser = chrome::FindBrowserWithWebContents(initiator_);
130 size->set_width(std::max(rect.width(), kMinDialogSize.width()) - 2 * kBorder); 131 if (browser) {
131 size->set_height(std::max(rect.height(), kMinDialogSize.height()) - kBorder + 132 web_modal::WebContentsModalDialogHost* host =
132 kConstrainedWindowOverlap); 133 browser->window()->GetWebContentsModalDialogHost();
134 if (host)
135 size->SetToMax(host->GetMaximumDialogSize());
136 }
137 size->Enlarge(-2 * kBorder, -kBorder);
133 138
134 #if defined(OS_MACOSX) 139 #if defined(OS_MACOSX)
135 // Limit the maximum size on MacOS X. 140 // Limit the maximum size on MacOS X.
136 // http://crbug.com/105815 141 // http://crbug.com/105815
137 const gfx::Size kMaxDialogSize(1000, 660); 142 const gfx::Size kMaxDialogSize(1000, 660);
138 size->set_width(std::min(size->width(), kMaxDialogSize.width())); 143 size->SetToMin(kMaxDialogSize);
139 size->set_height(std::min(size->height(), kMaxDialogSize.height()));
140 #endif 144 #endif
141 } 145 }
142 146
143 std::string PrintPreviewDialogDelegate::GetDialogArgs() const { 147 std::string PrintPreviewDialogDelegate::GetDialogArgs() const {
144 return std::string(); 148 return std::string();
145 } 149 }
146 150
147 void PrintPreviewDialogDelegate::OnDialogClosed( 151 void PrintPreviewDialogDelegate::OnDialogClosed(
148 const std::string& /* json_retval */) { 152 const std::string& /* json_retval */) {
149 } 153 }
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 PrintPreviewUI* print_preview_ui = 503 PrintPreviewUI* print_preview_ui =
500 static_cast<PrintPreviewUI*>(preview_dialog->GetWebUI()->GetController()); 504 static_cast<PrintPreviewUI*>(preview_dialog->GetWebUI()->GetController());
501 if (print_preview_ui) 505 if (print_preview_ui)
502 print_preview_ui->OnPrintPreviewDialogDestroyed(); 506 print_preview_ui->OnPrintPreviewDialogDestroyed();
503 507
504 preview_dialog_map_.erase(preview_dialog); 508 preview_dialog_map_.erase(preview_dialog);
505 RemoveObservers(preview_dialog); 509 RemoveObservers(preview_dialog);
506 } 510 }
507 511
508 } // namespace printing 512 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698