Skip to content

Conversation

@alexeykuzmin
Copy link
Contributor

@alexeykuzmin alexeykuzmin commented Aug 16, 2017

It was disabled during Chromium 59 upgrade, see #9946.

@alexeykuzmin alexeykuzmin mentioned this pull request Aug 16, 2017
2 tasks
@alexeykuzmin
Copy link
Contributor Author

alexeykuzmin commented Aug 21, 2017

Failed "path":

PrintPreviewMessageHandler::PrintToPDF(...)
  PrintWebViewHelper::OnPrintPreview(...)
    PrintWebViewHelper::UpdatePrintSettings(...)  // returns `false`
      PrintingMessageFilter::OnUpdatePrintSettings(...)
        PrintingMessageFilter::OnUpdatePrintSettingsReply(...)
      PrintMsg_Print_Params_IsValid(...)  // returns `false`
    PrintWebViewHelper::DidFinishPrinting(FAIL_PREVIEW);

In void PrintingMessageFilter::OnUpdatePrintSettingsReply:
chromium_src/chrome/browser/printing/printing_message_filter.cc#L320:

if (!printer_query.get() ||
    printer_query->last_status() != PrintingContext::OK) {
  params.Reset();
  } else {
  RenderParamsFromPrintSettings(printer_query->settings(), &params.params); 
  params.params.document_cookie = printer_query->cookie();
  params.pages = PageRange::GetPages(printer_query->settings().ranges());
}

On Windows printer_query->last_status() turns out to be equal to PrintingContext::FAILED,
document_cookie remains to be 0 (which is an invalid value), and then PrintMsg_Print_Params_IsValid returns false when called from PrintWebViewHelper::UpdatePrintSettings.

P.S. In a PrintMsg_Print_Params_IsValid call params.dpi turns out to be 0 too. That's not good.

chromium_src/chrome/renderer/printing/print_web_view_helper.cc#L66:

bool PrintMsg_Print_Params_IsValid(const PrintMsg_Print_Params& params) {
  return !params.content_size.IsEmpty() && !params.page_size.IsEmpty() &&
         !params.printable_area.IsEmpty() && params.document_cookie &&
         params.dpi && params.margin_top >= 0 && params.margin_left >= 0 &&
         params.dpi > kMinDpi && params.document_cookie != 0;
}

@zcbenz zcbenz merged commit 2bfc2be into master Aug 22, 2017
@zcbenz zcbenz deleted the fix-10279 branch August 22, 2017 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants