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 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 return false; | 1430 return false; |
1431 } | 1431 } |
1432 | 1432 |
1433 if (settings.params.dpi < kMinDpi || !settings.params.document_cookie) { | 1433 if (settings.params.dpi < kMinDpi || !settings.params.document_cookie) { |
1434 print_preview_context_.set_error(PREVIEW_ERROR_UPDATING_PRINT_SETTINGS); | 1434 print_preview_context_.set_error(PREVIEW_ERROR_UPDATING_PRINT_SETTINGS); |
1435 return false; | 1435 return false; |
1436 } | 1436 } |
1437 | 1437 |
1438 if (!print_for_preview_) { | 1438 if (!print_for_preview_) { |
1439 // Validate expected print preview settings. | 1439 // Validate expected print preview settings. |
1440 if (!job_settings->GetString(printing::kPreviewUIAddr, | 1440 if (!job_settings->GetInteger(printing::kPreviewUIID, |
1441 &(settings.params.preview_ui_addr)) || | 1441 &(settings.params.preview_ui_id)) || |
1442 !job_settings->GetInteger(printing::kPreviewRequestID, | 1442 !job_settings->GetInteger(printing::kPreviewRequestID, |
1443 &(settings.params.preview_request_id)) || | 1443 &(settings.params.preview_request_id)) || |
1444 !job_settings->GetBoolean(printing::kIsFirstRequest, | 1444 !job_settings->GetBoolean(printing::kIsFirstRequest, |
1445 &(settings.params.is_first_request))) { | 1445 &(settings.params.is_first_request))) { |
1446 NOTREACHED(); | 1446 NOTREACHED(); |
1447 print_preview_context_.set_error(PREVIEW_ERROR_BAD_SETTING); | 1447 print_preview_context_.set_error(PREVIEW_ERROR_BAD_SETTING); |
1448 return false; | 1448 return false; |
1449 } | 1449 } |
1450 | 1450 |
1451 settings.params.print_to_pdf = IsPrintToPdfRequested(*job_settings); | 1451 settings.params.print_to_pdf = IsPrintToPdfRequested(*job_settings); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 break; | 1601 break; |
1602 } | 1602 } |
1603 default: { | 1603 default: { |
1604 NOTREACHED(); | 1604 NOTREACHED(); |
1605 return; | 1605 return; |
1606 } | 1606 } |
1607 } | 1607 } |
1608 } | 1608 } |
1609 | 1609 |
1610 bool PrintWebViewHelper::CheckForCancel() { | 1610 bool PrintWebViewHelper::CheckForCancel() { |
| 1611 const PrintMsg_Print_Params& print_params = print_pages_params_->params; |
1611 bool cancel = false; | 1612 bool cancel = false; |
1612 Send(new PrintHostMsg_CheckForCancel( | 1613 Send(new PrintHostMsg_CheckForCancel(routing_id(), |
1613 routing_id(), | 1614 print_params.preview_ui_id, |
1614 print_pages_params_->params.preview_ui_addr, | 1615 print_params.preview_request_id, |
1615 print_pages_params_->params.preview_request_id, | 1616 &cancel)); |
1616 &cancel)); | |
1617 if (cancel) | 1617 if (cancel) |
1618 notify_browser_of_print_failure_ = false; | 1618 notify_browser_of_print_failure_ = false; |
1619 return cancel; | 1619 return cancel; |
1620 } | 1620 } |
1621 | 1621 |
1622 bool PrintWebViewHelper::PreviewPageRendered(int page_number, | 1622 bool PrintWebViewHelper::PreviewPageRendered(int page_number, |
1623 printing::Metafile* metafile) { | 1623 printing::Metafile* metafile) { |
1624 DCHECK_GE(page_number, printing::FIRST_PAGE_INDEX); | 1624 DCHECK_GE(page_number, printing::FIRST_PAGE_INDEX); |
1625 | 1625 |
1626 // For non-modifiable files, |metafile| should be NULL, so do not bother | 1626 // For non-modifiable files, |metafile| should be NULL, so do not bother |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1880 DCHECK(IsRendering()); | 1880 DCHECK(IsRendering()); |
1881 return prep_frame_view_->GetPrintCanvasSize(); | 1881 return prep_frame_view_->GetPrintCanvasSize(); |
1882 } | 1882 } |
1883 | 1883 |
1884 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 1884 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
1885 prep_frame_view_.reset(); | 1885 prep_frame_view_.reset(); |
1886 metafile_.reset(); | 1886 metafile_.reset(); |
1887 pages_to_render_.clear(); | 1887 pages_to_render_.clear(); |
1888 error_ = PREVIEW_ERROR_NONE; | 1888 error_ = PREVIEW_ERROR_NONE; |
1889 } | 1889 } |
OLD | NEW |