| OLD | NEW |
| 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/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/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 const PrintMsg_PrintPages_Params& oldParams, | 122 const PrintMsg_PrintPages_Params& oldParams, |
| 123 const PrintMsg_PrintPages_Params& newParams) { | 123 const PrintMsg_PrintPages_Params& newParams) { |
| 124 return PageLayoutIsEqual(oldParams, newParams) && | 124 return PageLayoutIsEqual(oldParams, newParams) && |
| 125 oldParams.params.max_shrink == newParams.params.max_shrink && | 125 oldParams.params.max_shrink == newParams.params.max_shrink && |
| 126 oldParams.params.min_shrink == newParams.params.min_shrink && | 126 oldParams.params.min_shrink == newParams.params.min_shrink && |
| 127 oldParams.params.selection_only == newParams.params.selection_only && | 127 oldParams.params.selection_only == newParams.params.selection_only && |
| 128 oldParams.params.supports_alpha_blend == | 128 oldParams.params.supports_alpha_blend == |
| 129 newParams.params.supports_alpha_blend && | 129 newParams.params.supports_alpha_blend && |
| 130 oldParams.pages.size() == newParams.pages.size() && | 130 oldParams.pages.size() == newParams.pages.size() && |
| 131 oldParams.params.print_to_pdf == newParams.params.print_to_pdf && | 131 oldParams.params.print_to_pdf == newParams.params.print_to_pdf && |
| 132 oldParams.params.fit_to_paper_size == |
| 133 newParams.params.fit_to_paper_size && |
| 132 oldParams.params.display_header_footer == | 134 oldParams.params.display_header_footer == |
| 133 newParams.params.display_header_footer && | 135 newParams.params.display_header_footer && |
| 134 oldParams.params.date == newParams.params.date && | 136 oldParams.params.date == newParams.params.date && |
| 135 oldParams.params.title == newParams.params.title && | 137 oldParams.params.title == newParams.params.title && |
| 136 oldParams.params.url == newParams.params.url && | 138 oldParams.params.url == newParams.params.url && |
| 137 std::equal(oldParams.pages.begin(), oldParams.pages.end(), | 139 std::equal(oldParams.pages.begin(), oldParams.pages.end(), |
| 138 newParams.pages.begin()); | 140 newParams.pages.begin()); |
| 139 } | 141 } |
| 140 | 142 |
| 141 PrintMsg_Print_Params GetCssPrintParams( | 143 PrintMsg_Print_Params GetCssPrintParams( |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 } | 658 } |
| 657 } | 659 } |
| 658 | 660 |
| 659 PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view) | 661 PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view) |
| 660 : content::RenderViewObserver(render_view), | 662 : content::RenderViewObserver(render_view), |
| 661 content::RenderViewObserverTracker<PrintWebViewHelper>(render_view), | 663 content::RenderViewObserverTracker<PrintWebViewHelper>(render_view), |
| 662 print_web_view_(NULL), | 664 print_web_view_(NULL), |
| 663 is_preview_enabled_(IsPrintPreviewEnabled()), | 665 is_preview_enabled_(IsPrintPreviewEnabled()), |
| 664 is_print_ready_metafile_sent_(false), | 666 is_print_ready_metafile_sent_(false), |
| 665 ignore_css_margins_(false), | 667 ignore_css_margins_(false), |
| 666 fit_to_page_(true), | |
| 667 user_cancelled_scripted_print_count_(0), | 668 user_cancelled_scripted_print_count_(0), |
| 668 is_scripted_printing_blocked_(false), | 669 is_scripted_printing_blocked_(false), |
| 669 notify_browser_of_print_failure_(true), | 670 notify_browser_of_print_failure_(true), |
| 670 print_for_preview_(false) { | 671 print_for_preview_(false) { |
| 671 } | 672 } |
| 672 | 673 |
| 673 PrintWebViewHelper::~PrintWebViewHelper() {} | 674 PrintWebViewHelper::~PrintWebViewHelper() {} |
| 674 | 675 |
| 675 bool PrintWebViewHelper::IsScriptInitiatedPrintAllowed( | 676 bool PrintWebViewHelper::IsScriptInitiatedPrintAllowed( |
| 676 WebKit::WebFrame* frame) { | 677 WebKit::WebFrame* frame) { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 if (notify_browser_of_print_failure_) | 881 if (notify_browser_of_print_failure_) |
| 881 LOG(ERROR) << "CreatePreviewDocument failed"; | 882 LOG(ERROR) << "CreatePreviewDocument failed"; |
| 882 DidFinishPrinting(FAIL_PREVIEW); | 883 DidFinishPrinting(FAIL_PREVIEW); |
| 883 } | 884 } |
| 884 } | 885 } |
| 885 | 886 |
| 886 bool PrintWebViewHelper::CreatePreviewDocument() { | 887 bool PrintWebViewHelper::CreatePreviewDocument() { |
| 887 PrintMsg_Print_Params print_params = print_pages_params_->params; | 888 PrintMsg_Print_Params print_params = print_pages_params_->params; |
| 888 const std::vector<int>& pages = print_pages_params_->pages; | 889 const std::vector<int>& pages = print_pages_params_->pages; |
| 889 if (!print_preview_context_.CreatePreviewDocument(&print_params, pages, | 890 if (!print_preview_context_.CreatePreviewDocument(&print_params, pages, |
| 890 ignore_css_margins_, | 891 ignore_css_margins_)) { |
| 891 fit_to_page_)) { | |
| 892 return false; | 892 return false; |
| 893 } | 893 } |
| 894 | 894 |
| 895 PageSizeMargins default_page_layout; | 895 PageSizeMargins default_page_layout; |
| 896 ComputePageLayoutInPointsForCss(print_preview_context_.frame(), 0, | 896 ComputePageLayoutInPointsForCss(print_preview_context_.frame(), 0, |
| 897 print_params, ignore_css_margins_, | 897 print_params, ignore_css_margins_, NULL, |
| 898 fit_to_page_, NULL, &default_page_layout); | 898 &default_page_layout); |
| 899 | 899 |
| 900 if (!old_print_pages_params_.get() || | 900 if (!old_print_pages_params_.get() || |
| 901 !PageLayoutIsEqual(*old_print_pages_params_, *print_pages_params_)) { | 901 !PageLayoutIsEqual(*old_print_pages_params_, *print_pages_params_)) { |
| 902 bool has_page_size_style = PrintingFrameHasPageSizeStyle( | 902 bool has_page_size_style = PrintingFrameHasPageSizeStyle( |
| 903 print_preview_context_.frame(), | 903 print_preview_context_.frame(), |
| 904 print_preview_context_.total_page_count()); | 904 print_preview_context_.total_page_count()); |
| 905 int dpi = GetDPI(&print_params); | 905 int dpi = GetDPI(&print_params); |
| 906 gfx::Rect printable_area_in_points( | 906 gfx::Rect printable_area_in_points( |
| 907 ConvertUnit(print_pages_params_->params.printable_area.x(), | 907 ConvertUnit(print_pages_params_->params.printable_area.x(), |
| 908 dpi, printing::kPointsPerInch), | 908 dpi, printing::kPointsPerInch), |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 | 1158 |
| 1159 return true; | 1159 return true; |
| 1160 } | 1160 } |
| 1161 | 1161 |
| 1162 #if defined(OS_MACOSX) || defined(OS_WIN) | 1162 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 1163 bool PrintWebViewHelper::PrintPages(WebFrame* frame, const WebNode& node) { | 1163 bool PrintWebViewHelper::PrintPages(WebFrame* frame, const WebNode& node) { |
| 1164 const PrintMsg_PrintPages_Params& params = *print_pages_params_; | 1164 const PrintMsg_PrintPages_Params& params = *print_pages_params_; |
| 1165 const PrintMsg_Print_Params& print_params = params.params; | 1165 const PrintMsg_Print_Params& print_params = params.params; |
| 1166 PrepareFrameAndViewForPrint prep_frame_view(print_params, frame, node); | 1166 PrepareFrameAndViewForPrint prep_frame_view(print_params, frame, node); |
| 1167 UpdateFrameAndViewFromCssPageLayout(frame, node, &prep_frame_view, | 1167 UpdateFrameAndViewFromCssPageLayout(frame, node, &prep_frame_view, |
| 1168 print_params, ignore_css_margins_, | 1168 print_params, ignore_css_margins_); |
| 1169 fit_to_page_); | |
| 1170 | 1169 |
| 1171 int page_count = prep_frame_view.GetExpectedPageCount(); | 1170 int page_count = prep_frame_view.GetExpectedPageCount(); |
| 1172 if (!page_count) | 1171 if (!page_count) |
| 1173 return false; | 1172 return false; |
| 1174 Send(new PrintHostMsg_DidGetPrintedPagesCount(routing_id(), | 1173 Send(new PrintHostMsg_DidGetPrintedPagesCount(routing_id(), |
| 1175 print_params.document_cookie, | 1174 print_params.document_cookie, |
| 1176 page_count)); | 1175 page_count)); |
| 1177 | 1176 |
| 1178 const gfx::Size& canvas_size = prep_frame_view.GetPrintCanvasSize(); | 1177 const gfx::Size& canvas_size = prep_frame_view.GetPrintCanvasSize(); |
| 1179 PrintMsg_PrintPage_Params page_params; | 1178 PrintMsg_PrintPage_Params page_params; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1198 void PrintWebViewHelper::didStopLoading() { | 1197 void PrintWebViewHelper::didStopLoading() { |
| 1199 PrintPages(print_web_view_->mainFrame(), WebNode()); | 1198 PrintPages(print_web_view_->mainFrame(), WebNode()); |
| 1200 } | 1199 } |
| 1201 | 1200 |
| 1202 // static - Not anonymous so that platform implementations can use it. | 1201 // static - Not anonymous so that platform implementations can use it. |
| 1203 void PrintWebViewHelper::ComputePageLayoutInPointsForCss( | 1202 void PrintWebViewHelper::ComputePageLayoutInPointsForCss( |
| 1204 WebFrame* frame, | 1203 WebFrame* frame, |
| 1205 int page_index, | 1204 int page_index, |
| 1206 const PrintMsg_Print_Params& page_params, | 1205 const PrintMsg_Print_Params& page_params, |
| 1207 bool ignore_css_margins, | 1206 bool ignore_css_margins, |
| 1208 bool fit_to_page, | |
| 1209 double* scale_factor, | 1207 double* scale_factor, |
| 1210 PageSizeMargins* page_layout_in_points) { | 1208 PageSizeMargins* page_layout_in_points) { |
| 1211 PrintMsg_Print_Params params = CalculatePrintParamsForCss(frame, page_index, | 1209 PrintMsg_Print_Params params = CalculatePrintParamsForCss( |
| 1212 page_params, | 1210 frame, page_index, page_params, ignore_css_margins, |
| 1213 ignore_css_margins, | 1211 page_params.fit_to_paper_size, scale_factor); |
| 1214 fit_to_page, | |
| 1215 scale_factor); | |
| 1216 CalculatePageLayoutFromPrintParams(params, page_layout_in_points); | 1212 CalculatePageLayoutFromPrintParams(params, page_layout_in_points); |
| 1217 } | 1213 } |
| 1218 | 1214 |
| 1219 // static - Not anonymous so that platform implementations can use it. | 1215 // static - Not anonymous so that platform implementations can use it. |
| 1220 void PrintWebViewHelper::UpdateFrameAndViewFromCssPageLayout( | 1216 void PrintWebViewHelper::UpdateFrameAndViewFromCssPageLayout( |
| 1221 WebFrame* frame, | 1217 WebFrame* frame, |
| 1222 const WebNode& node, | 1218 const WebNode& node, |
| 1223 PrepareFrameAndViewForPrint* prepare, | 1219 PrepareFrameAndViewForPrint* prepare, |
| 1224 const PrintMsg_Print_Params& params, | 1220 const PrintMsg_Print_Params& params, |
| 1225 bool ignore_css_margins, | 1221 bool ignore_css_margins) { |
| 1226 bool fit_to_page) { | |
| 1227 if (PrintingNodeOrPdfFrame(frame, node)) | 1222 if (PrintingNodeOrPdfFrame(frame, node)) |
| 1228 return; | 1223 return; |
| 1229 PrintMsg_Print_Params print_params = CalculatePrintParamsForCss( | 1224 PrintMsg_Print_Params print_params = CalculatePrintParamsForCss( |
| 1230 frame, 0, params, ignore_css_margins, ignore_css_margins && fit_to_page, | 1225 frame, 0, params, ignore_css_margins, |
| 1231 NULL); | 1226 ignore_css_margins && params.fit_to_paper_size, NULL); |
| 1232 prepare->UpdatePrintParams(print_params); | 1227 prepare->UpdatePrintParams(print_params); |
| 1233 } | 1228 } |
| 1234 | 1229 |
| 1235 bool PrintWebViewHelper::InitPrintSettings() { | 1230 bool PrintWebViewHelper::InitPrintSettings() { |
| 1236 PrintMsg_PrintPages_Params settings; | 1231 PrintMsg_PrintPages_Params settings; |
| 1237 Send(new PrintHostMsg_GetDefaultPrintSettings(routing_id(), | 1232 Send(new PrintHostMsg_GetDefaultPrintSettings(routing_id(), |
| 1238 &settings.params)); | 1233 &settings.params)); |
| 1239 // Check if the printer returned any settings, if the settings is empty, we | 1234 // Check if the printer returned any settings, if the settings is empty, we |
| 1240 // can safely assume there are no printer drivers configured. So we safely | 1235 // can safely assume there are no printer drivers configured. So we safely |
| 1241 // terminate. | 1236 // terminate. |
| 1242 bool result = true; | 1237 bool result = true; |
| 1243 if (!PrintMsg_Print_Params_IsValid(settings.params)) | 1238 if (!PrintMsg_Print_Params_IsValid(settings.params)) |
| 1244 result = false; | 1239 result = false; |
| 1245 | 1240 |
| 1246 if (result && | 1241 if (result && |
| 1247 (settings.params.dpi < kMinDpi || settings.params.document_cookie == 0)) { | 1242 (settings.params.dpi < kMinDpi || settings.params.document_cookie == 0)) { |
| 1248 // Invalid print page settings. | 1243 // Invalid print page settings. |
| 1249 NOTREACHED(); | 1244 NOTREACHED(); |
| 1250 result = false; | 1245 result = false; |
| 1251 } | 1246 } |
| 1252 | 1247 |
| 1253 // Reset to default values. | 1248 // Reset to default values. |
| 1254 ignore_css_margins_ = false; | 1249 ignore_css_margins_ = false; |
| 1255 fit_to_page_ = true; | 1250 settings.params.fit_to_paper_size = true; |
| 1256 settings.pages.clear(); | 1251 settings.pages.clear(); |
| 1257 | 1252 |
| 1258 print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); | 1253 print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); |
| 1259 return result; | 1254 return result; |
| 1260 } | 1255 } |
| 1261 | 1256 |
| 1262 bool PrintWebViewHelper::InitPrintSettingsAndPrepareFrame( | 1257 bool PrintWebViewHelper::InitPrintSettingsAndPrepareFrame( |
| 1263 WebKit::WebFrame* frame, const WebKit::WebNode& node, | 1258 WebKit::WebFrame* frame, const WebKit::WebNode& node, |
| 1264 scoped_ptr<PrepareFrameAndViewForPrint>* prepare) { | 1259 scoped_ptr<PrepareFrameAndViewForPrint>* prepare) { |
| 1265 DCHECK(frame); | 1260 DCHECK(frame); |
| 1266 if (!InitPrintSettings()) { | 1261 if (!InitPrintSettings()) { |
| 1267 notify_browser_of_print_failure_ = false; | 1262 notify_browser_of_print_failure_ = false; |
| 1268 render_view()->RunModalAlertDialog( | 1263 render_view()->RunModalAlertDialog( |
| 1269 frame, | 1264 frame, |
| 1270 l10n_util::GetStringUTF16(IDS_PRINT_PREVIEW_INVALID_PRINTER_SETTINGS)); | 1265 l10n_util::GetStringUTF16(IDS_PRINT_PREVIEW_INVALID_PRINTER_SETTINGS)); |
| 1271 return false; | 1266 return false; |
| 1272 } | 1267 } |
| 1273 | 1268 |
| 1274 DCHECK(!prepare->get()); | 1269 DCHECK(!prepare->get()); |
| 1275 prepare->reset(new PrepareFrameAndViewForPrint(print_pages_params_->params, | 1270 prepare->reset(new PrepareFrameAndViewForPrint(print_pages_params_->params, |
| 1276 frame, node)); | 1271 frame, node)); |
| 1277 UpdateFrameAndViewFromCssPageLayout(frame, node, prepare->get(), | 1272 UpdateFrameAndViewFromCssPageLayout(frame, node, prepare->get(), |
| 1278 print_pages_params_->params, | 1273 print_pages_params_->params, |
| 1279 ignore_css_margins_, fit_to_page_); | 1274 ignore_css_margins_); |
| 1280 Send(new PrintHostMsg_DidGetDocumentCookie( | 1275 Send(new PrintHostMsg_DidGetDocumentCookie( |
| 1281 routing_id(), print_pages_params_->params.document_cookie)); | 1276 routing_id(), print_pages_params_->params.document_cookie)); |
| 1282 return true; | 1277 return true; |
| 1283 } | 1278 } |
| 1284 | 1279 |
| 1285 bool PrintWebViewHelper::UpdatePrintSettings( | 1280 bool PrintWebViewHelper::UpdatePrintSettings( |
| 1286 WebKit::WebFrame* frame, const WebKit::WebNode& node, | 1281 WebKit::WebFrame* frame, const WebKit::WebNode& node, |
| 1287 const DictionaryValue& passed_job_settings) { | 1282 const DictionaryValue& passed_job_settings) { |
| 1288 DCHECK(is_preview_enabled_); | 1283 DCHECK(is_preview_enabled_); |
| 1289 const DictionaryValue* job_settings = &passed_job_settings; | 1284 const DictionaryValue* job_settings = &passed_job_settings; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 &(settings.params.preview_request_id)) || | 1367 &(settings.params.preview_request_id)) || |
| 1373 !job_settings->GetBoolean(printing::kIsFirstRequest, | 1368 !job_settings->GetBoolean(printing::kIsFirstRequest, |
| 1374 &(settings.params.is_first_request))) { | 1369 &(settings.params.is_first_request))) { |
| 1375 NOTREACHED(); | 1370 NOTREACHED(); |
| 1376 print_preview_context_.set_error(PREVIEW_ERROR_BAD_SETTING); | 1371 print_preview_context_.set_error(PREVIEW_ERROR_BAD_SETTING); |
| 1377 return false; | 1372 return false; |
| 1378 } | 1373 } |
| 1379 | 1374 |
| 1380 settings.params.print_to_pdf = IsPrintToPdfRequested(*job_settings); | 1375 settings.params.print_to_pdf = IsPrintToPdfRequested(*job_settings); |
| 1381 UpdateFrameMarginsCssInfo(*job_settings); | 1376 UpdateFrameMarginsCssInfo(*job_settings); |
| 1382 fit_to_page_ = source_is_html && !IsPrintToPdfRequested(*job_settings); | 1377 |
| 1378 // Fit to paper size. |
| 1379 settings.params.fit_to_paper_size = source_is_html && |
| 1380 !IsPrintToPdfRequested(*job_settings); |
| 1383 | 1381 |
| 1384 // Header/Footer: Set |header_footer_info_|. | 1382 // Header/Footer: Set |header_footer_info_|. |
| 1385 if (settings.params.display_header_footer) { | 1383 if (settings.params.display_header_footer) { |
| 1386 header_footer_info_.reset(new DictionaryValue()); | 1384 header_footer_info_.reset(new DictionaryValue()); |
| 1387 header_footer_info_->SetString(printing::kSettingHeaderFooterDate, | 1385 header_footer_info_->SetString(printing::kSettingHeaderFooterDate, |
| 1388 settings.params.date); | 1386 settings.params.date); |
| 1389 header_footer_info_->SetString(printing::kSettingHeaderFooterURL, | 1387 header_footer_info_->SetString(printing::kSettingHeaderFooterURL, |
| 1390 settings.params.url); | 1388 settings.params.url); |
| 1391 header_footer_info_->SetString(printing::kSettingHeaderFooterTitle, | 1389 header_footer_info_->SetString(printing::kSettingHeaderFooterTitle, |
| 1392 settings.params.title); | 1390 settings.params.title); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 } | 1624 } |
| 1627 | 1625 |
| 1628 void PrintWebViewHelper::PrintPreviewContext::OnPrintPreview() { | 1626 void PrintWebViewHelper::PrintPreviewContext::OnPrintPreview() { |
| 1629 DCHECK_EQ(INITIALIZED, state_); | 1627 DCHECK_EQ(INITIALIZED, state_); |
| 1630 ClearContext(); | 1628 ClearContext(); |
| 1631 } | 1629 } |
| 1632 | 1630 |
| 1633 bool PrintWebViewHelper::PrintPreviewContext::CreatePreviewDocument( | 1631 bool PrintWebViewHelper::PrintPreviewContext::CreatePreviewDocument( |
| 1634 PrintMsg_Print_Params* print_params, | 1632 PrintMsg_Print_Params* print_params, |
| 1635 const std::vector<int>& pages, | 1633 const std::vector<int>& pages, |
| 1636 bool ignore_css_margins, | 1634 bool ignore_css_margins) { |
| 1637 bool fit_to_page) { | |
| 1638 DCHECK_EQ(INITIALIZED, state_); | 1635 DCHECK_EQ(INITIALIZED, state_); |
| 1639 state_ = RENDERING; | 1636 state_ = RENDERING; |
| 1640 | 1637 |
| 1641 metafile_.reset(new printing::PreviewMetafile); | 1638 metafile_.reset(new printing::PreviewMetafile); |
| 1642 if (!metafile_->Init()) { | 1639 if (!metafile_->Init()) { |
| 1643 set_error(PREVIEW_ERROR_METAFILE_INIT_FAILED); | 1640 set_error(PREVIEW_ERROR_METAFILE_INIT_FAILED); |
| 1644 LOG(ERROR) << "PreviewMetafile Init failed"; | 1641 LOG(ERROR) << "PreviewMetafile Init failed"; |
| 1645 return false; | 1642 return false; |
| 1646 } | 1643 } |
| 1647 | 1644 |
| 1648 // Need to make sure old object gets destroyed first. | 1645 // Need to make sure old object gets destroyed first. |
| 1649 prep_frame_view_.reset(new PrepareFrameAndViewForPrint(*print_params, frame(), | 1646 prep_frame_view_.reset(new PrepareFrameAndViewForPrint(*print_params, frame(), |
| 1650 node())); | 1647 node())); |
| 1651 UpdateFrameAndViewFromCssPageLayout(frame_, node_, prep_frame_view_.get(), | 1648 UpdateFrameAndViewFromCssPageLayout(frame_, node_, prep_frame_view_.get(), |
| 1652 *print_params, ignore_css_margins, | 1649 *print_params, ignore_css_margins); |
| 1653 fit_to_page); | |
| 1654 | 1650 |
| 1655 print_params_.reset(new PrintMsg_Print_Params(*print_params)); | 1651 print_params_.reset(new PrintMsg_Print_Params(*print_params)); |
| 1656 | 1652 |
| 1657 total_page_count_ = prep_frame_view_->GetExpectedPageCount(); | 1653 total_page_count_ = prep_frame_view_->GetExpectedPageCount(); |
| 1658 if (total_page_count_ == 0) { | 1654 if (total_page_count_ == 0) { |
| 1659 LOG(ERROR) << "CreatePreviewDocument got 0 page count"; | 1655 LOG(ERROR) << "CreatePreviewDocument got 0 page count"; |
| 1660 set_error(PREVIEW_ERROR_ZERO_PAGES); | 1656 set_error(PREVIEW_ERROR_ZERO_PAGES); |
| 1661 return false; | 1657 return false; |
| 1662 } | 1658 } |
| 1663 | 1659 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1818 DCHECK(IsRendering()); | 1814 DCHECK(IsRendering()); |
| 1819 return prep_frame_view_->GetPrintCanvasSize(); | 1815 return prep_frame_view_->GetPrintCanvasSize(); |
| 1820 } | 1816 } |
| 1821 | 1817 |
| 1822 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 1818 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
| 1823 prep_frame_view_.reset(); | 1819 prep_frame_view_.reset(); |
| 1824 metafile_.reset(); | 1820 metafile_.reset(); |
| 1825 pages_to_render_.clear(); | 1821 pages_to_render_.clear(); |
| 1826 error_ = PREVIEW_ERROR_NONE; | 1822 error_ = PREVIEW_ERROR_NONE; |
| 1827 } | 1823 } |
| OLD | NEW |