Bug 1409971 - Part 2. Notify cancelling print job when cancel button pushed. r=mconley
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Wed, 15 Nov 2017 16:29:49 +0900
changeset 392380 154ec3c19c88655ffdf1d1684d61de19f1d57bea
parent 392379 983d715192fefc0fc34fa894ba2d03cd3d17c584
child 392381 b78cea997533d47a5b0ff5f719329c4ccd5514d0
push id55546
push usermantaroh@gmail.com
push dateFri, 17 Nov 2017 12:29:49 +0000
treeherderautoland@b78cea997533 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1409971
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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)