Bug 1763989. Remove the PPrinting and nsPrintingProxy code. r=bobowen
Bug 1757395 basically removed the reason for PPrinting to exist. What remained essentially just added an unnecessary layer of complexity/indirection to the creation of PRmotePrintJob actors. Differential Revision: https://phabricator.services.mozilla.com/D143330
This commit is contained in:
@@ -25,11 +25,14 @@
|
|||||||
#include "mozilla/dom/ContentPlaybackController.h"
|
#include "mozilla/dom/ContentPlaybackController.h"
|
||||||
#include "mozilla/dom/SessionStorageManager.h"
|
#include "mozilla/dom/SessionStorageManager.h"
|
||||||
#include "mozilla/ipc/ProtocolUtils.h"
|
#include "mozilla/ipc/ProtocolUtils.h"
|
||||||
|
#include "mozilla/layout/RemotePrintJobParent.h"
|
||||||
#include "mozilla/net/DocumentLoadListener.h"
|
#include "mozilla/net/DocumentLoadListener.h"
|
||||||
#include "mozilla/NullPrincipal.h"
|
#include "mozilla/NullPrincipal.h"
|
||||||
#include "mozilla/StaticPrefs_docshell.h"
|
#include "mozilla/StaticPrefs_docshell.h"
|
||||||
#include "mozilla/StaticPrefs_fission.h"
|
#include "mozilla/StaticPrefs_fission.h"
|
||||||
#include "mozilla/Telemetry.h"
|
#include "mozilla/Telemetry.h"
|
||||||
|
#include "nsIPrintSettings.h"
|
||||||
|
#include "nsIPrintSettingsService.h"
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
#include "nsIWebNavigation.h"
|
#include "nsIWebNavigation.h"
|
||||||
#include "mozilla/MozPromiseInlines.h"
|
#include "mozilla/MozPromiseInlines.h"
|
||||||
@@ -51,10 +54,6 @@
|
|||||||
#include "nsImportModule.h"
|
#include "nsImportModule.h"
|
||||||
#include "UnitTransforms.h"
|
#include "UnitTransforms.h"
|
||||||
|
|
||||||
#ifdef NS_PRINTING
|
|
||||||
# include "mozilla/embedding/printingui/PrintingParent.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace mozilla::ipc;
|
using namespace mozilla::ipc;
|
||||||
|
|
||||||
extern mozilla::LazyLogModule gAutoplayPermissionLog;
|
extern mozilla::LazyLogModule gAutoplayPermissionLog;
|
||||||
@@ -708,16 +707,38 @@ already_AddRefed<Promise> CanonicalBrowsingContext::Print(
|
|||||||
return promise.forget();
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<embedding::PrintingParent> printingParent =
|
nsCOMPtr<nsIPrintSettingsService> printSettingsSvc =
|
||||||
browserParent->Manager()->GetPrintingParent();
|
do_GetService("@mozilla.org/gfx/printsettings-service;1");
|
||||||
|
if (NS_WARN_IF(!printSettingsSvc)) {
|
||||||
|
promise->MaybeReject(ErrorResult(NS_ERROR_FAILURE));
|
||||||
|
return promise.forget();
|
||||||
|
}
|
||||||
|
|
||||||
embedding::PrintData printData;
|
nsresult rv;
|
||||||
nsresult rv = printingParent->SerializeAndEnsureRemotePrintJob(
|
nsCOMPtr<nsIPrintSettings> printSettings = aPrintSettings;
|
||||||
aPrintSettings, listener, nullptr, &printData);
|
if (!printSettings) {
|
||||||
|
rv = printSettingsSvc->GetNewPrintSettings(getter_AddRefs(printSettings));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
promise->MaybeReject(ErrorResult(rv));
|
promise->MaybeReject(ErrorResult(rv));
|
||||||
return promise.forget();
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
embedding::PrintData printData;
|
||||||
|
rv = printSettingsSvc->SerializeToPrintData(printSettings, &printData);
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
promise->MaybeReject(ErrorResult(rv));
|
||||||
|
return promise.forget();
|
||||||
|
}
|
||||||
|
|
||||||
|
layout::RemotePrintJobParent* remotePrintJob =
|
||||||
|
new layout::RemotePrintJobParent(printSettings);
|
||||||
|
printData.remotePrintJobParent() =
|
||||||
|
browserParent->Manager()->SendPRemotePrintJobConstructor(remotePrintJob);
|
||||||
|
|
||||||
|
if (listener) {
|
||||||
|
remotePrintJob->RegisterListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
if (NS_WARN_IF(!browserParent->SendPrint(this, printData))) {
|
if (NS_WARN_IF(!browserParent->SendPrint(this, printData))) {
|
||||||
promise->MaybeReject(ErrorResult(NS_ERROR_FAILURE));
|
promise->MaybeReject(ErrorResult(NS_ERROR_FAILURE));
|
||||||
|
|||||||
@@ -136,7 +136,6 @@
|
|||||||
#include "nsXULPopupManager.h"
|
#include "nsXULPopupManager.h"
|
||||||
|
|
||||||
#ifdef NS_PRINTING
|
#ifdef NS_PRINTING
|
||||||
# include "mozilla/embedding/printingui/PrintingParent.h"
|
|
||||||
# include "nsIWebBrowserPrint.h"
|
# include "nsIWebBrowserPrint.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,7 @@
|
|||||||
#include "mozilla/layers/CompositorManagerChild.h"
|
#include "mozilla/layers/CompositorManagerChild.h"
|
||||||
#include "mozilla/layers/ContentProcessController.h"
|
#include "mozilla/layers/ContentProcessController.h"
|
||||||
#include "mozilla/layers/ImageBridgeChild.h"
|
#include "mozilla/layers/ImageBridgeChild.h"
|
||||||
|
#include "mozilla/layout/RemotePrintJobChild.h"
|
||||||
#include "mozilla/loader/ScriptCacheActors.h"
|
#include "mozilla/loader/ScriptCacheActors.h"
|
||||||
#include "mozilla/media/MediaChild.h"
|
#include "mozilla/media/MediaChild.h"
|
||||||
#include "mozilla/net/CaptivePortalService.h"
|
#include "mozilla/net/CaptivePortalService.h"
|
||||||
@@ -194,9 +195,6 @@
|
|||||||
#include "nsThreadManager.h"
|
#include "nsThreadManager.h"
|
||||||
#include "nsVariant.h"
|
#include "nsVariant.h"
|
||||||
#include "nsXULAppAPI.h"
|
#include "nsXULAppAPI.h"
|
||||||
#ifdef NS_PRINTING
|
|
||||||
# include "nsPrintingProxy.h"
|
|
||||||
#endif
|
|
||||||
#include "IHistory.h"
|
#include "IHistory.h"
|
||||||
#include "ReferrerInfo.h"
|
#include "ReferrerInfo.h"
|
||||||
#include "base/message_loop.h"
|
#include "base/message_loop.h"
|
||||||
@@ -801,12 +799,6 @@ void ContentChild::Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
|||||||
mID = aChildID;
|
mID = aChildID;
|
||||||
mIsForBrowser = aIsForBrowser;
|
mIsForBrowser = aIsForBrowser;
|
||||||
|
|
||||||
#ifdef NS_PRINTING
|
|
||||||
// Force the creation of the nsPrintingProxy so that it's IPC counterpart,
|
|
||||||
// PrintingParent, is always available for printing initiated from the parent.
|
|
||||||
RefPtr<nsPrintingProxy> printingProxy = nsPrintingProxy::GetInstance();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SetProcessName("Web Content"_ns);
|
SetProcessName("Web Content"_ns);
|
||||||
|
|
||||||
#ifdef NIGHTLY_BUILD
|
#ifdef NIGHTLY_BUILD
|
||||||
@@ -2025,17 +2017,8 @@ mozilla::ipc::IPCResult ContentChild::RecvSocketProcessCrashed() {
|
|||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
PPrintingChild* ContentChild::AllocPPrintingChild() {
|
PRemotePrintJobChild* ContentChild::AllocPRemotePrintJobChild() {
|
||||||
// The ContentParent should never attempt to allocate the nsPrintingProxy,
|
return new RemotePrintJobChild();
|
||||||
// which implements PPrintingChild. Instead, the nsPrintingProxy service is
|
|
||||||
// requested and instantiated via XPCOM, and the constructor of
|
|
||||||
// nsPrintingProxy sets up the IPC connection.
|
|
||||||
MOZ_CRASH("Should never get here!");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContentChild::DeallocPPrintingChild(PPrintingChild* printing) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PChildToParentStreamChild* ContentChild::SendPChildToParentStreamConstructor(
|
PChildToParentStreamChild* ContentChild::SendPChildToParentStreamConstructor(
|
||||||
|
|||||||
@@ -230,9 +230,7 @@ class ContentChild final : public PContentChild,
|
|||||||
PScriptCacheChild*, const FileDescOrError& cacheFile,
|
PScriptCacheChild*, const FileDescOrError& cacheFile,
|
||||||
const bool& wantCacheData) override;
|
const bool& wantCacheData) override;
|
||||||
|
|
||||||
PPrintingChild* AllocPPrintingChild();
|
PRemotePrintJobChild* AllocPRemotePrintJobChild();
|
||||||
|
|
||||||
bool DeallocPPrintingChild(PPrintingChild*);
|
|
||||||
|
|
||||||
PChildToParentStreamChild* AllocPChildToParentStreamChild();
|
PChildToParentStreamChild* AllocPChildToParentStreamChild();
|
||||||
bool DeallocPChildToParentStreamChild(PChildToParentStreamChild*);
|
bool DeallocPChildToParentStreamChild(PChildToParentStreamChild*);
|
||||||
|
|||||||
@@ -134,7 +134,6 @@
|
|||||||
#include "mozilla/dom/nsMixedContentBlocker.h"
|
#include "mozilla/dom/nsMixedContentBlocker.h"
|
||||||
#include "mozilla/dom/power/PowerManagerService.h"
|
#include "mozilla/dom/power/PowerManagerService.h"
|
||||||
#include "mozilla/dom/quota/QuotaManagerService.h"
|
#include "mozilla/dom/quota/QuotaManagerService.h"
|
||||||
#include "mozilla/embedding/printingui/PrintingParent.h"
|
|
||||||
#include "mozilla/extensions/ExtensionsParent.h"
|
#include "mozilla/extensions/ExtensionsParent.h"
|
||||||
#include "mozilla/extensions/StreamFilterParent.h"
|
#include "mozilla/extensions/StreamFilterParent.h"
|
||||||
#include "mozilla/gfx/GPUProcessManager.h"
|
#include "mozilla/gfx/GPUProcessManager.h"
|
||||||
@@ -4328,51 +4327,6 @@ already_AddRefed<PNeckoParent> ContentParent::AllocPNeckoParent() {
|
|||||||
return actor.forget();
|
return actor.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
PPrintingParent* ContentParent::AllocPPrintingParent() {
|
|
||||||
#ifdef NS_PRINTING
|
|
||||||
if (mPrintingParent) {
|
|
||||||
// Only one PrintingParent should be created per process.
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the printing singleton for this process.
|
|
||||||
mPrintingParent = new PrintingParent();
|
|
||||||
|
|
||||||
// Take another reference for IPDL code.
|
|
||||||
mPrintingParent.get()->AddRef();
|
|
||||||
|
|
||||||
return mPrintingParent.get();
|
|
||||||
#else
|
|
||||||
MOZ_ASSERT_UNREACHABLE("Should never be created if no printing.");
|
|
||||||
return nullptr;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContentParent::DeallocPPrintingParent(PPrintingParent* printing) {
|
|
||||||
#ifdef NS_PRINTING
|
|
||||||
MOZ_RELEASE_ASSERT(
|
|
||||||
mPrintingParent == printing,
|
|
||||||
"Only one PrintingParent should have been created per process.");
|
|
||||||
|
|
||||||
// Release reference taken for IPDL code.
|
|
||||||
static_cast<PrintingParent*>(printing)->Release();
|
|
||||||
|
|
||||||
mPrintingParent = nullptr;
|
|
||||||
#else
|
|
||||||
MOZ_ASSERT_UNREACHABLE("Should never have been created if no printing.");
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef NS_PRINTING
|
|
||||||
already_AddRefed<embedding::PrintingParent> ContentParent::GetPrintingParent() {
|
|
||||||
MOZ_ASSERT(mPrintingParent);
|
|
||||||
|
|
||||||
RefPtr<embedding::PrintingParent> printingParent = mPrintingParent;
|
|
||||||
return printingParent.forget();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mozilla::ipc::IPCResult ContentParent::RecvInitStreamFilter(
|
mozilla::ipc::IPCResult ContentParent::RecvInitStreamFilter(
|
||||||
const uint64_t& aChannelId, const nsString& aAddonId,
|
const uint64_t& aChannelId, const nsString& aAddonId,
|
||||||
InitStreamFilterResolver&& aResolver) {
|
InitStreamFilterResolver&& aResolver) {
|
||||||
|
|||||||
@@ -74,10 +74,6 @@ class BenchmarkStorageParent;
|
|||||||
|
|
||||||
using mozilla::loader::PScriptCacheParent;
|
using mozilla::loader::PScriptCacheParent;
|
||||||
|
|
||||||
namespace embedding {
|
|
||||||
class PrintingParent;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ipc {
|
namespace ipc {
|
||||||
class CrashReporterHost;
|
class CrashReporterHost;
|
||||||
class PFileDescriptorSetParent;
|
class PFileDescriptorSetParent;
|
||||||
@@ -450,17 +446,6 @@ class ContentParent final
|
|||||||
return PContentParent::RecvPNeckoConstructor(aActor);
|
return PContentParent::RecvPNeckoConstructor(aActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
PPrintingParent* AllocPPrintingParent();
|
|
||||||
|
|
||||||
bool DeallocPPrintingParent(PPrintingParent* aActor);
|
|
||||||
|
|
||||||
#if defined(NS_PRINTING)
|
|
||||||
/**
|
|
||||||
* @return the PrintingParent for this ContentParent.
|
|
||||||
*/
|
|
||||||
already_AddRefed<embedding::PrintingParent> GetPrintingParent();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mozilla::ipc::IPCResult RecvInitStreamFilter(
|
mozilla::ipc::IPCResult RecvInitStreamFilter(
|
||||||
const uint64_t& aChannelId, const nsString& aAddonId,
|
const uint64_t& aChannelId, const nsString& aAddonId,
|
||||||
InitStreamFilterResolver&& aResolver);
|
InitStreamFilterResolver&& aResolver);
|
||||||
@@ -1615,10 +1600,6 @@ class ContentParent final
|
|||||||
sSandboxBrokerPolicyFactory;
|
sSandboxBrokerPolicyFactory;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NS_PRINTING
|
|
||||||
RefPtr<embedding::PrintingParent> mPrintingParent;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This hashtable is used to run GetFilesHelper objects in the parent process.
|
// This hashtable is used to run GetFilesHelper objects in the parent process.
|
||||||
// GetFilesHelper can be aborted by receiving RecvDeleteGetFilesRequest.
|
// GetFilesHelper can be aborted by receiving RecvDeleteGetFilesRequest.
|
||||||
nsRefPtrHashtable<nsIDHashKey, GetFilesHelper> mGetFilesPendingRequests;
|
nsRefPtrHashtable<nsIDHashKey, GetFilesHelper> mGetFilesPendingRequests;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ include protocol PHeapSnapshotTempFileHelper;
|
|||||||
include protocol PProcessHangMonitor;
|
include protocol PProcessHangMonitor;
|
||||||
include protocol PImageBridge;
|
include protocol PImageBridge;
|
||||||
include protocol PRemoteLazyInputStream;
|
include protocol PRemoteLazyInputStream;
|
||||||
|
include protocol PRemotePrintJob;
|
||||||
include protocol PLoginReputation;
|
include protocol PLoginReputation;
|
||||||
include protocol PMedia;
|
include protocol PMedia;
|
||||||
include protocol PNecko;
|
include protocol PNecko;
|
||||||
@@ -26,7 +27,6 @@ include protocol PStreamFilter;
|
|||||||
include protocol PGMPContent;
|
include protocol PGMPContent;
|
||||||
include protocol PGMPService;
|
include protocol PGMPService;
|
||||||
include protocol PGMP;
|
include protocol PGMP;
|
||||||
include protocol PPrinting;
|
|
||||||
include protocol PChildToParentStream;
|
include protocol PChildToParentStream;
|
||||||
include protocol PParentToChildStream;
|
include protocol PParentToChildStream;
|
||||||
#ifdef MOZ_WEBSPEECH
|
#ifdef MOZ_WEBSPEECH
|
||||||
@@ -468,9 +468,9 @@ sync protocol PContent
|
|||||||
manages PHandlerService;
|
manages PHandlerService;
|
||||||
manages PHeapSnapshotTempFileHelper;
|
manages PHeapSnapshotTempFileHelper;
|
||||||
manages PRemoteLazyInputStream;
|
manages PRemoteLazyInputStream;
|
||||||
|
manages PRemotePrintJob;
|
||||||
manages PMedia;
|
manages PMedia;
|
||||||
manages PNecko;
|
manages PNecko;
|
||||||
manages PPrinting;
|
|
||||||
manages PChildToParentStream;
|
manages PChildToParentStream;
|
||||||
manages PParentToChildStream;
|
manages PParentToChildStream;
|
||||||
#ifdef MOZ_WEBSPEECH
|
#ifdef MOZ_WEBSPEECH
|
||||||
@@ -1035,6 +1035,8 @@ child:
|
|||||||
// details.
|
// details.
|
||||||
async InitNextGenLocalStorageEnabled(bool enabled);
|
async InitNextGenLocalStorageEnabled(bool enabled);
|
||||||
|
|
||||||
|
async PRemotePrintJob();
|
||||||
|
|
||||||
parent:
|
parent:
|
||||||
|
|
||||||
async SynchronizeLayoutHistoryState(MaybeDiscardedBrowsingContext aContext,
|
async SynchronizeLayoutHistoryState(MaybeDiscardedBrowsingContext aContext,
|
||||||
@@ -1085,8 +1087,6 @@ parent:
|
|||||||
|
|
||||||
async PNecko();
|
async PNecko();
|
||||||
|
|
||||||
async PPrinting();
|
|
||||||
|
|
||||||
async PChildToParentStream();
|
async PChildToParentStream();
|
||||||
|
|
||||||
#ifdef MOZ_WEBSPEECH
|
#ifdef MOZ_WEBSPEECH
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
include protocol PPrinting;
|
include protocol PContent;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace layout {
|
namespace layout {
|
||||||
@@ -12,7 +12,7 @@ namespace layout {
|
|||||||
[ChildImpl=virtual, ParentImpl=virtual]
|
[ChildImpl=virtual, ParentImpl=virtual]
|
||||||
async protocol PRemotePrintJob
|
async protocol PRemotePrintJob
|
||||||
{
|
{
|
||||||
manager PPrinting;
|
manager PContent;
|
||||||
|
|
||||||
both:
|
both:
|
||||||
// Tell either side to abort printing and clean up.
|
// Tell either side to abort printing and clean up.
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
/* -*- 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 PContent;
|
|
||||||
include protocol PBrowser;
|
|
||||||
include protocol PRemotePrintJob;
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace embedding {
|
|
||||||
|
|
||||||
[ManualDealloc, ChildImpl=virtual, ParentImpl=virtual]
|
|
||||||
sync protocol PPrinting
|
|
||||||
{
|
|
||||||
manager PContent;
|
|
||||||
manages PRemotePrintJob;
|
|
||||||
|
|
||||||
child:
|
|
||||||
async PRemotePrintJob();
|
|
||||||
async __delete__();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace embedding
|
|
||||||
} // namespace mozilla
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
/* -*- 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 "mozilla/dom/Element.h"
|
|
||||||
#include "mozilla/dom/BrowserParent.h"
|
|
||||||
#include "mozilla/Preferences.h"
|
|
||||||
#include "mozilla/Unused.h"
|
|
||||||
#include "nsIContent.h"
|
|
||||||
#include "mozilla/dom/Document.h"
|
|
||||||
#include "nsIPrintingPromptService.h"
|
|
||||||
#include "nsIPrintSettingsService.h"
|
|
||||||
#include "nsServiceManagerUtils.h"
|
|
||||||
#include "PrintingParent.h"
|
|
||||||
#include "mozilla/layout/RemotePrintJobParent.h"
|
|
||||||
#include "mozilla/StaticPrefs_print.h"
|
|
||||||
|
|
||||||
using namespace mozilla;
|
|
||||||
using namespace mozilla::dom;
|
|
||||||
using namespace mozilla::layout;
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace embedding {
|
|
||||||
void PrintingParent::ActorDestroy(ActorDestroyReason aWhy) {}
|
|
||||||
|
|
||||||
nsresult PrintingParent::SerializeAndEnsureRemotePrintJob(
|
|
||||||
nsIPrintSettings* aPrintSettings, nsIWebProgressListener* aListener,
|
|
||||||
layout::RemotePrintJobParent* aRemotePrintJob, PrintData* aPrintData) {
|
|
||||||
MOZ_ASSERT(aPrintData);
|
|
||||||
|
|
||||||
nsresult rv;
|
|
||||||
nsCOMPtr<nsIPrintSettings> printSettings;
|
|
||||||
if (aPrintSettings) {
|
|
||||||
printSettings = aPrintSettings;
|
|
||||||
} else {
|
|
||||||
rv = mPrintSettingsSvc->GetNewPrintSettings(getter_AddRefs(printSettings));
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = mPrintSettingsSvc->SerializeToPrintData(printSettings, aPrintData);
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
RemotePrintJobParent* remotePrintJob;
|
|
||||||
if (aRemotePrintJob) {
|
|
||||||
remotePrintJob = aRemotePrintJob;
|
|
||||||
aPrintData->remotePrintJobParent() = remotePrintJob;
|
|
||||||
} else {
|
|
||||||
remotePrintJob = new RemotePrintJobParent(aPrintSettings);
|
|
||||||
aPrintData->remotePrintJobParent() =
|
|
||||||
SendPRemotePrintJobConstructor(remotePrintJob);
|
|
||||||
}
|
|
||||||
if (aListener) {
|
|
||||||
remotePrintJob->RegisterListener(aListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintingParent::PrintingParent() {
|
|
||||||
mPrintSettingsSvc = do_GetService("@mozilla.org/gfx/printsettings-service;1");
|
|
||||||
MOZ_ASSERT(mPrintSettingsSvc);
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintingParent::~PrintingParent() = default;
|
|
||||||
|
|
||||||
} // namespace embedding
|
|
||||||
} // namespace mozilla
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set sw=2 ts=8 et 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/. */
|
|
||||||
|
|
||||||
#ifndef mozilla_embedding_PrintingParent_h
|
|
||||||
#define mozilla_embedding_PrintingParent_h
|
|
||||||
|
|
||||||
#include "mozilla/dom/PBrowserParent.h"
|
|
||||||
#include "mozilla/embedding/PPrintingParent.h"
|
|
||||||
|
|
||||||
class nsIPrintSettingsService;
|
|
||||||
class nsIWebProgressListener;
|
|
||||||
class nsPIDOMWindowOuter;
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace layout {
|
|
||||||
class PRemotePrintJobParent;
|
|
||||||
class RemotePrintJobParent;
|
|
||||||
} // namespace layout
|
|
||||||
|
|
||||||
namespace embedding {
|
|
||||||
|
|
||||||
class PrintingParent final : public PPrintingParent {
|
|
||||||
public:
|
|
||||||
NS_INLINE_DECL_REFCOUNTING(PrintingParent)
|
|
||||||
|
|
||||||
void ActorDestroy(ActorDestroyReason aWhy) final;
|
|
||||||
|
|
||||||
MOZ_IMPLICIT PrintingParent();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialize nsIPrintSettings to PrintData ready for sending to a child
|
|
||||||
* process. A RemotePrintJob will be created and added to the PrintData.
|
|
||||||
* An optional progress listener can be given, which will be registered
|
|
||||||
* with the RemotePrintJob, so that progress can be tracked in the parent.
|
|
||||||
*
|
|
||||||
* @param aPrintSettings optional print settings to serialize, otherwise a
|
|
||||||
* default print settings will be used.
|
|
||||||
* @param aProgressListener optional print progress listener.
|
|
||||||
* @param aRemotePrintJob optional remote print job, so that an existing
|
|
||||||
* one can be used.
|
|
||||||
* @param aPrintData PrintData to populate.
|
|
||||||
*/
|
|
||||||
nsresult SerializeAndEnsureRemotePrintJob(
|
|
||||||
nsIPrintSettings* aPrintSettings, nsIWebProgressListener* aListener,
|
|
||||||
layout::RemotePrintJobParent* aRemotePrintJob, PrintData* aPrintData);
|
|
||||||
|
|
||||||
private:
|
|
||||||
~PrintingParent() final;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPrintSettingsService> mPrintSettingsSvc;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace embedding
|
|
||||||
} // namespace mozilla
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -4,22 +4,7 @@
|
|||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# 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/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
EXPORTS += [
|
|
||||||
"nsPrintingProxy.h",
|
|
||||||
]
|
|
||||||
|
|
||||||
EXPORTS.mozilla.embedding.printingui += [
|
|
||||||
"PrintingParent.h",
|
|
||||||
]
|
|
||||||
|
|
||||||
if CONFIG["NS_PRINTING"]:
|
|
||||||
UNIFIED_SOURCES += [
|
|
||||||
"nsPrintingProxy.cpp",
|
|
||||||
"PrintingParent.cpp",
|
|
||||||
]
|
|
||||||
|
|
||||||
IPDL_SOURCES += [
|
IPDL_SOURCES += [
|
||||||
"PPrinting.ipdl",
|
|
||||||
"PPrintingTypes.ipdlh",
|
"PPrintingTypes.ipdlh",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 4; 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 "nsPrintingProxy.h"
|
|
||||||
|
|
||||||
#include "mozilla/ClearOnShutdown.h"
|
|
||||||
#include "mozilla/dom/ContentChild.h"
|
|
||||||
#include "mozilla/dom/BrowserChild.h"
|
|
||||||
#include "mozilla/layout/RemotePrintJobChild.h"
|
|
||||||
#include "mozilla/SpinEventLoopUntil.h"
|
|
||||||
#include "mozilla/Unused.h"
|
|
||||||
#include "nsIDocShell.h"
|
|
||||||
#include "nsIPrintingPromptService.h"
|
|
||||||
#include "nsIPrintSession.h"
|
|
||||||
#include "nsPIDOMWindow.h"
|
|
||||||
#include "nsPrintSettingsService.h"
|
|
||||||
#include "nsServiceManagerUtils.h"
|
|
||||||
|
|
||||||
using namespace mozilla;
|
|
||||||
using namespace mozilla::dom;
|
|
||||||
using namespace mozilla::embedding;
|
|
||||||
using namespace mozilla::layout;
|
|
||||||
|
|
||||||
static StaticRefPtr<nsPrintingProxy> sPrintingProxyInstance;
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS0(nsPrintingProxy)
|
|
||||||
|
|
||||||
nsPrintingProxy::nsPrintingProxy() = default;
|
|
||||||
|
|
||||||
nsPrintingProxy::~nsPrintingProxy() = default;
|
|
||||||
|
|
||||||
/* static */
|
|
||||||
already_AddRefed<nsPrintingProxy> nsPrintingProxy::GetInstance() {
|
|
||||||
if (!sPrintingProxyInstance) {
|
|
||||||
sPrintingProxyInstance = new nsPrintingProxy();
|
|
||||||
if (!sPrintingProxyInstance) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
nsresult rv = sPrintingProxyInstance->Init();
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
sPrintingProxyInstance = nullptr;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
ClearOnShutdown(&sPrintingProxyInstance);
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<nsPrintingProxy> inst = sPrintingProxyInstance.get();
|
|
||||||
return inst.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult nsPrintingProxy::Init() {
|
|
||||||
mozilla::Unused << ContentChild::GetSingleton()->SendPPrintingConstructor(
|
|
||||||
this);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
already_AddRefed<PRemotePrintJobChild>
|
|
||||||
nsPrintingProxy::AllocPRemotePrintJobChild() {
|
|
||||||
RefPtr<RemotePrintJobChild> remotePrintJob = new RemotePrintJobChild();
|
|
||||||
return remotePrintJob.forget();
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/* -*- 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/. */
|
|
||||||
|
|
||||||
#ifndef __nsPrintingProxy_h
|
|
||||||
#define __nsPrintingProxy_h
|
|
||||||
|
|
||||||
#include "nsIPrintingPromptService.h"
|
|
||||||
#include "mozilla/embedding/PPrintingChild.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace layout {
|
|
||||||
class PRemotePrintJobChild;
|
|
||||||
}
|
|
||||||
} // namespace mozilla
|
|
||||||
|
|
||||||
class nsPrintingProxy final : public nsISupports,
|
|
||||||
public mozilla::embedding::PPrintingChild {
|
|
||||||
friend class mozilla::embedding::PPrintingChild;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static already_AddRefed<nsPrintingProxy> GetInstance();
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
|
|
||||||
protected:
|
|
||||||
already_AddRefed<PRemotePrintJobChild> AllocPRemotePrintJobChild() final;
|
|
||||||
|
|
||||||
private:
|
|
||||||
nsPrintingProxy();
|
|
||||||
|
|
||||||
~nsPrintingProxy() final;
|
|
||||||
|
|
||||||
nsresult Init();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -25,7 +25,7 @@ StaticRefPtr<nsPrintingPromptService> sSingleton;
|
|||||||
already_AddRefed<nsPrintingPromptService>
|
already_AddRefed<nsPrintingPromptService>
|
||||||
nsPrintingPromptService::GetSingleton() {
|
nsPrintingPromptService::GetSingleton() {
|
||||||
MOZ_ASSERT(XRE_IsParentProcess(),
|
MOZ_ASSERT(XRE_IsParentProcess(),
|
||||||
"The content process must use nsPrintingProxy");
|
"The content process must not try to open printing prompts");
|
||||||
|
|
||||||
if (!sSingleton) {
|
if (!sSingleton) {
|
||||||
sSingleton = new nsPrintingPromptService();
|
sSingleton = new nsPrintingPromptService();
|
||||||
|
|||||||
@@ -7,29 +7,22 @@
|
|||||||
|
|
||||||
#if defined(NS_PRINTING)
|
#if defined(NS_PRINTING)
|
||||||
# include "nsPrintingPromptService.h"
|
# include "nsPrintingPromptService.h"
|
||||||
# include "nsPrintingProxy.h"
|
|
||||||
|
|
||||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPrintingPromptService,
|
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPrintingPromptService,
|
||||||
nsPrintingPromptService::GetSingleton)
|
nsPrintingPromptService::GetSingleton)
|
||||||
# ifdef PROXY_PRINTING
|
|
||||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPrintingProxy,
|
|
||||||
nsPrintingProxy::GetInstance)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
NS_DEFINE_NAMED_CID(NS_PRINTINGPROMPTSERVICE_CID);
|
NS_DEFINE_NAMED_CID(NS_PRINTINGPROMPTSERVICE_CID);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const mozilla::Module::CIDEntry kEmbeddingCIDs[] = {
|
static const mozilla::Module::CIDEntry kEmbeddingCIDs[] = {
|
||||||
#if defined(NS_PRINTING)
|
#if defined(NS_PRINTING)
|
||||||
|
{&kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr,
|
||||||
|
nsPrintingPromptServiceConstructor
|
||||||
# ifdef PROXY_PRINTING
|
# ifdef PROXY_PRINTING
|
||||||
{&kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr,
|
,
|
||||||
nsPrintingPromptServiceConstructor, mozilla::Module::MAIN_PROCESS_ONLY},
|
mozilla::Module::MAIN_PROCESS_ONLY
|
||||||
{&kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr, nsPrintingProxyConstructor,
|
|
||||||
mozilla::Module::CONTENT_PROCESS_ONLY},
|
|
||||||
# else
|
|
||||||
{&kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr,
|
|
||||||
nsPrintingPromptServiceConstructor},
|
|
||||||
# endif
|
# endif
|
||||||
|
},
|
||||||
#endif
|
#endif
|
||||||
{nullptr}};
|
{nullptr}};
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "nsPrintSettingsServiceX.h"
|
#include "nsPrintSettingsServiceX.h"
|
||||||
|
|
||||||
|
#include "mozilla/embedding/PPrintingTypes.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsQueryObject.h"
|
#include "nsQueryObject.h"
|
||||||
#include "nsPrintSettingsX.h"
|
#include "nsPrintSettingsX.h"
|
||||||
|
|||||||
@@ -5,12 +5,11 @@
|
|||||||
|
|
||||||
#include "nsPrintSettingsService.h"
|
#include "nsPrintSettingsService.h"
|
||||||
|
|
||||||
#include "mozilla/embedding/PPrinting.h"
|
#include "mozilla/embedding/PPrintingTypes.h"
|
||||||
#include "mozilla/layout/RemotePrintJobChild.h"
|
#include "mozilla/layout/RemotePrintJobChild.h"
|
||||||
#include "mozilla/RefPtr.h"
|
#include "mozilla/RefPtr.h"
|
||||||
#include "nsCoord.h"
|
#include "nsCoord.h"
|
||||||
#include "nsIPrinterList.h"
|
#include "nsIPrinterList.h"
|
||||||
#include "nsPrintingProxy.h"
|
|
||||||
#include "nsReadableUtils.h"
|
#include "nsReadableUtils.h"
|
||||||
#include "nsPrintSettingsImpl.h"
|
#include "nsPrintSettingsImpl.h"
|
||||||
#include "nsIPrintSession.h"
|
#include "nsIPrintSession.h"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#ifndef nsPrintSettingsService_h
|
#ifndef nsPrintSettingsService_h
|
||||||
#define nsPrintSettingsService_h
|
#define nsPrintSettingsService_h
|
||||||
|
|
||||||
#include "mozilla/embedding/PPrinting.h"
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIPrintSettings.h"
|
#include "nsIPrintSettings.h"
|
||||||
#include "nsIPrintSettingsService.h"
|
#include "nsIPrintSettingsService.h"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#ifndef nsPrintSettingsServiceWin_h
|
#ifndef nsPrintSettingsServiceWin_h
|
||||||
#define nsPrintSettingsServiceWin_h
|
#define nsPrintSettingsServiceWin_h
|
||||||
|
|
||||||
#include "mozilla/embedding/PPrinting.h"
|
|
||||||
#include "nsPrintSettingsService.h"
|
#include "nsPrintSettingsService.h"
|
||||||
|
|
||||||
class nsIPrintSettings;
|
class nsIPrintSettings;
|
||||||
|
|||||||
Reference in New Issue
Block a user