Backed out changeset 8e04b9c921ad (bug 1088070)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Thu, 05 Mar 2015 08:54:00 +0100
changeset 232048 cad3f79fc553734073892e3ab16a90bdc8ea41f1
parent 232047 09cc97c4e8e03d4bcf402c96e11b19998a311e3c
child 232049 42cf6af7870b8c5fd1a64981a2a0b436a811371d
push id11612
push userkwierso@gmail.com
push dateThu, 05 Mar 2015 23:43:42 +0000
treeherderfx-team@0189941a3fd5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1088070
milestone39.0a1
backs out8e04b9c921ad1df7a4aab484ad892d8aa007a6aa
Backed out changeset 8e04b9c921ad (bug 1088070)
embedding/components/build/nsEmbeddingModule.cpp
embedding/components/printingui/ipc/PPrinting.ipdl
embedding/components/printingui/ipc/PrintingParent.cpp
embedding/components/printingui/ipc/PrintingParent.h
embedding/components/printingui/ipc/moz.build
embedding/components/printingui/ipc/nsPrintingProxy.cpp
embedding/components/printingui/ipc/nsPrintingProxy.h
widget/nsPrintOptionsImpl.cpp
--- a/embedding/components/build/nsEmbeddingModule.cpp
+++ b/embedding/components/build/nsEmbeddingModule.cpp
@@ -35,18 +35,17 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCo
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsControllerCommandGroup)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBaseCommandController)
 
 #ifdef MOZ_XUL
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDialogParamBlock)
 #ifdef NS_PRINTING
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintingPromptService, Init)
 #ifdef PROXY_PRINTING
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPrintingProxy,
-                                         nsPrintingProxy::GetInstance)
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintingProxy, Init)
 #endif
 #endif
 #endif
 
 #ifdef MOZ_XUL
 NS_DEFINE_NAMED_CID(NS_DIALOGPARAMBLOCK_CID);
 #ifdef NS_PRINTING
 NS_DEFINE_NAMED_CID(NS_PRINTINGPROMPTSERVICE_CID);
--- a/embedding/components/printingui/ipc/PPrinting.ipdl
+++ b/embedding/components/printingui/ipc/PPrinting.ipdl
@@ -97,18 +97,14 @@ parent:
     returns(bool notifyOnOpen,
             bool success);
 
   sync ShowPrintDialog(PBrowser browser, PrintData settings)
     returns(PrintData modifiedSettings, bool success);
 
   PPrintProgressDialog();
 
-  sync SavePrintSettings(PrintData settings, bool usePrinterNamePrefix,
-                         uint32_t flags)
-    returns(nsresult rv);
-
 child:
   __delete__();
 };
 
 } // namespace embedding
 } // namespace mozilla
--- a/embedding/components/printingui/ipc/PrintingParent.cpp
+++ b/embedding/components/printingui/ipc/PrintingParent.cpp
@@ -7,17 +7,16 @@
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/TabParent.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsIPrintingPromptService.h"
 #include "nsIPrintOptions.h"
 #include "nsIPrintProgressParams.h"
-#include "nsIPrintSettingsService.h"
 #include "nsIServiceManager.h"
 #include "nsIWebProgressListener.h"
 #include "PrintingParent.h"
 #include "PrintDataUtils.h"
 #include "PrintProgressDialogParent.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
@@ -107,41 +106,16 @@ PrintingParent::RecvShowPrintDialog(PBro
   rv = po->SerializeToPrintData(settings, nullptr, &result);
   NS_ENSURE_SUCCESS(rv, true);
 
   *retVal = result;
   *success = true;
   return true;
 }
 
-bool
-PrintingParent::RecvSavePrintSettings(const PrintData& aData,
-                                      const bool& aUsePrinterNamePrefix,
-                                      const uint32_t& aFlags,
-                                      nsresult* aResult)
-{
-  nsCOMPtr<nsIPrintSettingsService> pss =
-    do_GetService("@mozilla.org/gfx/printsettings-service;1", aResult);
-  NS_ENSURE_SUCCESS(*aResult, true);
-
-  nsCOMPtr<nsIPrintOptions> po = do_QueryInterface(pss, aResult);
-  NS_ENSURE_SUCCESS(*aResult, true);
-
-  nsCOMPtr<nsIPrintSettings> settings;
-  *aResult = po->CreatePrintSettings(getter_AddRefs(settings));
-  NS_ENSURE_SUCCESS(*aResult, true);
-
-  *aResult = po->DeserializeToPrintSettings(aData, settings);
-  NS_ENSURE_SUCCESS(*aResult, true);
-
-  *aResult = pss->SavePrintSettingsToPrefs(settings, aUsePrinterNamePrefix, aFlags);
-
-  return true;
-}
-
 PPrintProgressDialogParent*
 PrintingParent::AllocPPrintProgressDialogParent()
 {
   PrintProgressDialogParent* actor = new PrintProgressDialogParent();
   NS_ADDREF(actor); // De-ref'd in the __delete__ handler for
                     // PrintProgressDialogParent.
   return actor;
 }
--- a/embedding/components/printingui/ipc/PrintingParent.h
+++ b/embedding/components/printingui/ipc/PrintingParent.h
@@ -26,22 +26,16 @@ public:
                      bool* notifyOnOpen,
                      bool* success);
     virtual bool
     RecvShowPrintDialog(PBrowserParent* parent,
                         const PrintData& initSettings,
                         PrintData* retVal,
                         bool* success);
 
-    virtual bool
-    RecvSavePrintSettings(const PrintData& aData,
-                          const bool& aUsePrinterNamePrefix,
-                          const uint32_t& aFlags,
-                          nsresult* aResult);
-
     virtual PPrintProgressDialogParent*
     AllocPPrintProgressDialogParent();
 
     virtual bool
     DeallocPPrintProgressDialogParent(PPrintProgressDialogParent* aActor);
 
     virtual void
     ActorDestroy(ActorDestroyReason aWhy);
--- a/embedding/components/printingui/ipc/moz.build
+++ b/embedding/components/printingui/ipc/moz.build
@@ -1,18 +1,14 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
-EXPORTS += [
-    'nsPrintingProxy.h',
-]
-
 EXPORTS.mozilla.embedding.printingui += [
     'PrintingParent.h',
 ]
 
 if CONFIG['NS_PRINTING']:
     UNIFIED_SOURCES += [
         'nsPrintingProxy.cpp',
         'PrintDataUtils.cpp',
--- a/embedding/components/printingui/ipc/nsPrintingProxy.cpp
+++ b/embedding/components/printingui/ipc/nsPrintingProxy.cpp
@@ -1,64 +1,40 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  *
  * 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/ClearOnShutdown.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/unused.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIPrintingPromptService.h"
 #include "nsPIDOMWindow.h"
 #include "nsPrintingProxy.h"
 #include "nsPrintOptionsImpl.h"
 #include "PrintDataUtils.h"
 #include "PrintProgressDialogChild.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::embedding;
 
-static StaticRefPtr<nsPrintingProxy> sPrintingProxyInstance;
-
 NS_IMPL_ISUPPORTS(nsPrintingProxy, nsIPrintingPromptService)
 
 nsPrintingProxy::nsPrintingProxy()
 {
 }
 
 nsPrintingProxy::~nsPrintingProxy()
 {
 }
 
-/* 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);
-  }
-
-  nsRefPtr<nsPrintingProxy> inst = sPrintingProxyInstance.get();
-  return inst.forget();
-}
-
 nsresult
 nsPrintingProxy::Init()
 {
   mozilla::unused << ContentChild::GetSingleton()->SendPPrintingConstructor(this);
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -163,35 +139,16 @@ nsPrintingProxy::ShowPageSetup(nsIDOMWin
 NS_IMETHODIMP
 nsPrintingProxy::ShowPrinterProperties(nsIDOMWindow *parent,
                                        const char16_t *printerName,
                                        nsIPrintSettings *printSettings)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-nsresult
-nsPrintingProxy::SavePrintSettings(nsIPrintSettings* aPS,
-                                   bool aUsePrinterNamePrefix,
-                                   uint32_t aFlags)
-{
-  nsresult rv;
-  nsCOMPtr<nsIPrintOptions> po =
-    do_GetService("@mozilla.org/gfx/printsettings-service;1", &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  PrintData settings;
-  rv = po->SerializeToPrintData(aPS, nullptr, &settings);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  unused << SendSavePrintSettings(settings, aUsePrinterNamePrefix, aFlags,
-                                  &rv);
-  return rv;
-}
-
 PPrintProgressDialogChild*
 nsPrintingProxy::AllocPPrintProgressDialogChild()
 {
   // The parent process will never initiate the PPrintProgressDialog
   // protocol connection, so no need to provide an allocator here.
   NS_NOTREACHED("Allocator for PPrintProgressDialogChild should not be "
                 "called on nsPrintingProxy.");
   return nullptr;
--- a/embedding/components/printingui/ipc/nsPrintingProxy.h
+++ b/embedding/components/printingui/ipc/nsPrintingProxy.h
@@ -12,27 +12,21 @@
 class nsPrintingProxy: public nsIPrintingPromptService,
                        public mozilla::embedding::PPrintingChild
 {
     virtual ~nsPrintingProxy();
 
 public:
     nsPrintingProxy();
 
-    static already_AddRefed<nsPrintingProxy> GetInstance();
-
     nsresult Init();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIPRINTINGPROMPTSERVICE
 
-    nsresult SavePrintSettings(nsIPrintSettings* aPS,
-                               bool aUsePrinterNamePrefix,
-                               uint32_t aFlags);
-
     virtual PPrintProgressDialogChild*
     AllocPPrintProgressDialogChild() MOZ_OVERRIDE;
 
     virtual bool
     DeallocPPrintProgressDialogChild(PPrintProgressDialogChild* aActor) MOZ_OVERRIDE;
 };
 
 #endif
--- a/widget/nsPrintOptionsImpl.cpp
+++ b/widget/nsPrintOptionsImpl.cpp
@@ -1,15 +1,14 @@
 /* -*- 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 "mozilla/embedding/PPrinting.h"
-#include "nsPrintingProxy.h"
 #include "nsPrintOptionsImpl.h"
 #include "nsReadableUtils.h"
 #include "nsPrintSettingsImpl.h"
 
 #include "nsIDOMWindow.h"
 #include "nsIServiceManager.h"
 #include "nsIDialogParamBlock.h"
 #include "nsXPCOM.h"
@@ -1293,25 +1292,16 @@ nsPrintOptions::InitPrintSettingsFromPre
  *  printer-specific preferences. Otherwise, save generic ones.
  */
 nsresult
 nsPrintOptions::SavePrintSettingsToPrefs(nsIPrintSettings *aPS,
                                          bool aUsePrinterNamePrefix,
                                          uint32_t aFlags)
 {
   NS_ENSURE_ARG_POINTER(aPS);
-
-  if (GeckoProcessType_Content == XRE_GetProcessType()) {
-    // If we're in the content process, we can't directly write to the
-    // Preferences service - we have to proxy the save up to the
-    // parent process.
-    nsRefPtr<nsPrintingProxy> proxy = nsPrintingProxy::GetInstance();
-    return proxy->SavePrintSettings(aPS, aUsePrinterNamePrefix, aFlags);
-  }
-
   nsAutoString prtName;
 
   // Do not use printer name in Linux because GTK backend does not support
   // per printer settings.
 #ifndef MOZ_X11
   // Get the printer name from the PrinterSettings for an optional prefix.
   nsresult rv = GetAdjustedPrinterName(aPS, aUsePrinterNamePrefix, prtName);
   NS_ENSURE_SUCCESS(rv, rv);