| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/print_web_view_helper.h" | 5 #include "chrome/renderer/print_web_view_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 ConvertPixelsToPointDouble(margin_left_in_pixels); | 646 ConvertPixelsToPointDouble(margin_left_in_pixels); |
| 647 } | 647 } |
| 648 | 648 |
| 649 // static - Not anonymous so that platform implementations can use it. | 649 // static - Not anonymous so that platform implementations can use it. |
| 650 void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( | 650 void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( |
| 651 WebFrame* frame, | 651 WebFrame* frame, |
| 652 WebNode* node, | 652 WebNode* node, |
| 653 PrepareFrameAndViewForPrint* prepare, | 653 PrepareFrameAndViewForPrint* prepare, |
| 654 PrintMsg_Print_Params* params) { | 654 PrintMsg_Print_Params* params) { |
| 655 PageSizeMargins page_layout_in_points; | 655 PageSizeMargins page_layout_in_points; |
| 656 prepare->UpdatePrintParams(*params); | |
| 657 PrintWebViewHelper::GetPageSizeAndMarginsInPoints(frame, 0, *params, | 656 PrintWebViewHelper::GetPageSizeAndMarginsInPoints(frame, 0, *params, |
| 658 &page_layout_in_points); | 657 &page_layout_in_points); |
| 659 int dpi = GetDPI(params); | 658 int dpi = GetDPI(params); |
| 660 params->printable_size = gfx::Size( | 659 params->printable_size = gfx::Size( |
| 661 static_cast<int>(ConvertUnitDouble( | 660 static_cast<int>(ConvertUnitDouble( |
| 662 page_layout_in_points.content_width, | 661 page_layout_in_points.content_width, |
| 663 printing::kPointsPerInch, dpi)), | 662 printing::kPointsPerInch, dpi)), |
| 664 static_cast<int>(ConvertUnitDouble( | 663 static_cast<int>(ConvertUnitDouble( |
| 665 page_layout_in_points.content_height, | 664 page_layout_in_points.content_height, |
| 666 printing::kPointsPerInch, dpi))); | 665 printing::kPointsPerInch, dpi))); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 677 params->page_size = gfx::Size( | 676 params->page_size = gfx::Size( |
| 678 static_cast<int>(ConvertUnitDouble( | 677 static_cast<int>(ConvertUnitDouble( |
| 679 page_width_in_points, printing::kPointsPerInch, dpi)), | 678 page_width_in_points, printing::kPointsPerInch, dpi)), |
| 680 static_cast<int>(ConvertUnitDouble( | 679 static_cast<int>(ConvertUnitDouble( |
| 681 page_height_in_points, printing::kPointsPerInch, dpi))); | 680 page_height_in_points, printing::kPointsPerInch, dpi))); |
| 682 | 681 |
| 683 params->margin_top = static_cast<int>(ConvertUnitDouble( | 682 params->margin_top = static_cast<int>(ConvertUnitDouble( |
| 684 page_layout_in_points.margin_top, printing::kPointsPerInch, dpi)); | 683 page_layout_in_points.margin_top, printing::kPointsPerInch, dpi)); |
| 685 params->margin_left = static_cast<int>(ConvertUnitDouble( | 684 params->margin_left = static_cast<int>(ConvertUnitDouble( |
| 686 page_layout_in_points.margin_left, printing::kPointsPerInch, dpi)); | 685 page_layout_in_points.margin_left, printing::kPointsPerInch, dpi)); |
| 686 |
| 687 prepare->UpdatePrintParams(*params); |
| 687 } | 688 } |
| 688 | 689 |
| 689 bool PrintWebViewHelper::InitPrintSettings(WebKit::WebFrame* frame, | 690 bool PrintWebViewHelper::InitPrintSettings(WebKit::WebFrame* frame, |
| 690 WebKit::WebNode* node) { | 691 WebKit::WebNode* node) { |
| 691 DCHECK(frame); | 692 DCHECK(frame); |
| 692 PrintMsg_PrintPages_Params settings; | 693 PrintMsg_PrintPages_Params settings; |
| 693 | 694 |
| 694 Send(new PrintHostMsg_GetDefaultPrintSettings(routing_id(), | 695 Send(new PrintHostMsg_GetDefaultPrintSettings(routing_id(), |
| 695 &settings.params)); | 696 &settings.params)); |
| 696 // Check if the printer returned any settings, if the settings is empty, we | 697 // Check if the printer returned any settings, if the settings is empty, we |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 const gfx::Size& | 1094 const gfx::Size& |
| 1094 PrintWebViewHelper::PrintPreviewContext::GetPrintCanvasSize() const { | 1095 PrintWebViewHelper::PrintPreviewContext::GetPrintCanvasSize() const { |
| 1095 return prep_frame_view_->GetPrintCanvasSize(); | 1096 return prep_frame_view_->GetPrintCanvasSize(); |
| 1096 } | 1097 } |
| 1097 | 1098 |
| 1098 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 1099 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
| 1099 prep_frame_view_.reset(); | 1100 prep_frame_view_.reset(); |
| 1100 metafile_.reset(); | 1101 metafile_.reset(); |
| 1101 pages_to_render_.clear(); | 1102 pages_to_render_.clear(); |
| 1102 } | 1103 } |
| OLD | NEW |