Commit 247babb5 authored by Jonathan Watt's avatar Jonathan Watt
Browse files

Bug 1432651 p2 - Remove nsIPrintSession and all the code that uses it....

Bug 1432651 p2 - Remove nsIPrintSession and all the code that uses it. r=emilio,geckoview-reviewers,m_kato

Lately nsIPrintSession was only used to pass around RemotePrintJobChild objects.
Now that we pass those objects explicitly where needed (part 1), this class
serves no purpose.

Another reason to want to get rid of this class is that having it as a member
of nsIPrintSettings made no sense and was confusing.

Differential Revision: https://phabricator.services.mozilla.com/D146381
parent 41b151c8
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -148,7 +148,6 @@
#endif

#ifdef NS_PRINTING
#  include "nsIPrintSession.h"
#  include "nsIPrintSettings.h"
#  include "nsIPrintSettingsService.h"
#  include "nsIWebBrowserPrint.h"
@@ -1117,9 +1116,9 @@ nsresult BrowserChild::UpdateRemotePrintSettings(
      // BC tree, and our code above is simple enough and keeps strong refs to
      // everything.
      ([&]() MOZ_CAN_RUN_SCRIPT_BOUNDARY {
        cv->SetPrintSettingsForSubdocument(
            printSettings, static_cast<RemotePrintJobChild*>(
                               aPrintData.remotePrintJobChild()));
        RefPtr<RemotePrintJobChild> printJob =
            static_cast<RemotePrintJobChild*>(aPrintData.remotePrintJobChild());
        cv->SetPrintSettingsForSubdocument(printSettings, printJob);
      }());
    } else if (RefPtr<BrowserBridgeChild> remoteChild =
                   BrowserBridgeChild::GetFrom(aBc->GetEmbedderElement())) {
@@ -2517,13 +2516,6 @@ mozilla::ipc::IPCResult BrowserChild::RecvPrint(
    return IPC_OK();
  }

  nsCOMPtr<nsIPrintSession> printSession =
      do_CreateInstance("@mozilla.org/gfx/printsession;1", &rv);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    return IPC_OK();
  }

  printSettings->SetPrintSession(printSession);
  printSettingsSvc->DeserializeToPrintSettings(aPrintData, printSettings);
  {
    IgnoredErrorResult rv;
+5 −21
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@
// Print Options
#include "nsIPrintSettings.h"
#include "nsIPrintSettingsService.h"
#include "nsIPrintSession.h"
#include "nsGkAtoms.h"
#include "nsXPCOM.h"

@@ -494,6 +493,11 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview,
  if (aWebProgressListener) {
    printData->mPrintProgressListeners.AppendObject(aWebProgressListener);
  }
  if (mRemotePrintJob) {
    // If we have a RemotePrintJob add it to the print progress listeners,
    // so it can forward to the parent.
    printData->mPrintProgressListeners.AppendElement(mRemotePrintJob);
  }

  // Get the docshell for this documentviewer
  nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell, &rv));
@@ -538,26 +542,6 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview,

  printData->mPrintSettings->GetShrinkToFit(&printData->mShrinkToFit);

  // Create a print session and let the print settings know about it.
  // Don't overwrite an existing print session.
  // The print settings hold an nsWeakPtr to the session so it does not
  // need to be cleared from the settings at the end of the job.
  // XXX What lifetime does the printSession need to have?
  nsCOMPtr<nsIPrintSession> printSession;
  if (!mIsCreatingPrintPreview) {
    rv = printData->mPrintSettings->GetPrintSession(
        getter_AddRefs(printSession));
    if (NS_FAILED(rv) || !printSession) {
      printSession = do_CreateInstance("@mozilla.org/gfx/printsession;1", &rv);
      NS_ENSURE_SUCCESS(rv, rv);
      printData->mPrintSettings->SetPrintSession(printSession);
    } else if (mRemotePrintJob) {
      // If we have a RemotePrintJob add it to the print progress listeners,
      // so it can forward to the parent.
      printData->mPrintProgressListeners.AppendElement(mRemotePrintJob);
    }
  }

  bool printingViaParent =
      XRE_IsContentProcess() && StaticPrefs::print_print_via_parent();
  nsCOMPtr<nsIDeviceContextSpec> devspec;
+0 −7
Original line number Diff line number Diff line
@@ -65,13 +65,6 @@ Classes = [
        'headers': ['/widget/android/nsPrintSettingsServiceAndroid.h'],
        'init_method': 'Init',
    },
    {
        'cid': '{2f977d53-5485-11d4-87e2-0010a4e75ef2}',
        'contract_ids': ['@mozilla.org/gfx/printsession;1'],
        'type': 'nsPrintSession',
        'headers': ['/widget/nsPrintSession.h'],
        'init_method': 'Init',
    },
    {
        'cid': '{d3f69889-e13a-4321-980c-a39332e21f34}',
        'contract_ids': ['@mozilla.org/gfx/devicecontextspec;1'],
+0 −5
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@
#include "nsPrinterListCUPS.h"
#include "nsPrintSettingsServiceX.h"
#include "nsPrintDialogX.h"
#include "nsPrintSession.h"
#include "nsToolkitCompsCID.h"

#include "mozilla/widget/ScreenManager.h"
@@ -66,7 +65,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterListCUPS)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSettingsServiceX, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceX, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsUserIdleServiceX, nsUserIdleServiceX::GetInstance)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ScreenManager, ScreenManager::GetAddRefedSingleton)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(OSXNotificationCenter, Init)
@@ -106,7 +104,6 @@ NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
NS_DEFINE_NAMED_CID(NS_PRINTER_LIST_CID);
NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
@@ -137,7 +134,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
    {&kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecXConstructor},
    {&kNS_PRINTER_LIST_CID, false, NULL, nsPrinterListCUPSConstructor,
     mozilla::Module::MAIN_PROCESS_ONLY},
    {&kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor},
    {&kNS_PRINTSETTINGSSERVICE_CID, false, NULL, nsPrintSettingsServiceXConstructor},
    {&kNS_PRINTDIALOGSERVICE_CID, false, NULL, nsPrintDialogServiceXConstructor,
     mozilla::Module::MAIN_PROCESS_ONLY},
@@ -167,7 +163,6 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
     mozilla::Module::MAIN_PROCESS_ONLY},
    {"@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID},
    {"@mozilla.org/gfx/printerlist;1", &kNS_PRINTER_LIST_CID, mozilla::Module::MAIN_PROCESS_ONLY},
    {"@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID},
    {"@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID},
    {NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID,
     mozilla::Module::MAIN_PROCESS_ONLY},
+0 −7
Original line number Diff line number Diff line
@@ -135,13 +135,6 @@ if defined('NS_PRINTING'):
            'init_method': 'Init',
            'processes': ProcessSelector.MAIN_PROCESS_ONLY,
        },
        {
            'cid': '{2f977d53-5485-11d4-87e2-0010a4e75ef2}',
            'contract_ids': ['@mozilla.org/gfx/printsession;1'],
            'type': 'nsPrintSession',
            'headers': ['/widget/nsPrintSession.h'],
            'init_method': 'Init',
        },
        {
            'cid': '{841387c8-72e6-484b-9296-bf6eea80d58a}',
            'contract_ids': ['@mozilla.org/gfx/printsettings-service;1'],
Loading