summaryrefslogtreecommitdiffstats
path: root/embedding/components/printingui/ipc/PrintProgressDialogChild.cpp
blob: a6dc5de4ec42498de900d05a43d3711aad6a548f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* 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 "PrintProgressDialogChild.h"

class nsIWebProgress;
class nsIRequest;

using mozilla::Unused;

namespace mozilla {
namespace embedding {

NS_IMPL_ISUPPORTS(PrintProgressDialogChild,
                  nsIWebProgressListener,
                  nsIPrintProgressParams)

PrintProgressDialogChild::PrintProgressDialogChild(
  nsIObserver* aOpenObserver) :
  mOpenObserver(aOpenObserver)
{
  MOZ_COUNT_CTOR(PrintProgressDialogChild);
}

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);
  MOZ_COUNT_DTOR(PrintProgressDialogChild);
}

bool
PrintProgressDialogChild::RecvDialogOpened()
{
  // nsPrintEngine'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 true;
}

// 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;
}

// nsIPrintProgressParams

NS_IMETHODIMP PrintProgressDialogChild::GetDocTitle(char16_t* *aDocTitle)
{
  NS_ENSURE_ARG(aDocTitle);

  *aDocTitle = ToNewUnicode(mDocTitle);
  return NS_OK;
}

NS_IMETHODIMP PrintProgressDialogChild::SetDocTitle(const char16_t* aDocTitle)
{
  mDocTitle = aDocTitle;
  Unused << SendDocTitleChange(nsString(aDocTitle));
  return NS_OK;
}

NS_IMETHODIMP PrintProgressDialogChild::GetDocURL(char16_t **aDocURL)
{
  NS_ENSURE_ARG(aDocURL);

  *aDocURL = ToNewUnicode(mDocURL);
  return NS_OK;
}

NS_IMETHODIMP PrintProgressDialogChild::SetDocURL(const char16_t* aDocURL)
{
  mDocURL = aDocURL;
  Unused << SendDocURLChange(nsString(aDocURL));
  return NS_OK;
}

} // namespace embedding
} // namespace mozilla