Fix sync printing not working
This commit is contained in:
parent
85961a0dd9
commit
75627ba6ad
3 changed files with 21 additions and 12 deletions
|
@ -1137,7 +1137,9 @@ void WebContents::Print(mate::Arguments* args) {
|
|||
}
|
||||
|
||||
printing::PrintViewManagerBasic::FromWebContents(web_contents())->
|
||||
PrintNow(settings.silent, settings.print_background);
|
||||
PrintNow(web_contents()->GetMainFrame(),
|
||||
settings.silent,
|
||||
settings.print_background);
|
||||
}
|
||||
|
||||
void WebContents::PrintToPDF(const base::DictionaryValue& setting,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "base/bind.h"
|
||||
#include "base/memory/ref_counted_memory.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/timer/timer.h"
|
||||
|
@ -25,6 +26,7 @@
|
|||
#include "content/public/browser/notification_details.h"
|
||||
#include "content/public/browser/notification_service.h"
|
||||
#include "content/public/browser/notification_source.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "printing/pdf_metafile_skia.h"
|
||||
|
@ -64,9 +66,12 @@ PrintViewManagerBase::~PrintViewManagerBase() {
|
|||
}
|
||||
|
||||
#if !defined(DISABLE_BASIC_PRINTING)
|
||||
bool PrintViewManagerBase::PrintNow(bool silent, bool print_background) {
|
||||
return PrintNowInternal(new PrintMsg_PrintPages(
|
||||
routing_id(), silent, print_background));
|
||||
bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh,
|
||||
bool silent, bool print_background) {
|
||||
int32_t id = rfh->GetRoutingID();
|
||||
return PrintNowInternal(
|
||||
rfh,
|
||||
base::MakeUnique<PrintMsg_PrintPages>(id, silent, print_background));
|
||||
}
|
||||
#endif // !DISABLE_BASIC_PRINTING
|
||||
|
||||
|
@ -467,13 +472,13 @@ bool PrintViewManagerBase::OpportunisticallyCreatePrintJob(int cookie) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool PrintViewManagerBase::PrintNowInternal(IPC::Message* message) {
|
||||
// Don't print / print preview interstitials.
|
||||
if (web_contents()->ShowingInterstitialPage()) {
|
||||
delete message;
|
||||
bool PrintViewManagerBase::PrintNowInternal(
|
||||
content::RenderFrameHost* rfh,
|
||||
std::unique_ptr<IPC::Message> message) {
|
||||
// Don't print / print preview interstitials or crashed tabs.
|
||||
if (web_contents()->ShowingInterstitialPage() || web_contents()->IsCrashed())
|
||||
return false;
|
||||
}
|
||||
return Send(message);
|
||||
return rfh->Send(message.release());
|
||||
}
|
||||
|
||||
void PrintViewManagerBase::ReleasePrinterQuery() {
|
||||
|
|
|
@ -39,7 +39,8 @@ class PrintViewManagerBase : public content::NotificationObserver,
|
|||
// Prints the current document immediately. Since the rendering is
|
||||
// asynchronous, the actual printing will not be completed on the return of
|
||||
// this function. Returns false if printing is impossible at the moment.
|
||||
virtual bool PrintNow(bool silent, bool print_background);
|
||||
virtual bool PrintNow(content::RenderFrameHost* rfh,
|
||||
bool silent, bool print_background);
|
||||
#endif // !DISABLE_BASIC_PRINTING
|
||||
|
||||
// PrintedPagesSource implementation.
|
||||
|
@ -49,7 +50,8 @@ class PrintViewManagerBase : public content::NotificationObserver,
|
|||
explicit PrintViewManagerBase(content::WebContents* web_contents);
|
||||
|
||||
// Helper method for Print*Now().
|
||||
bool PrintNowInternal(IPC::Message* message);
|
||||
bool PrintNowInternal(content::RenderFrameHost* rfh,
|
||||
std::unique_ptr<IPC::Message> message);
|
||||
|
||||
// Terminates or cancels the print job if one was pending.
|
||||
virtual void RenderProcessGone(base::TerminationStatus status) override;
|
||||
|
|
Loading…
Reference in a new issue