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