Bug 1156742 Part 6: Add RemotePrintJob to PrintSession and PrintData. r=roc, r=mconley
Someone knew that nsIPrintSession would come in handy one day.
--- a/embedding/components/printingui/ipc/PPrintSettingsDialog.ipdl
+++ b/embedding/components/printingui/ipc/PPrintSettingsDialog.ipdl
@@ -1,15 +1,16 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 PPrintingTypes;
include protocol PPrinting;
+include protocol PRemotePrintJob;
namespace mozilla {
namespace embedding {
// A PrintData for success, a failure nsresult for failure.
union PrintDataOrNSResult
{
PrintData;
--- a/embedding/components/printingui/ipc/PPrintingTypes.ipdlh
+++ b/embedding/components/printingui/ipc/PPrintingTypes.ipdlh
@@ -1,22 +1,25 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 {
struct CStringKeyValue {
nsCString key;
nsCString value;
};
struct PrintData {
+ nullable PRemotePrintJob remotePrintJob;
int32_t startPageRange;
int32_t endPageRange;
double edgeTop;
double edgeLeft;
double edgeBottom;
double edgeRight;
double marginTop;
double marginLeft;
--- a/embedding/components/printingui/ipc/PrintingParent.cpp
+++ b/embedding/components/printingui/ipc/PrintingParent.cpp
@@ -18,16 +18,17 @@
#include "PrintingParent.h"
#include "PrintDataUtils.h"
#include "PrintProgressDialogParent.h"
#include "PrintSettingsDialogParent.h"
#include "mozilla/layout/RemotePrintJobParent.h"
using namespace mozilla;
using namespace mozilla::dom;
+using namespace mozilla::layout;
namespace mozilla {
namespace embedding {
bool
PrintingParent::RecvShowProgress(PBrowserParent* parent,
PPrintProgressDialogParent* printProgressDialog,
const bool& isForPrinting,
bool* notifyOnOpen,
@@ -98,16 +99,20 @@ PrintingParent::ShowPrintDialog(PBrowser
rv = po->DeserializeToPrintSettings(aData, settings);
NS_ENSURE_SUCCESS(rv, rv);
rv = pps->ShowPrintDialog(parentWin, wbp, settings);
NS_ENSURE_SUCCESS(rv, rv);
// And send it back.
rv = po->SerializeToPrintData(settings, nullptr, aResult);
+
+ PRemotePrintJobParent* remotePrintJob = new RemotePrintJobParent(settings);
+ aResult->remotePrintJobParent() = SendPRemotePrintJobConstructor(remotePrintJob);
+
return rv;
}
bool
PrintingParent::RecvShowPrintDialog(PPrintSettingsDialogParent* aDialog,
PBrowserParent* aParent,
const PrintData& aData)
{
--- a/embedding/components/printingui/ipc/PrintingParent.h
+++ b/embedding/components/printingui/ipc/PrintingParent.h
@@ -45,17 +45,17 @@ public:
virtual bool
DeallocPPrintProgressDialogParent(PPrintProgressDialogParent* aActor);
virtual PPrintSettingsDialogParent*
AllocPPrintSettingsDialogParent();
virtual bool
DeallocPPrintSettingsDialogParent(PPrintSettingsDialogParent* aActor);
-
+
virtual PRemotePrintJobParent*
AllocPRemotePrintJobParent();
virtual bool
DeallocPRemotePrintJobParent(PRemotePrintJobParent* aActor);
virtual void
ActorDestroy(ActorDestroyReason aWhy);
--- a/layout/printing/ipc/RemotePrintJobChild.cpp
+++ b/layout/printing/ipc/RemotePrintJobChild.cpp
@@ -1,16 +1,18 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 "RemotePrintJobChild.h"
+#include "mozilla/unused.h"
+
namespace mozilla {
namespace layout {
RemotePrintJobChild::RemotePrintJobChild()
{
MOZ_COUNT_CTOR(RemotePrintJobChild);
}
@@ -25,17 +27,17 @@ bool
RemotePrintJobChild::RecvAbortPrint(const nsresult& aRv)
{
NS_NOTREACHED("RemotePrintJobChild::RecvAbortPrint not implemented!");
return false;
}
void
RemotePrintJobChild::ProcessPage(Shmem& aStoredPage)
{
- SendProcessPage(aStoredPage);
+ Unused << SendProcessPage(aStoredPage);
}
RemotePrintJobChild::~RemotePrintJobChild()
{
MOZ_COUNT_DTOR(RemotePrintJobChild);
}
void
--- a/widget/nsIPrintSession.idl
+++ b/widget/nsIPrintSession.idl
@@ -7,25 +7,34 @@
/**
* nsIPrintSession
*
* Stores data pertaining only to a single print job. This
* 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.
*
* @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;
};
--- a/widget/nsPrintOptionsImpl.cpp
+++ b/widget/nsPrintOptionsImpl.cpp
@@ -1,18 +1,21 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 "nsPrintOptionsImpl.h"
+
#include "mozilla/embedding/PPrinting.h"
+#include "mozilla/layout/RemotePrintJobChild.h"
#include "nsPrintingProxy.h"
-#include "nsPrintOptionsImpl.h"
#include "nsReadableUtils.h"
#include "nsPrintSettingsImpl.h"
+#include "nsIPrintSession.h"
#include "nsIDOMWindow.h"
#include "nsIServiceManager.h"
#include "nsIDialogParamBlock.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsIWindowWatcher.h"
#include "nsISupportsArray.h"
@@ -24,16 +27,18 @@
#include "nsAutoPtr.h"
#include "mozilla/Preferences.h"
#include "nsPrintfCString.h"
#include "nsIWebBrowserPrint.h"
using namespace mozilla;
using namespace mozilla::embedding;
+typedef mozilla::layout::RemotePrintJobChild RemotePrintJobChild;
+
NS_IMPL_ISUPPORTS(nsPrintOptions, nsIPrintOptions, nsIPrintSettingsService)
// Pref Constants
static const char kMarginTop[] = "print_margin_top";
static const char kMarginLeft[] = "print_margin_left";
static const char kMarginBottom[] = "print_margin_bottom";
static const char kMarginRight[] = "print_margin_right";
static const char kEdgeTop[] = "print_edge_top";
@@ -228,16 +233,22 @@ nsPrintOptions::SerializeToPrintData(nsI
return NS_OK;
}
NS_IMETHODIMP
nsPrintOptions::DeserializeToPrintSettings(const PrintData& data,
nsIPrintSettings* settings)
{
+ nsCOMPtr<nsIPrintSession> session;
+ nsresult rv = settings->GetPrintSession(getter_AddRefs(session));
+ if (NS_SUCCEEDED(rv) && session) {
+ session->SetRemotePrintJob(
+ static_cast<RemotePrintJobChild*>(data.remotePrintJobChild()));
+ }
settings->SetStartPageRange(data.startPageRange());
settings->SetEndPageRange(data.endPageRange());
settings->SetEdgeTop(data.edgeTop());
settings->SetEdgeLeft(data.edgeLeft());
settings->SetEdgeBottom(data.edgeBottom());
settings->SetEdgeRight(data.edgeRight());
--- a/widget/nsPrintSession.cpp
+++ b/widget/nsPrintSession.cpp
@@ -1,15 +1,19 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 "nsPrintSession.h"
+#include "mozilla/layout/RemotePrintJobChild.h"
+
+typedef mozilla::layout::RemotePrintJobChild RemotePrintJobChild;
+
//*****************************************************************************
//*** nsPrintSession
//*****************************************************************************
NS_IMPL_ISUPPORTS(nsPrintSession, nsIPrintSession, nsISupportsWeakReference)
//-----------------------------------------------------------------------------
nsPrintSession::nsPrintSession()
@@ -21,8 +25,24 @@ nsPrintSession::~nsPrintSession()
{
}
//-----------------------------------------------------------------------------
nsresult nsPrintSession::Init()
{
return NS_OK;
}
+
+NS_IMETHODIMP
+nsPrintSession::GetRemotePrintJob(RemotePrintJobChild** aRemotePrintJob)
+{
+ MOZ_ASSERT(aRemotePrintJob);
+ RefPtr<RemotePrintJobChild> result = mRemotePrintJob;
+ result.forget(aRemotePrintJob);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsPrintSession::SetRemotePrintJob(RemotePrintJobChild* aRemotePrintJob)
+{
+ mRemotePrintJob = aRemotePrintJob;
+ return NS_OK;
+}
--- a/widget/nsPrintSession.h
+++ b/widget/nsPrintSession.h
@@ -2,29 +2,41 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#ifndef nsPrintSession_h__
#define nsPrintSession_h__
#include "nsIPrintSession.h"
+
+#include "mozilla/RefPtr.h"
#include "nsWeakReference.h"
+namespace mozilla {
+namespace layout {
+class RemotePrintJobChild;
+}
+}
+
+
//*****************************************************************************
//*** nsPrintSession
//*****************************************************************************
class nsPrintSession : public nsIPrintSession,
public nsSupportsWeakReference
{
virtual ~nsPrintSession();
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPRINTSESSION
nsPrintSession();
virtual nsresult Init();
+
+private:
+ RefPtr<mozilla::layout::RemotePrintJobChild> mRemotePrintJob;
};
#endif // nsPrintSession_h__