Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#include "chrome/browser/printing/printer_query.h"
#include "components/printing/common/print_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "printing/page_size_margins.h"
#include "printing/pdf_metafile_skia.h"
Expand Down Expand Up @@ -119,8 +120,16 @@ void PrintPreviewMessageHandler::PrintToPDF(
options.GetInteger(kPreviewRequestID, &request_id);
print_to_pdf_callback_map_[request_id] = callback;

content::RenderViewHost* rvh = web_contents()->GetRenderViewHost();
rvh->Send(new PrintMsg_PrintPreview(rvh->GetRoutingID(), options));
content::RenderFrameHost* rfh = web_contents()->GetMainFrame();

if (rfh) {
std::unique_ptr<base::DictionaryValue> new_options(options.DeepCopy());
new_options->SetInteger(kPreviewInitiatorHostId,
rfh->GetProcess()->GetID());
new_options->SetInteger(kPreviewInitiatorRoutingId,
rfh->GetRoutingID());
rfh->Send(new PrintMsg_PrintPreview(rfh->GetRoutingID(), *new_options));
}
}

void PrintPreviewMessageHandler::RunPrintToPDFCallback(
Expand Down
3 changes: 2 additions & 1 deletion lib/browser/api/web-contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const defaultPrintingSetting = {
copies: 1,
collate: true,
shouldPrintBackgrounds: false,
shouldPrintSelectionOnly: false
shouldPrintSelectionOnly: false,
scaleFactor: 100
}

// JavaScript implementations of WebContents.
Expand Down

0 comments on commit 0ab197d

Please sign in to comment.