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
--- 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)