Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this
3 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #include "mozilla/Unused.h"
6 : #include "nsIPrintProgressParams.h"
7 : #include "nsIWebProgressListener.h"
8 : #include "PrintProgressDialogParent.h"
9 :
10 : using mozilla::Unused;
11 :
12 : namespace mozilla {
13 : namespace embedding {
14 :
15 0 : NS_IMPL_ISUPPORTS(PrintProgressDialogParent, nsIObserver)
16 :
17 0 : PrintProgressDialogParent::PrintProgressDialogParent() :
18 0 : mActive(true)
19 : {
20 0 : }
21 :
22 0 : PrintProgressDialogParent::~PrintProgressDialogParent()
23 : {
24 0 : }
25 :
26 : void
27 0 : PrintProgressDialogParent::SetWebProgressListener(nsIWebProgressListener* aListener)
28 : {
29 0 : mWebProgressListener = aListener;
30 0 : }
31 :
32 : void
33 0 : PrintProgressDialogParent::SetPrintProgressParams(nsIPrintProgressParams* aParams)
34 : {
35 0 : mPrintProgressParams = aParams;
36 0 : }
37 :
38 : mozilla::ipc::IPCResult
39 0 : PrintProgressDialogParent::RecvStateChange(const long& stateFlags,
40 : const nsresult& status)
41 : {
42 0 : if (mWebProgressListener) {
43 0 : mWebProgressListener->OnStateChange(nullptr, nullptr, stateFlags, status);
44 : }
45 0 : return IPC_OK();
46 : }
47 :
48 : mozilla::ipc::IPCResult
49 0 : PrintProgressDialogParent::RecvProgressChange(const long& curSelfProgress,
50 : const long& maxSelfProgress,
51 : const long& curTotalProgress,
52 : const long& maxTotalProgress)
53 : {
54 0 : if (mWebProgressListener) {
55 0 : mWebProgressListener->OnProgressChange(nullptr, nullptr, curSelfProgress,
56 0 : maxSelfProgress, curTotalProgress,
57 0 : maxTotalProgress);
58 : }
59 0 : return IPC_OK();
60 : }
61 :
62 : mozilla::ipc::IPCResult
63 0 : PrintProgressDialogParent::RecvDocTitleChange(const nsString& newTitle)
64 : {
65 0 : if (mPrintProgressParams) {
66 0 : mPrintProgressParams->SetDocTitle(newTitle.get());
67 : }
68 0 : return IPC_OK();
69 : }
70 :
71 : mozilla::ipc::IPCResult
72 0 : PrintProgressDialogParent::RecvDocURLChange(const nsString& newURL)
73 : {
74 0 : if (mPrintProgressParams) {
75 0 : mPrintProgressParams->SetDocURL(newURL.get());
76 : }
77 0 : return IPC_OK();
78 : }
79 :
80 : void
81 0 : PrintProgressDialogParent::ActorDestroy(ActorDestroyReason aWhy)
82 : {
83 0 : }
84 :
85 : mozilla::ipc::IPCResult
86 0 : PrintProgressDialogParent::Recv__delete__()
87 : {
88 : // The child has requested that we tear down the connection, so we set a
89 : // member to make sure we don't try to contact it after the fact.
90 0 : mActive = false;
91 0 : return IPC_OK();
92 : }
93 :
94 : // nsIObserver
95 : NS_IMETHODIMP
96 0 : PrintProgressDialogParent::Observe(nsISupports *aSubject, const char *aTopic,
97 : const char16_t *aData)
98 : {
99 0 : if (mActive) {
100 0 : Unused << SendDialogOpened();
101 : } else {
102 : NS_WARNING("The print progress dialog finished opening, but communications "
103 0 : "with the child have been closed.");
104 : }
105 :
106 0 : return NS_OK;
107 : }
108 :
109 :
110 : } // namespace embedding
111 : } // namespace mozilla
|