Bug 1409972 - Part 4. Merge mac printingui. r?mconley draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 10 Nov 2017 11:00:54 +0900
changeset 695956 617649c5a48309ff213c80bc74318276f18acadc
parent 695955 3e8c2888e0bc606be2ccc8fe3a1fff93d2c5e6d7
child 695957 c53ae014cbd20f83332891c9f80b7b1da9bb8d55
push id88595
push usermantaroh@gmail.com
push dateFri, 10 Nov 2017 02:11:26 +0000
reviewersmconley
bugs1409972
milestone58.0a1
Bug 1409972 - Part 4. Merge mac printingui. r?mconley This patch will merge mac printingui implementation to common code. Primary differences are: * Remove progress implementation if build target is macOS. MozReview-Commit-ID: 8qoxgmzhqnM
toolkit/components/printingui/nsPrintingPromptService.cpp
toolkit/components/printingui/nsPrintingPromptService.h
--- a/toolkit/components/printingui/nsPrintingPromptService.cpp
+++ b/toolkit/components/printingui/nsPrintingPromptService.cpp
@@ -5,40 +5,47 @@
 
 #include "nsPrintingPromptService.h"
 
 #include "nsIDOMWindow.h"
 #include "nsIServiceManager.h"
 #include "nsISupportsUtils.h"
 #include "nsString.h"
 #include "nsIPrintDialogService.h"
+#include "nsPIDOMWindow.h"
 
 // Printing Progress Includes
+#if !defined(XP_MACOSX)
 #include "nsPrintProgress.h"
 #include "nsPrintProgressParams.h"
 
 static const char* kPrintProgressDialogURL =
   "chrome://global/content/printProgress.xul";
 static const char* kPrtPrvProgressDialogURL =
   "chrome://global/content/printPreviewProgress.xul";
+#endif
 
 NS_IMPL_ISUPPORTS(nsPrintingPromptService,
                   nsIPrintingPromptService,
                   nsIWebProgressListener)
 
 nsPrintingPromptService::nsPrintingPromptService() = default;
 
 nsPrintingPromptService::~nsPrintingPromptService() = default;
 
 nsresult
 nsPrintingPromptService::Init()
 {
+#if !defined(XP_MACOSX)
   nsresult rv;
   mWatcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
   return rv;
+#else
+  return NS_OK;
+#endif
 }
 
 NS_IMETHODIMP
 nsPrintingPromptService::ShowPrintDialog(mozIDOMWindowProxy* parent,
                                          nsIWebBrowserPrint* webBrowserPrint,
                                          nsIPrintSettings* printSettings)
 {
   NS_ENSURE_ARG(webBrowserPrint);
@@ -59,16 +66,17 @@ nsPrintingPromptService::ShowProgress(
   nsIWebBrowserPrint* webBrowserPrint, // ok to be null
   nsIPrintSettings* printSettings,     // ok to be null
   nsIObserver* openDialogObserver,     // ok to be null
   bool isForPrinting,
   nsIWebProgressListener** webProgressListener,
   nsIPrintProgressParams** printProgressParams,
   bool* notifyOnOpen)
 {
+#if !defined(XP_MACOSX)
   NS_ENSURE_ARG(webProgressListener);
   NS_ENSURE_ARG(printProgressParams);
   NS_ENSURE_ARG(notifyOnOpen);
 
   *notifyOnOpen = false;
   if (mPrintProgress) {
     *webProgressListener = nullptr;
     *printProgressParams = nullptr;
@@ -96,16 +104,19 @@ nsPrintingPromptService::ShowProgress(
                                        openDialogObserver,
                                        notifyOnOpen);
   }
 
   prtProgressParams.forget(printProgressParams);
   NS_ADDREF(*webProgressListener = this);
 
   return NS_OK;
+#else
+  return NS_ERROR_NOT_IMPLEMENTED;
+#endif
 }
 
 NS_IMETHODIMP
 nsPrintingPromptService::ShowPageSetup(mozIDOMWindowProxy* parent,
                                        nsIPrintSettings* printSettings,
                                        nsIObserver* aObs)
 {
   NS_ENSURE_ARG(printSettings);
@@ -120,76 +131,86 @@ nsPrintingPromptService::ShowPageSetup(m
 }
 
 NS_IMETHODIMP
 nsPrintingPromptService::OnStateChange(nsIWebProgress* aWebProgress,
                                        nsIRequest* aRequest,
                                        uint32_t aStateFlags,
                                        nsresult aStatus)
 {
+#if !defined(XP_MACOSX)
   if ((aStateFlags & STATE_STOP) && mWebProgressListener) {
     mWebProgressListener->OnStateChange(
       aWebProgress, aRequest, aStateFlags, aStatus);
     if (mPrintProgress) {
       mPrintProgress->CloseProgressDialog(true);
     }
     mPrintProgress = nullptr;
     mWebProgressListener = nullptr;
   }
+#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPrintingPromptService::OnProgressChange(nsIWebProgress* aWebProgress,
                                           nsIRequest* aRequest,
                                           int32_t aCurSelfProgress,
                                           int32_t aMaxSelfProgress,
                                           int32_t aCurTotalProgress,
                                           int32_t aMaxTotalProgress)
 {
+#if !defined(XP_MACOSX)
   if (mWebProgressListener) {
     return mWebProgressListener->OnProgressChange(aWebProgress,
                                                   aRequest,
                                                   aCurSelfProgress,
                                                   aMaxSelfProgress,
                                                   aCurTotalProgress,
                                                   aMaxTotalProgress);
   }
+#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPrintingPromptService::OnLocationChange(nsIWebProgress* aWebProgress,
                                           nsIRequest* aRequest,
                                           nsIURI* location,
                                           uint32_t aFlags)
 {
+#if !defined(XP_MACOSX)
   if (mWebProgressListener) {
     return mWebProgressListener->OnLocationChange(
       aWebProgress, aRequest, location, aFlags);
   }
+#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPrintingPromptService::OnStatusChange(nsIWebProgress* aWebProgress,
                                         nsIRequest* aRequest,
                                         nsresult aStatus,
                                         const char16_t* aMessage)
 {
+#if !defined(XP_MACOSX)
   if (mWebProgressListener) {
     return mWebProgressListener->OnStatusChange(
       aWebProgress, aRequest, aStatus, aMessage);
   }
+#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPrintingPromptService::OnSecurityChange(nsIWebProgress* aWebProgress,
                                           nsIRequest* aRequest,
                                           uint32_t state)
 {
+#if !defined(XP_MACOSX)
   if (mWebProgressListener) {
     return mWebProgressListener->OnSecurityChange(
       aWebProgress, aRequest, state);
   }
+#endif
   return NS_OK;
 }
--- a/toolkit/components/printingui/nsPrintingPromptService.h
+++ b/toolkit/components/printingui/nsPrintingPromptService.h
@@ -18,21 +18,23 @@
   "@mozilla.org/embedcomp/printingprompt-service;1"
 
 #include "nsCOMPtr.h"
 #include "nsIPrintingPromptService.h"
 #include "nsPIPromptService.h"
 #include "nsIWindowWatcher.h"
 
 // Printing Progress Includes
+#include "nsIWebProgressListener.h"
+#if !defined(XP_MACOSX)
 #include "nsPrintProgress.h"
-#include "nsIWebProgressListener.h"
 
 class nsIDOMWindow;
 class nsIDialogParamBlock;
+#endif
 
 class nsPrintingPromptService
   : public nsIPrintingPromptService
   , public nsIWebProgressListener
 {
 
 public:
   nsPrintingPromptService();
@@ -42,14 +44,16 @@ public:
   NS_DECL_NSIPRINTINGPROMPTSERVICE
   NS_DECL_NSIWEBPROGRESSLISTENER
   NS_DECL_ISUPPORTS
 
 protected:
   virtual ~nsPrintingPromptService();
 
 private:
+#if !defined(XP_MACOSX)
   nsCOMPtr<nsIWindowWatcher> mWatcher;
   nsCOMPtr<nsIPrintProgress> mPrintProgress;
   nsCOMPtr<nsIWebProgressListener> mWebProgressListener;
+#endif
 };
 
 #endif