Bug 1409971 - Part 2. Notify cancelling print job when cancel button pushed. r?mconley draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Wed, 15 Nov 2017 16:29:49 +0900
changeset 698066 1bf953f4a70046c4a8a4bfd55460582c8574f17b
parent 698065 3cfb06c32f56dba7cbca1dd4bf5a1f226a4d5f95
child 698067 5dcdfba8a4f439675008467b4d7dc0513a12e373
push id89191
push userbmo:mantaroh@gmail.com
push dateWed, 15 Nov 2017 07:31:46 +0000
reviewersmconley
bugs1409971
milestone59.0a1
Bug 1409971 - Part 2. Notify cancelling print job when cancel button pushed. r?mconley This patch will use existing nsIObserver, and distinguish each message by using parameter character. MozReview-Commit-ID: GAhPl7n9wmS
toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp
toolkit/components/printingui/nsPrintProgress.cpp
--- a/toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp
+++ b/toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp
@@ -91,21 +91,25 @@ PrintProgressDialogParent::Recv__delete_
   return IPC_OK();
 }
 
 // nsIObserver
 NS_IMETHODIMP
 PrintProgressDialogParent::Observe(nsISupports *aSubject, const char *aTopic,
                                    const char16_t *aData)
 {
-  if (mActive) {
-    Unused << SendDialogOpened();
+  if (aTopic && !strcmp(aTopic, "cancelled")) {
+    Unused << SendCancelledCurrentJob();
   } else {
-    NS_WARNING("The print progress dialog finished opening, but communications "
-               "with the child have been closed.");
+    if (mActive) {
+      Unused << SendDialogOpened();
+    } else {
+      NS_WARNING("The print progress dialog finished opening, but communications "
+                 "with the child have been closed.");
+    }
   }
 
   return NS_OK;
 }
 
 
 } // namespace embedding
 } // namespace mozilla
--- a/toolkit/components/printingui/nsPrintProgress.cpp
+++ b/toolkit/components/printingui/nsPrintProgress.cpp
@@ -10,16 +10,17 @@
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIXULWindow.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIComponentManager.h"
 #include "nsPIDOMWindow.h"
+#include "nsXULAppAPI.h"
 
 
 NS_IMPL_ADDREF(nsPrintProgress)
 NS_IMPL_RELEASE(nsPrintProgress)
 
 NS_INTERFACE_MAP_BEGIN(nsPrintProgress)
    NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPrintStatusFeedback)
    NS_INTERFACE_MAP_ENTRY(nsIPrintProgress)
@@ -128,16 +129,20 @@ NS_IMETHODIMP nsPrintProgress::GetPrompt
 NS_IMETHODIMP nsPrintProgress::GetProcessCanceledByUser(bool *aProcessCanceledByUser)
 {
   NS_ENSURE_ARG_POINTER(aProcessCanceledByUser);
   *aProcessCanceledByUser = m_processCanceled;
   return NS_OK;
 }
 NS_IMETHODIMP nsPrintProgress::SetProcessCanceledByUser(bool aProcessCanceledByUser)
 {
+  if (XRE_IsE10sParentProcess()) {
+    MOZ_ASSERT(m_observer);
+    m_observer->Observe(nullptr, "cancelled", nullptr);
+  }
   if(m_PrintSetting)
     m_PrintSetting->SetIsCancelled(true);
   m_processCanceled = aProcessCanceledByUser;
   OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, NS_OK);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listener)