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/printing/print_web_view_helper.h" | 5 #include "chrome/renderer/printing/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 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 | 1403 |
1404 bool PrintWebViewHelper::CalculateNumberOfPages(blink::WebFrame* frame, | 1404 bool PrintWebViewHelper::CalculateNumberOfPages(blink::WebFrame* frame, |
1405 const blink::WebNode& node, | 1405 const blink::WebNode& node, |
1406 int* number_of_pages) { | 1406 int* number_of_pages) { |
1407 DCHECK(frame); | 1407 DCHECK(frame); |
1408 bool fit_to_paper_size = !(PrintingNodeOrPdfFrame(frame, node)); | 1408 bool fit_to_paper_size = !(PrintingNodeOrPdfFrame(frame, node)); |
1409 if (!InitPrintSettings(fit_to_paper_size)) { | 1409 if (!InitPrintSettings(fit_to_paper_size)) { |
1410 notify_browser_of_print_failure_ = false; | 1410 notify_browser_of_print_failure_ = false; |
1411 render_view()->RunModalAlertDialog( | 1411 render_view()->RunModalAlertDialog( |
1412 frame, | 1412 frame, |
1413 l10n_util::GetStringUTF16(IDS_PRINT_PREVIEW_INVALID_PRINTER_SETTINGS)); | 1413 l10n_util::GetStringUTF16(IDS_PRINT_INVALID_PRINTER_SETTINGS)); |
1414 return false; | 1414 return false; |
1415 } | 1415 } |
1416 | 1416 |
1417 const PrintMsg_Print_Params& params = print_pages_params_->params; | 1417 const PrintMsg_Print_Params& params = print_pages_params_->params; |
1418 PrepareFrameAndViewForPrint prepare(params, frame, node, ignore_css_margins_); | 1418 PrepareFrameAndViewForPrint prepare(params, frame, node, ignore_css_margins_); |
1419 prepare.StartPrinting(); | 1419 prepare.StartPrinting(); |
1420 | 1420 |
1421 Send(new PrintHostMsg_DidGetDocumentCookie(routing_id(), | 1421 Send(new PrintHostMsg_DidGetDocumentCookie(routing_id(), |
1422 params.document_cookie)); | 1422 params.document_cookie)); |
1423 *number_of_pages = prepare.GetExpectedPageCount(); | 1423 *number_of_pages = prepare.GetExpectedPageCount(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 } else { | 1468 } else { |
1469 // PrintForPrintPreview | 1469 // PrintForPrintPreview |
1470 blink::WebFrame* print_frame = NULL; | 1470 blink::WebFrame* print_frame = NULL; |
1471 // This may not be the right frame, but the alert will be modal, | 1471 // This may not be the right frame, but the alert will be modal, |
1472 // therefore it works well enough. | 1472 // therefore it works well enough. |
1473 GetPrintFrame(&print_frame); | 1473 GetPrintFrame(&print_frame); |
1474 if (print_frame) { | 1474 if (print_frame) { |
1475 render_view()->RunModalAlertDialog( | 1475 render_view()->RunModalAlertDialog( |
1476 print_frame, | 1476 print_frame, |
1477 l10n_util::GetStringUTF16( | 1477 l10n_util::GetStringUTF16( |
1478 IDS_PRINT_PREVIEW_INVALID_PRINTER_SETTINGS)); | 1478 IDS_PRINT_INVALID_PRINTER_SETTINGS)); |
1479 } | 1479 } |
1480 } | 1480 } |
1481 return false; | 1481 return false; |
1482 } | 1482 } |
1483 | 1483 |
1484 if (settings.params.dpi < kMinDpi || !settings.params.document_cookie) { | 1484 if (settings.params.dpi < kMinDpi || !settings.params.document_cookie) { |
1485 print_preview_context_.set_error(PREVIEW_ERROR_UPDATING_PRINT_SETTINGS); | 1485 print_preview_context_.set_error(PREVIEW_ERROR_UPDATING_PRINT_SETTINGS); |
1486 return false; | 1486 return false; |
1487 } | 1487 } |
1488 | 1488 |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1992 } | 1992 } |
1993 | 1993 |
1994 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 1994 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
1995 prep_frame_view_.reset(); | 1995 prep_frame_view_.reset(); |
1996 metafile_.reset(); | 1996 metafile_.reset(); |
1997 pages_to_render_.clear(); | 1997 pages_to_render_.clear(); |
1998 error_ = PREVIEW_ERROR_NONE; | 1998 error_ = PREVIEW_ERROR_NONE; |
1999 } | 1999 } |
2000 | 2000 |
2001 } // namespace printing | 2001 } // namespace printing |
OLD | NEW |