Chromium Code Reviews| 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 "components/printing/renderer/print_web_view_helper.h" | 5 #include "components/printing/renderer/print_web_view_helper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1181 | 1181 |
| 1182 if (!print_preview_context_.source_frame()) { | 1182 if (!print_preview_context_.source_frame()) { |
| 1183 DidFinishPrinting(FAIL_PREVIEW); | 1183 DidFinishPrinting(FAIL_PREVIEW); |
| 1184 return; | 1184 return; |
| 1185 } | 1185 } |
| 1186 | 1186 |
| 1187 if (!UpdatePrintSettings(print_preview_context_.source_frame(), | 1187 if (!UpdatePrintSettings(print_preview_context_.source_frame(), |
| 1188 print_preview_context_.source_node(), settings)) { | 1188 print_preview_context_.source_node(), settings)) { |
| 1189 if (print_preview_context_.last_error() != PREVIEW_ERROR_BAD_SETTING) { | 1189 if (print_preview_context_.last_error() != PREVIEW_ERROR_BAD_SETTING) { |
| 1190 Send(new PrintHostMsg_PrintPreviewInvalidPrinterSettings( | 1190 Send(new PrintHostMsg_PrintPreviewInvalidPrinterSettings( |
| 1191 routing_id(), print_pages_params_ | 1191 routing_id(), |
| 1192 ? print_pages_params_->params.document_cookie | 1192 print_pages_params_ ? print_pages_params_->params.document_cookie : 0, |
| 1193 : 0)); | 1193 print_pages_params_ ? print_pages_params_->params.preview_request_id |
| 1194 : -1)); | |
| 1194 notify_browser_of_print_failure_ = false; // Already sent. | 1195 notify_browser_of_print_failure_ = false; // Already sent. |
| 1195 } | 1196 } |
| 1196 DidFinishPrinting(FAIL_PREVIEW); | 1197 DidFinishPrinting(FAIL_PREVIEW); |
| 1197 return; | 1198 return; |
| 1198 } | 1199 } |
| 1199 | 1200 |
| 1200 // Set the options from document if we are previewing a pdf and send a | 1201 // Set the options from document if we are previewing a pdf and send a |
| 1201 // message to browser. | 1202 // message to browser. |
| 1202 if (print_pages_params_->params.is_first_request && | 1203 if (print_pages_params_->params.is_first_request && |
| 1203 !print_preview_context_.IsModifiable()) { | 1204 !print_preview_context_.IsModifiable()) { |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1569 if (notify_browser_of_print_failure_ && print_pages_params_) { | 1570 if (notify_browser_of_print_failure_ && print_pages_params_) { |
| 1570 int cookie = print_pages_params_->params.document_cookie; | 1571 int cookie = print_pages_params_->params.document_cookie; |
| 1571 Send(new PrintHostMsg_PrintingFailed(routing_id(), cookie)); | 1572 Send(new PrintHostMsg_PrintingFailed(routing_id(), cookie)); |
| 1572 } | 1573 } |
| 1573 break; | 1574 break; |
| 1574 | 1575 |
| 1575 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) | 1576 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 1576 case FAIL_PREVIEW: | 1577 case FAIL_PREVIEW: |
| 1577 int cookie = | 1578 int cookie = |
| 1578 print_pages_params_ ? print_pages_params_->params.document_cookie : 0; | 1579 print_pages_params_ ? print_pages_params_->params.document_cookie : 0; |
| 1580 int request_id = print_pages_params_ | |
| 1581 ? print_pages_params_->params.preview_request_id | |
| 1582 : 0; | |
|
Lei Zhang
2017/06/29 19:25:46
Why do we use 0 here, but -1 on line 1194?
rbpotter
2017/06/29 20:44:10
Should always be -1, fixed.
| |
| 1579 if (notify_browser_of_print_failure_) { | 1583 if (notify_browser_of_print_failure_) { |
| 1580 LOG(ERROR) << "CreatePreviewDocument failed"; | 1584 LOG(ERROR) << "CreatePreviewDocument failed"; |
| 1581 Send(new PrintHostMsg_PrintPreviewFailed(routing_id(), cookie)); | 1585 Send(new PrintHostMsg_PrintPreviewFailed(routing_id(), cookie, |
| 1586 request_id)); | |
| 1582 } else { | 1587 } else { |
| 1583 Send(new PrintHostMsg_PrintPreviewCancelled(routing_id(), cookie)); | 1588 Send(new PrintHostMsg_PrintPreviewCancelled(routing_id(), cookie)); |
| 1584 } | 1589 } |
| 1585 print_preview_context_.Failed(notify_browser_of_print_failure_); | 1590 print_preview_context_.Failed(notify_browser_of_print_failure_); |
| 1586 break; | 1591 break; |
| 1587 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) | 1592 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 1588 } | 1593 } |
| 1589 prep_frame_view_.reset(); | 1594 prep_frame_view_.reset(); |
| 1590 print_pages_params_.reset(); | 1595 print_pages_params_.reset(); |
| 1591 notify_browser_of_print_failure_ = true; | 1596 notify_browser_of_print_failure_ = true; |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2402 blink::WebConsoleMessage::kLevelWarning, message)); | 2407 blink::WebConsoleMessage::kLevelWarning, message)); |
| 2403 return false; | 2408 return false; |
| 2404 } | 2409 } |
| 2405 | 2410 |
| 2406 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2411 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
| 2407 // Reset counter on successful print. | 2412 // Reset counter on successful print. |
| 2408 count_ = 0; | 2413 count_ = 0; |
| 2409 } | 2414 } |
| 2410 | 2415 |
| 2411 } // namespace printing | 2416 } // namespace printing |
| OLD | NEW |