Bug 1156742 Part 6: Add RemotePrintJob to PrintSession and PrintData. r=roc, r=mconley

Someone knew that nsIPrintSession would come in handy one day.
This commit is contained in:
Bob Owen 2016-01-05 10:08:57 +00:00
parent 203c24a393
commit dfac96f84c
9 changed files with 73 additions and 10 deletions

View File

@ -5,6 +5,7 @@
include PPrintingTypes;
include protocol PPrinting;
include protocol PRemotePrintJob;
namespace mozilla {
namespace embedding {

View File

@ -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;

View File

@ -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;
}

View File

@ -50,7 +50,7 @@ public:
virtual bool
DeallocPPrintSettingsDialogParent(PPrintSettingsDialogParent* aActor);
virtual PRemotePrintJobParent*
AllocPRemotePrintJobParent();

View File

@ -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()

View File

@ -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;
};

View File

@ -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<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());

View File

@ -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<RemotePrintJobChild> result = mRemotePrintJob;
result.forget(aRemotePrintJob);
return NS_OK;
}
NS_IMETHODIMP
nsPrintSession::SetRemotePrintJob(RemotePrintJobChild* aRemotePrintJob)
{
mRemotePrintJob = aRemotePrintJob;
return NS_OK;
}

View File

@ -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<mozilla::layout::RemotePrintJobChild> mRemotePrintJob;
};
#endif // nsPrintSession_h__