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