Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: components/printing/renderer/print_web_view_helper.cc

Issue 2962983002: Print Preview: change getPreview to cr.sendWithPromise (Closed)
Patch Set: Re-comment test Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 1177
1178 if (!print_preview_context_.source_frame()) { 1178 if (!print_preview_context_.source_frame()) {
1179 DidFinishPrinting(FAIL_PREVIEW); 1179 DidFinishPrinting(FAIL_PREVIEW);
1180 return; 1180 return;
1181 } 1181 }
1182 1182
1183 if (!UpdatePrintSettings(print_preview_context_.source_frame(), 1183 if (!UpdatePrintSettings(print_preview_context_.source_frame(),
1184 print_preview_context_.source_node(), settings)) { 1184 print_preview_context_.source_node(), settings)) {
1185 if (print_preview_context_.last_error() != PREVIEW_ERROR_BAD_SETTING) { 1185 if (print_preview_context_.last_error() != PREVIEW_ERROR_BAD_SETTING) {
1186 Send(new PrintHostMsg_PrintPreviewInvalidPrinterSettings( 1186 Send(new PrintHostMsg_PrintPreviewInvalidPrinterSettings(
1187 routing_id(), print_pages_params_ 1187 routing_id(),
1188 ? print_pages_params_->params.document_cookie 1188 print_pages_params_ ? print_pages_params_->params.document_cookie : 0,
1189 : 0)); 1189 print_pages_params_ ? print_pages_params_->params.preview_request_id
1190 : -1));
1190 notify_browser_of_print_failure_ = false; // Already sent. 1191 notify_browser_of_print_failure_ = false; // Already sent.
1191 } 1192 }
1192 DidFinishPrinting(FAIL_PREVIEW); 1193 DidFinishPrinting(FAIL_PREVIEW);
1193 return; 1194 return;
1194 } 1195 }
1195 1196
1196 // Set the options from document if we are previewing a pdf and send a 1197 // Set the options from document if we are previewing a pdf and send a
1197 // message to browser. 1198 // message to browser.
1198 if (print_pages_params_->params.is_first_request && 1199 if (print_pages_params_->params.is_first_request &&
1199 !print_preview_context_.IsModifiable()) { 1200 !print_preview_context_.IsModifiable()) {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 if (notify_browser_of_print_failure_ && print_pages_params_) { 1566 if (notify_browser_of_print_failure_ && print_pages_params_) {
1566 int cookie = print_pages_params_->params.document_cookie; 1567 int cookie = print_pages_params_->params.document_cookie;
1567 Send(new PrintHostMsg_PrintingFailed(routing_id(), cookie)); 1568 Send(new PrintHostMsg_PrintingFailed(routing_id(), cookie));
1568 } 1569 }
1569 break; 1570 break;
1570 1571
1571 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) 1572 #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
1572 case FAIL_PREVIEW: 1573 case FAIL_PREVIEW:
1573 int cookie = 1574 int cookie =
1574 print_pages_params_ ? print_pages_params_->params.document_cookie : 0; 1575 print_pages_params_ ? print_pages_params_->params.document_cookie : 0;
1576 int request_id = print_pages_params_
1577 ? print_pages_params_->params.preview_request_id
1578 : 0;
1575 if (notify_browser_of_print_failure_) { 1579 if (notify_browser_of_print_failure_) {
1576 LOG(ERROR) << "CreatePreviewDocument failed"; 1580 LOG(ERROR) << "CreatePreviewDocument failed";
1577 Send(new PrintHostMsg_PrintPreviewFailed(routing_id(), cookie)); 1581 Send(new PrintHostMsg_PrintPreviewFailed(routing_id(), cookie,
1582 request_id));
1578 } else { 1583 } else {
1579 Send(new PrintHostMsg_PrintPreviewCancelled(routing_id(), cookie)); 1584 Send(new PrintHostMsg_PrintPreviewCancelled(routing_id(), cookie));
1580 } 1585 }
1581 print_preview_context_.Failed(notify_browser_of_print_failure_); 1586 print_preview_context_.Failed(notify_browser_of_print_failure_);
1582 break; 1587 break;
1583 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) 1588 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
1584 } 1589 }
1585 prep_frame_view_.reset(); 1590 prep_frame_view_.reset();
1586 print_pages_params_.reset(); 1591 print_pages_params_.reset();
1587 notify_browser_of_print_failure_ = true; 1592 notify_browser_of_print_failure_ = true;
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
2398 blink::WebConsoleMessage::kLevelWarning, message)); 2403 blink::WebConsoleMessage::kLevelWarning, message));
2399 return false; 2404 return false;
2400 } 2405 }
2401 2406
2402 void PrintWebViewHelper::ScriptingThrottler::Reset() { 2407 void PrintWebViewHelper::ScriptingThrottler::Reset() {
2403 // Reset counter on successful print. 2408 // Reset counter on successful print.
2404 count_ = 0; 2409 count_ = 0;
2405 } 2410 }
2406 2411
2407 } // namespace printing 2412 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698