1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsPrinterWin_h_
7 #define nsPrinterWin_h_
9 #include "nsPrinterBase.h"
10 #include "mozilla/DataMutex.h"
11 #include "nsTArrayForwardDeclare.h"
13 class nsPrinterWin final
: public nsPrinterBase
{
15 NS_IMETHOD
GetName(nsAString
& aName
) override
;
16 NS_IMETHOD
GetSystemName(nsAString
& aName
) override
;
17 NS_IMETHOD
CopyFromWithValidation(nsIPrintSettings
*, JSContext
*,
19 bool SupportsDuplex() const final
;
20 bool SupportsColor() const final
;
21 bool SupportsMonochrome() const final
;
22 bool SupportsCollation() const final
;
23 PrinterInfo
CreatePrinterInfo() const final
;
24 MarginDouble
GetMarginsForPaper(nsString aPaperId
) const final
;
26 nsPrinterWin() = delete;
27 static already_AddRefed
<nsPrinterWin
> Create(
28 const mozilla::CommonPaperInfoArray
* aPaperInfoArray
,
29 const nsAString
& aName
);
32 nsPrinterWin(const mozilla::CommonPaperInfoArray
* aPaperInfoArray
,
33 const nsAString
& aName
);
34 ~nsPrinterWin() = default;
36 PrintSettingsInitializer
GetValidatedSettings(
37 PrintSettingsInitializer aSettingsToValidate
) const;
39 nsTArray
<uint8_t> CopyDefaultDevmodeW() const;
40 nsTArray
<mozilla::PaperInfo
> PaperList() const;
41 PrintSettingsInitializer
DefaultSettings() const;
44 mutable mozilla::DataMutex
<nsTArray
<uint8_t>> mDefaultDevmodeWStorage
;
45 // Even though some documentation seems to suggest that you should be able to
46 // use printer drivers on separate threads if you have separate handles, we
47 // see threading issues with multiple drivers. This Mutex is used to lock
48 // around all calls to DeviceCapabilitiesW, DocumentPropertiesW and
49 // CreateICW/DCW, to hopefully prevent these issues.
50 mutable mozilla::Mutex mDriverMutex MOZ_UNANNOTATED
{"nsPrinterWin::Driver"};
53 #endif // nsPrinterWin_h_