Bug 1270447 Part 1: Use the RemotePrintJob's print settings in the parent when available.
MozReview-Commit-ID: 4PnVf4pzHWr
--- a/embedding/components/printingui/ipc/PrintingParent.cpp
+++ b/embedding/components/printingui/ipc/PrintingParent.cpp
@@ -93,30 +93,35 @@ PrintingParent::ShowPrintDialog(PBrowser
return NS_ERROR_FAILURE;
}
// The initSettings we got can be wrapped using
// PrintDataUtils' MockWebBrowserPrint, which implements enough of
// nsIWebBrowserPrint to keep the dialogs happy.
nsCOMPtr<nsIWebBrowserPrint> wbp = new MockWebBrowserPrint(aData);
+ // Use the existing RemotePrintJob and its settings, if we have one, to make
+ // sure they stay current.
+ RemotePrintJobParent* remotePrintJob =
+ static_cast<RemotePrintJobParent*>(aData.remotePrintJobParent());
nsCOMPtr<nsIPrintSettings> settings;
- nsresult rv = mPrintSettingsSvc->GetNewPrintSettings(getter_AddRefs(settings));
- NS_ENSURE_SUCCESS(rv, rv);
+ nsresult rv;
+ if (remotePrintJob) {
+ settings = remotePrintJob->GetPrintSettings();
+ } else {
+ rv = mPrintSettingsSvc->GetNewPrintSettings(getter_AddRefs(settings));
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
rv = mPrintSettingsSvc->DeserializeToPrintSettings(aData, settings);
NS_ENSURE_SUCCESS(rv, rv);
rv = pps->ShowPrintDialog(parentWin, wbp, settings);
NS_ENSURE_SUCCESS(rv, rv);
- // Serialize back to aResult. Use the existing RemotePrintJob if we have one
- // otherwise SerializeAndEnsureRemotePrintJob() will create a new one.
- RemotePrintJobParent* remotePrintJob =
- static_cast<RemotePrintJobParent*>(aData.remotePrintJobParent());
rv = SerializeAndEnsureRemotePrintJob(settings, nullptr, remotePrintJob,
aResult);
return rv;
}
bool
PrintingParent::RecvShowPrintDialog(PPrintSettingsDialogParent* aDialog,
--- a/layout/printing/ipc/RemotePrintJobParent.cpp
+++ b/layout/printing/ipc/RemotePrintJobParent.cpp
@@ -195,16 +195,23 @@ RemotePrintJobParent::RecvStatusChange(c
void
RemotePrintJobParent::RegisterListener(nsIWebProgressListener* aListener)
{
MOZ_ASSERT(aListener);
mPrintProgressListeners.AppendElement(aListener);
}
+already_AddRefed<nsIPrintSettings>
+RemotePrintJobParent::GetPrintSettings()
+{
+ nsCOMPtr<nsIPrintSettings> printSettings = mPrintSettings;
+ return printSettings.forget();
+}
+
RemotePrintJobParent::~RemotePrintJobParent()
{
MOZ_COUNT_DTOR(RemotePrintJobParent);
}
void
RemotePrintJobParent::ActorDestroy(ActorDestroyReason aWhy)
{
--- a/layout/printing/ipc/RemotePrintJobParent.h
+++ b/layout/printing/ipc/RemotePrintJobParent.h
@@ -52,16 +52,21 @@ public:
/**
* Register a progress listener to receive print progress updates.
*
* @param aListener the progress listener to register. Must not be null.
*/
void RegisterListener(nsIWebProgressListener* aListener);
+ /**
+ * @return the print settings for this remote print job.
+ */
+ already_AddRefed<nsIPrintSettings> GetPrintSettings();
+
private:
~RemotePrintJobParent() final;
nsresult InitializePrintDevice(const nsString& aDocumentTitle,
const nsString& aPrintToFile,
const int32_t& aStartPage,
const int32_t& aEndPage);