summaryrefslogtreecommitdiffstats
path: root/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp')
-rw-r--r--toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp128
1 files changed, 128 insertions, 0 deletions
diff --git a/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp b/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
new file mode 100644
index 0000000000..c3b5adfb22
--- /dev/null
+++ b/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
@@ -0,0 +1,128 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+#include "mozilla/Unused.h"
+#include "nsIObserver.h"
+#include "nsIPrintProgressParams.h"
+#include "PrintProgressDialogChild.h"
+
+class nsIWebProgress;
+class nsIRequest;
+
+using mozilla::Unused;
+
+namespace mozilla {
+namespace embedding {
+
+NS_IMPL_ISUPPORTS(PrintProgressDialogChild, nsIWebProgressListener,
+ nsIPrintProgressParams)
+
+PrintProgressDialogChild::PrintProgressDialogChild(
+ 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
+ // to contact us further.
+ Unused << Send__delete__(this);
+}
+
+mozilla::ipc::IPCResult PrintProgressDialogChild::RecvDialogOpened() {
+ // nsPrintJob's observer, which we're reporting to here, doesn't care
+ // what gets passed as the subject, topic or data, so we'll just send
+ // 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,
+ uint32_t aStateFlags,
+ nsresult aStatus) {
+ Unused << SendStateChange(aStateFlags, aStatus);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+PrintProgressDialogChild::OnProgressChange(nsIWebProgress* aProgress,
+ nsIRequest* aRequest,
+ int32_t aCurSelfProgress,
+ int32_t aMaxSelfProgress,
+ int32_t aCurTotalProgress,
+ int32_t aMaxTotalProgress) {
+ Unused << SendProgressChange(aCurSelfProgress, aMaxSelfProgress,
+ aCurTotalProgress, aMaxTotalProgress);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+PrintProgressDialogChild::OnLocationChange(nsIWebProgress* aProgress,
+ nsIRequest* aRequest, nsIURI* aURI,
+ uint32_t aFlags) {
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+PrintProgressDialogChild::OnStatusChange(nsIWebProgress* aProgress,
+ nsIRequest* aRequest, nsresult aStatus,
+ const char16_t* aMessage) {
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+PrintProgressDialogChild::OnSecurityChange(nsIWebProgress* aProgress,
+ nsIRequest* aRequest,
+ uint32_t aState) {
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+PrintProgressDialogChild::OnContentBlockingEvent(nsIWebProgress* aProgress,
+ nsIRequest* aRequest,
+ uint32_t aEvent) {
+ return NS_OK;
+}
+
+// nsIPrintProgressParams
+
+NS_IMETHODIMP
+PrintProgressDialogChild::GetDocTitle(nsAString& aDocTitle) {
+ aDocTitle = mDocTitle;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+PrintProgressDialogChild::SetDocTitle(const nsAString& aDocTitle) {
+ mDocTitle = aDocTitle;
+ Unused << SendDocTitleChange(PromiseFlatString(aDocTitle));
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+PrintProgressDialogChild::GetDocURL(nsAString& aDocURL) {
+ aDocURL = mDocURL;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+PrintProgressDialogChild::SetDocURL(const nsAString& aDocURL) {
+ mDocURL = aDocURL;
+ Unused << SendDocURLChange(PromiseFlatString(aDocURL));
+ return NS_OK;
+}
+
+} // namespace embedding
+} // namespace mozilla