From dfac96f84cf643e328fade3d9c11625273e7b495 Mon Sep 17 00:00:00 2001 From: Bob Owen Date: Tue, 5 Jan 2016 10:08:57 +0000 Subject: [PATCH] Bug 1156742 Part 6: Add RemotePrintJob to PrintSession and PrintData. r=roc, r=mconley Someone knew that nsIPrintSession would come in handy one day. --- .../printingui/ipc/PPrintSettingsDialog.ipdl | 1 + .../printingui/ipc/PPrintingTypes.ipdlh | 3 +++ .../printingui/ipc/PrintingParent.cpp | 5 +++++ .../printingui/ipc/PrintingParent.h | 2 +- layout/printing/ipc/RemotePrintJobChild.cpp | 4 +++- widget/nsIPrintSession.idl | 21 +++++++++++++------ widget/nsPrintOptionsImpl.cpp | 15 +++++++++++-- widget/nsPrintSession.cpp | 20 ++++++++++++++++++ widget/nsPrintSession.h | 12 +++++++++++ 9 files changed, 73 insertions(+), 10 deletions(-) diff --git a/embedding/components/printingui/ipc/PPrintSettingsDialog.ipdl b/embedding/components/printingui/ipc/PPrintSettingsDialog.ipdl index 91f29fde2a2..95868e3e44d 100644 --- a/embedding/components/printingui/ipc/PPrintSettingsDialog.ipdl +++ b/embedding/components/printingui/ipc/PPrintSettingsDialog.ipdl @@ -5,6 +5,7 @@ include PPrintingTypes; include protocol PPrinting; +include protocol PRemotePrintJob; namespace mozilla { namespace embedding { diff --git a/embedding/components/printingui/ipc/PPrintingTypes.ipdlh b/embedding/components/printingui/ipc/PPrintingTypes.ipdlh index 5f6a2135a39..5a4d7a21c13 100644 --- a/embedding/components/printingui/ipc/PPrintingTypes.ipdlh +++ b/embedding/components/printingui/ipc/PPrintingTypes.ipdlh @@ -3,6 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +include protocol PRemotePrintJob; + namespace mozilla { namespace embedding { @@ -12,6 +14,7 @@ struct CStringKeyValue { }; struct PrintData { + nullable PRemotePrintJob remotePrintJob; int32_t startPageRange; int32_t endPageRange; double edgeTop; diff --git a/embedding/components/printingui/ipc/PrintingParent.cpp b/embedding/components/printingui/ipc/PrintingParent.cpp index d746557150d..804d3818b5c 100644 --- a/embedding/components/printingui/ipc/PrintingParent.cpp +++ b/embedding/components/printingui/ipc/PrintingParent.cpp @@ -23,6 +23,7 @@ using namespace mozilla; using namespace mozilla::dom; +using namespace mozilla::layout; namespace mozilla { namespace embedding { @@ -103,6 +104,10 @@ PrintingParent::ShowPrintDialog(PBrowserParent* aParent, // And send it back. rv = po->SerializeToPrintData(settings, nullptr, aResult); + + PRemotePrintJobParent* remotePrintJob = new RemotePrintJobParent(settings); + aResult->remotePrintJobParent() = SendPRemotePrintJobConstructor(remotePrintJob); + return rv; } diff --git a/embedding/components/printingui/ipc/PrintingParent.h b/embedding/components/printingui/ipc/PrintingParent.h index a1a320bd5a1..79f7ce4e1a4 100644 --- a/embedding/components/printingui/ipc/PrintingParent.h +++ b/embedding/components/printingui/ipc/PrintingParent.h @@ -50,7 +50,7 @@ public: virtual bool DeallocPPrintSettingsDialogParent(PPrintSettingsDialogParent* aActor); - + virtual PRemotePrintJobParent* AllocPRemotePrintJobParent(); diff --git a/layout/printing/ipc/RemotePrintJobChild.cpp b/layout/printing/ipc/RemotePrintJobChild.cpp index 2fb2ca2cad6..5196f39a477 100644 --- a/layout/printing/ipc/RemotePrintJobChild.cpp +++ b/layout/printing/ipc/RemotePrintJobChild.cpp @@ -6,6 +6,8 @@ #include "RemotePrintJobChild.h" +#include "mozilla/unused.h" + namespace mozilla { namespace layout { @@ -30,7 +32,7 @@ RemotePrintJobChild::RecvAbortPrint(const nsresult& aRv) void RemotePrintJobChild::ProcessPage(Shmem& aStoredPage) { - SendProcessPage(aStoredPage); + Unused << SendProcessPage(aStoredPage); } RemotePrintJobChild::~RemotePrintJobChild() diff --git a/widget/nsIPrintSession.idl b/widget/nsIPrintSession.idl index d94dfe7949f..ca7541371c7 100644 --- a/widget/nsIPrintSession.idl +++ b/widget/nsIPrintSession.idl @@ -12,11 +12,6 @@ * differs from nsIPrintSettings, which stores data which may * be valid across a number of jobs. * - * This interface is currently empty since, at this point, only - * platform-specific derived interfaces offer any functionality. - * It is here as a placeholder for when the printing session has - * XP functionality. - * * The creation of a component which implements this interface * will begin the session. Likewise, destruction of that object * will end the session. @@ -24,8 +19,22 @@ * @status */ -[uuid(2f977d52-5485-11d4-87e2-0010a4e75ef2)] +%{ C++ +namespace mozilla { +namespace layout { +class RemotePrintJobChild; +} +} +%} + +[ptr] native RemotePrintJobChildPtr(mozilla::layout::RemotePrintJobChild); + +[uuid(424ae4bb-10ca-4f35-b84e-eab893322df4)] interface nsIPrintSession : nsISupports { + /** + * The remote print job is used for printing via the parent process. + */ + [noscript] attribute RemotePrintJobChildPtr remotePrintJob; }; diff --git a/widget/nsPrintOptionsImpl.cpp b/widget/nsPrintOptionsImpl.cpp index 4735a6f8df0..06ae3d5ff84 100644 --- a/widget/nsPrintOptionsImpl.cpp +++ b/widget/nsPrintOptionsImpl.cpp @@ -3,11 +3,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "mozilla/embedding/PPrinting.h" -#include "nsPrintingProxy.h" #include "nsPrintOptionsImpl.h" + +#include "mozilla/embedding/PPrinting.h" +#include "mozilla/layout/RemotePrintJobChild.h" +#include "nsPrintingProxy.h" #include "nsReadableUtils.h" #include "nsPrintSettingsImpl.h" +#include "nsIPrintSession.h" #include "nsIDOMWindow.h" #include "nsIServiceManager.h" @@ -29,6 +32,8 @@ using namespace mozilla; using namespace mozilla::embedding; +typedef mozilla::layout::RemotePrintJobChild RemotePrintJobChild; + NS_IMPL_ISUPPORTS(nsPrintOptions, nsIPrintOptions, nsIPrintSettingsService) // Pref Constants @@ -233,6 +238,12 @@ NS_IMETHODIMP nsPrintOptions::DeserializeToPrintSettings(const PrintData& data, nsIPrintSettings* settings) { + nsCOMPtr session; + nsresult rv = settings->GetPrintSession(getter_AddRefs(session)); + if (NS_SUCCEEDED(rv) && session) { + session->SetRemotePrintJob( + static_cast(data.remotePrintJobChild())); + } settings->SetStartPageRange(data.startPageRange()); settings->SetEndPageRange(data.endPageRange()); diff --git a/widget/nsPrintSession.cpp b/widget/nsPrintSession.cpp index c4f265db2ff..9b334b42479 100644 --- a/widget/nsPrintSession.cpp +++ b/widget/nsPrintSession.cpp @@ -5,6 +5,10 @@ #include "nsPrintSession.h" +#include "mozilla/layout/RemotePrintJobChild.h" + +typedef mozilla::layout::RemotePrintJobChild RemotePrintJobChild; + //***************************************************************************** //*** nsPrintSession //***************************************************************************** @@ -26,3 +30,19 @@ nsresult nsPrintSession::Init() { return NS_OK; } + +NS_IMETHODIMP +nsPrintSession::GetRemotePrintJob(RemotePrintJobChild** aRemotePrintJob) +{ + MOZ_ASSERT(aRemotePrintJob); + RefPtr result = mRemotePrintJob; + result.forget(aRemotePrintJob); + return NS_OK; +} + +NS_IMETHODIMP +nsPrintSession::SetRemotePrintJob(RemotePrintJobChild* aRemotePrintJob) +{ + mRemotePrintJob = aRemotePrintJob; + return NS_OK; +} diff --git a/widget/nsPrintSession.h b/widget/nsPrintSession.h index c7585adb942..cb349e76fb7 100644 --- a/widget/nsPrintSession.h +++ b/widget/nsPrintSession.h @@ -7,8 +7,17 @@ #define nsPrintSession_h__ #include "nsIPrintSession.h" + +#include "mozilla/RefPtr.h" #include "nsWeakReference.h" +namespace mozilla { +namespace layout { +class RemotePrintJobChild; +} +} + + //***************************************************************************** //*** nsPrintSession //***************************************************************************** @@ -25,6 +34,9 @@ public: nsPrintSession(); virtual nsresult Init(); + +private: + RefPtr mRemotePrintJob; }; #endif // nsPrintSession_h__