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

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: 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 | no next file » | 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
128 gfx::Rect rect; 129 Browser* browser = chrome::FindBrowserWithWebContents(initiator_);
129 initiator_->GetView()->GetContainerBounds(&rect); 130 if (!browser)
130 size->set_width(std::max(rect.width(), kMinDialogSize.width()) - 2 * kBorder); 131 return;
131 size->set_height(std::max(rect.height(), kMinDialogSize.height()) - kBorder + 132 *size = browser->window()->GetWebContentsModalDialogHost()->
132 kConstrainedWindowOverlap); 133 GetMaximumDialogSize();
Vitaly Buka (NO REVIEWS) 2013/09/06 21:14:29 Shouldn't we put at least kMinDialogSize in case o
Rune Fevang 2013/09/06 22:27:55 That seems reasonable, good idea :)
134 size->SetToMax(kMinDialogSize);
135 size->Enlarge(-2 * kBorder, -kBorder);
133 136
134 #if defined(OS_MACOSX) 137 #if defined(OS_MACOSX)
135 // Limit the maximum size on MacOS X. 138 // Limit the maximum size on MacOS X.
136 // http://crbug.com/105815 139 // http://crbug.com/105815
137 const gfx::Size kMaxDialogSize(1000, 660); 140 const gfx::Size kMaxDialogSize(1000, 660);
138 size->set_width(std::min(size->width(), kMaxDialogSize.width())); 141 size->SetToMin(kMaxDialogSize);
139 size->set_height(std::min(size->height(), kMaxDialogSize.height()));
140 #endif 142 #endif
141 } 143 }
142 144
143 std::string PrintPreviewDialogDelegate::GetDialogArgs() const { 145 std::string PrintPreviewDialogDelegate::GetDialogArgs() const {
144 return std::string(); 146 return std::string();
145 } 147 }
146 148
147 void PrintPreviewDialogDelegate::OnDialogClosed( 149 void PrintPreviewDialogDelegate::OnDialogClosed(
148 const std::string& /* json_retval */) { 150 const std::string& /* json_retval */) {
149 } 151 }
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 PrintPreviewUI* print_preview_ui = 501 PrintPreviewUI* print_preview_ui =
500 static_cast<PrintPreviewUI*>(preview_dialog->GetWebUI()->GetController()); 502 static_cast<PrintPreviewUI*>(preview_dialog->GetWebUI()->GetController());
501 if (print_preview_ui) 503 if (print_preview_ui)
502 print_preview_ui->OnPrintPreviewDialogDestroyed(); 504 print_preview_ui->OnPrintPreviewDialogDestroyed();
503 505
504 preview_dialog_map_.erase(preview_dialog); 506 preview_dialog_map_.erase(preview_dialog);
505 RemoveObservers(preview_dialog); 507 RemoveObservers(preview_dialog);
506 } 508 }
507 509
508 } // namespace printing 510 } // namespace printing
OLDNEW
« 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