fix: ensure correct WebContents
when checking PDFReadyToPrint
(32-x-y) (#44011)
* fix: ensure correct `WebContents` when checking `PDFReadyToPrint` (#43943) * fix: ensure correct WebContents when checking PDFReadyToPrint * test: fix paths on Windows Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * Update spec/api-web-contents-spec.ts Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: Charles Kerr <charles@charleskerr.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
dad72f1925
commit
e69f5bc850
2 changed files with 58 additions and 9 deletions
|
@ -27,13 +27,23 @@ void ElectronPDFDocumentHelperClient::UpdateContentRestrictions(
|
|||
// allowed there won't be a printing restriction passed, so we can use this
|
||||
// second call to notify that the pdf document is ready to print.
|
||||
if (!(content_restrictions & chrome_pdf::kContentRestrictionPrint)) {
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
electron::api::WebContents* api_web_contents =
|
||||
electron::api::WebContents::From(
|
||||
web_contents->GetOutermostWebContents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->PDFReadyToPrint();
|
||||
// It's a WebView - emit the event on the WebView webContents.
|
||||
auto* guest_view = extensions::MimeHandlerViewGuest::FromRenderFrameHost(
|
||||
render_frame_host);
|
||||
if (guest_view) {
|
||||
auto* gv_api_wc =
|
||||
electron::api::WebContents::From(guest_view->embedder_web_contents());
|
||||
if (gv_api_wc)
|
||||
gv_api_wc->PDFReadyToPrint();
|
||||
return;
|
||||
}
|
||||
|
||||
auto* wc = content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
if (wc) {
|
||||
auto* api_wc =
|
||||
electron::api::WebContents::From(wc->GetOuterWebContents());
|
||||
if (api_wc)
|
||||
api_wc->PDFReadyToPrint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue