Bug 1409971 - Part 3. Set nsIPrintSettings::IsCancelled to true in order to cancel print job. r?mconley draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Wed, 15 Nov 2017 16:31:18 +0900
changeset 698067 5dcdfba8a4f439675008467b4d7dc0513a12e373
parent 698066 1bf953f4a70046c4a8a4bfd55460582c8574f17b
child 740287 875dbd4355b74a809e473e2f6c4f8164b1083d6e
push id89191
push userbmo:mantaroh@gmail.com
push dateWed, 15 Nov 2017 07:31:46 +0000
reviewersmconley
bugs1409971
milestone59.0a1
Bug 1409971 - Part 3. Set nsIPrintSettings::IsCancelled to true in order to cancel print job. r?mconley In content process, we should set nsIPrintSettings::IsCancelled to true in order to cancel the print job. nsPrintEngine use this flag for cancelling. MozReview-Commit-ID: EqnNJOlIm5s
toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
toolkit/components/printingui/ipc/PrintProgressDialogChild.h
toolkit/components/printingui/ipc/nsPrintingProxy.cpp
--- a/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
+++ b/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
@@ -14,18 +14,20 @@ using mozilla::Unused;
 namespace mozilla {
 namespace embedding {
 
 NS_IMPL_ISUPPORTS(PrintProgressDialogChild,
                   nsIWebProgressListener,
                   nsIPrintProgressParams)
 
 PrintProgressDialogChild::PrintProgressDialogChild(
-  nsIObserver* aOpenObserver) :
-  mOpenObserver(aOpenObserver)
+  nsIObserver* aOpenObserver,
+  nsIPrintSettings* aPrintSettings) :
+  mOpenObserver(aOpenObserver),
+  mPrintSettings(aPrintSettings)
 {
 }
 
 PrintProgressDialogChild::~PrintProgressDialogChild()
 {
   // When the printing engine stops supplying information about printing
   // progress, it'll drop references to us and destroy us. We need to signal
   // the parent to decrement its refcount, as well as prevent it from attempting
@@ -41,16 +43,19 @@ PrintProgressDialogChild::RecvDialogOpen
   // nullptrs.
   mOpenObserver->Observe(nullptr, nullptr, nullptr);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 PrintProgressDialogChild::RecvCancelledCurrentJob()
 {
+  if (mPrintSettings) {
+    mPrintSettings->SetIsCancelled(true);
+  }
   return IPC_OK();
 }
 
 // nsIWebProgressListener
 
 NS_IMETHODIMP
 PrintProgressDialogChild::OnStateChange(nsIWebProgress* aProgress,
                                         nsIRequest* aRequest,
--- a/toolkit/components/printingui/ipc/PrintProgressDialogChild.h
+++ b/toolkit/components/printingui/ipc/PrintProgressDialogChild.h
@@ -2,41 +2,44 @@
  * 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_PrintProgressDialogChild_h
 #define mozilla_embedding_PrintProgressDialogChild_h
 
 #include "mozilla/embedding/PPrintProgressDialogChild.h"
 #include "nsIPrintProgressParams.h"
+#include "nsIPrintSettings.h"
 #include "nsIWebProgressListener.h"
 
 class nsIObserver;
 
 namespace mozilla {
 namespace embedding {
 
 class PrintProgressDialogChild final : public PPrintProgressDialogChild,
                                        public nsIWebProgressListener,
                                        public nsIPrintProgressParams
 {
   NS_DECL_ISUPPORTS
   NS_DECL_NSIWEBPROGRESSLISTENER
   NS_DECL_NSIPRINTPROGRESSPARAMS
 
 public:
-  MOZ_IMPLICIT PrintProgressDialogChild(nsIObserver* aOpenObserver);
+    MOZ_IMPLICIT PrintProgressDialogChild(nsIObserver* aOpenObserver,
+                                          nsIPrintSettings* aPrintSettings);
 
   virtual mozilla::ipc::IPCResult RecvDialogOpened() override;
 
   virtual mozilla::ipc::IPCResult RecvCancelledCurrentJob() override;
 
 private:
   virtual ~PrintProgressDialogChild();
   nsCOMPtr<nsIObserver> mOpenObserver;
   nsString mDocTitle;
   nsString mDocURL;
+  nsCOMPtr<nsIPrintSettings> mPrintSettings;
 };
 
 } // namespace embedding
 } // namespace mozilla
 
 #endif
--- a/toolkit/components/printingui/ipc/nsPrintingProxy.cpp
+++ b/toolkit/components/printingui/ipc/nsPrintingProxy.cpp
@@ -143,17 +143,17 @@ nsPrintingProxy::ShowProgress(mozIDOMWin
   nsCOMPtr<nsPIDOMWindowOuter> pwin = nsPIDOMWindowOuter::From(parent);
   NS_ENSURE_STATE(pwin);
   nsCOMPtr<nsIDocShell> docShell = pwin->GetDocShell();
   NS_ENSURE_STATE(docShell);
   nsCOMPtr<nsITabChild> tabchild = docShell->GetTabChild();
   TabChild* pBrowser = static_cast<TabChild*>(tabchild.get());
 
   RefPtr<PrintProgressDialogChild> dialogChild =
-    new PrintProgressDialogChild(openDialogObserver);
+    new PrintProgressDialogChild(openDialogObserver, printSettings);
 
   SendPPrintProgressDialogConstructor(dialogChild);
 
   // Get the RemotePrintJob if we have one available.
   RefPtr<mozilla::layout::RemotePrintJobChild> remotePrintJob;
   if (printSettings) {
     nsCOMPtr<nsIPrintSession> printSession;
     nsresult rv = printSettings->GetPrintSession(getter_AddRefs(printSession));