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 "nsIObserver.h"
7 : #include "PrintProgressDialogChild.h"
8 :
9 : class nsIWebProgress;
10 : class nsIRequest;
11 :
12 : using mozilla::Unused;
13 :
14 : namespace mozilla {
15 : namespace embedding {
16 :
17 0 : NS_IMPL_ISUPPORTS(PrintProgressDialogChild,
18 : nsIWebProgressListener,
19 : nsIPrintProgressParams)
20 :
21 0 : PrintProgressDialogChild::PrintProgressDialogChild(
22 0 : nsIObserver* aOpenObserver) :
23 0 : mOpenObserver(aOpenObserver)
24 : {
25 0 : }
26 :
27 0 : PrintProgressDialogChild::~PrintProgressDialogChild()
28 : {
29 : // When the printing engine stops supplying information about printing
30 : // progress, it'll drop references to us and destroy us. We need to signal
31 : // the parent to decrement its refcount, as well as prevent it from attempting
32 : // to contact us further.
33 0 : Unused << Send__delete__(this);
34 0 : }
35 :
36 : mozilla::ipc::IPCResult
37 0 : PrintProgressDialogChild::RecvDialogOpened()
38 : {
39 : // nsPrintEngine's observer, which we're reporting to here, doesn't care
40 : // what gets passed as the subject, topic or data, so we'll just send
41 : // nullptrs.
42 0 : mOpenObserver->Observe(nullptr, nullptr, nullptr);
43 0 : return IPC_OK();
44 : }
45 :
46 : // nsIWebProgressListener
47 :
48 : NS_IMETHODIMP
49 0 : PrintProgressDialogChild::OnStateChange(nsIWebProgress* aProgress,
50 : nsIRequest* aRequest,
51 : uint32_t aStateFlags,
52 : nsresult aStatus)
53 : {
54 0 : Unused << SendStateChange(aStateFlags, aStatus);
55 0 : return NS_OK;
56 : }
57 :
58 : NS_IMETHODIMP
59 0 : PrintProgressDialogChild::OnProgressChange(nsIWebProgress * aProgress,
60 : nsIRequest * aRequest,
61 : int32_t aCurSelfProgress,
62 : int32_t aMaxSelfProgress,
63 : int32_t aCurTotalProgress,
64 : int32_t aMaxTotalProgress)
65 : {
66 0 : Unused << SendProgressChange(aCurSelfProgress, aMaxSelfProgress,
67 : aCurTotalProgress, aMaxTotalProgress);
68 0 : return NS_OK;
69 : }
70 :
71 : NS_IMETHODIMP
72 0 : PrintProgressDialogChild::OnLocationChange(nsIWebProgress* aProgress,
73 : nsIRequest* aRequest,
74 : nsIURI* aURI,
75 : uint32_t aFlags)
76 : {
77 0 : return NS_OK;
78 : }
79 :
80 : NS_IMETHODIMP
81 0 : PrintProgressDialogChild::OnStatusChange(nsIWebProgress* aProgress,
82 : nsIRequest* aRequest,
83 : nsresult aStatus,
84 : const char16_t* aMessage)
85 : {
86 0 : return NS_OK;
87 : }
88 :
89 : NS_IMETHODIMP
90 0 : PrintProgressDialogChild::OnSecurityChange(nsIWebProgress* aProgress,
91 : nsIRequest* aRequest,
92 : uint32_t aState)
93 : {
94 0 : return NS_OK;
95 : }
96 :
97 : // nsIPrintProgressParams
98 :
99 0 : NS_IMETHODIMP PrintProgressDialogChild::GetDocTitle(char16_t* *aDocTitle)
100 : {
101 0 : NS_ENSURE_ARG(aDocTitle);
102 :
103 0 : *aDocTitle = ToNewUnicode(mDocTitle);
104 0 : return NS_OK;
105 : }
106 :
107 0 : NS_IMETHODIMP PrintProgressDialogChild::SetDocTitle(const char16_t* aDocTitle)
108 : {
109 0 : mDocTitle = aDocTitle;
110 0 : Unused << SendDocTitleChange(nsString(aDocTitle));
111 0 : return NS_OK;
112 : }
113 :
114 0 : NS_IMETHODIMP PrintProgressDialogChild::GetDocURL(char16_t **aDocURL)
115 : {
116 0 : NS_ENSURE_ARG(aDocURL);
117 :
118 0 : *aDocURL = ToNewUnicode(mDocURL);
119 0 : return NS_OK;
120 : }
121 :
122 0 : NS_IMETHODIMP PrintProgressDialogChild::SetDocURL(const char16_t* aDocURL)
123 : {
124 0 : mDocURL = aDocURL;
125 0 : Unused << SendDocURLChange(nsString(aDocURL));
126 0 : return NS_OK;
127 : }
128 :
129 : } // namespace embedding
130 : } // namespace mozilla
|