summaryrefslogtreecommitdiffstats
path: root/embedding/components/printingui/ipc/PrintingParent.h
blob: 66f87726ca544663dcdca897d9c3d7d0cb0f5a15 (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
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=8 et tw=80 : */
/* 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/. */

#ifndef mozilla_embedding_PrintingParent_h
#define mozilla_embedding_PrintingParent_h

#include "mozilla/dom/PBrowserParent.h"
#include "mozilla/embedding/PPrintingParent.h"

class nsIPrintSettingsService;
class nsIWebProgressListener;
class nsPIDOMWindowOuter;
class PPrintProgressDialogParent;
class PPrintSettingsDialogParent;

namespace mozilla {
namespace layout {
class PRemotePrintJobParent;
class RemotePrintJobParent;
}

namespace embedding {

class PrintingParent final : public PPrintingParent
{
public:
    NS_INLINE_DECL_REFCOUNTING(PrintingParent)

    virtual bool
    RecvShowProgress(PBrowserParent* parent,
                     PPrintProgressDialogParent* printProgressDialog,
                     PRemotePrintJobParent* remotePrintJob,
                     const bool& isForPrinting,
                     bool* notifyOnOpen,
                     nsresult* result);
    virtual bool
    RecvShowPrintDialog(PPrintSettingsDialogParent* aDialog,
                        PBrowserParent* aParent,
                        const PrintData& aData);

    virtual bool
    RecvSavePrintSettings(const PrintData& data,
                          const bool& usePrinterNamePrefix,
                          const uint32_t& flags,
                          nsresult* rv);

    virtual PPrintProgressDialogParent*
    AllocPPrintProgressDialogParent();

    virtual bool
    DeallocPPrintProgressDialogParent(PPrintProgressDialogParent* aActor);

    virtual PPrintSettingsDialogParent*
    AllocPPrintSettingsDialogParent();

    virtual bool
    DeallocPPrintSettingsDialogParent(PPrintSettingsDialogParent* aActor);

    virtual PRemotePrintJobParent*
    AllocPRemotePrintJobParent();

    virtual bool
    DeallocPRemotePrintJobParent(PRemotePrintJobParent* aActor);

    virtual void
    ActorDestroy(ActorDestroyReason aWhy);

    MOZ_IMPLICIT PrintingParent();

    /**
     * Serialize nsIPrintSettings to PrintData ready for sending to a child
     * process. A RemotePrintJob will be created and added to the PrintData.
     * An optional progress listener can be given, which will be registered
     * with the RemotePrintJob, so that progress can be tracked in the parent.
     *
     * @param aPrintSettings optional print settings to serialize, otherwise a
     *                       default print settings will be used.
     * @param aProgressListener optional print progress listener.
     * @param aRemotePrintJob optional remote print job, so that an existing
     *                        one can be used.
     * @param aPrintData PrintData to populate.
     */
    nsresult
    SerializeAndEnsureRemotePrintJob(nsIPrintSettings* aPrintSettings,
                                     nsIWebProgressListener* aListener,
                                     layout::RemotePrintJobParent* aRemotePrintJob,
                                     PrintData* aPrintData);

private:
    virtual ~PrintingParent();

    nsPIDOMWindowOuter*
    DOMWindowFromBrowserParent(PBrowserParent* parent);

    nsresult
    ShowPrintDialog(PBrowserParent* parent,
                    const PrintData& data,
                    PrintData* result);

    nsCOMPtr<nsIPrintSettingsService> mPrintSettingsSvc;
};

} // namespace embedding
} // namespace mozilla

#endif