1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PRINTING_PRINTING_CONTEXT_WIN_H_
6 #define PRINTING_PRINTING_CONTEXT_WIN_H_
13 #include "printing/mojom/print.mojom.h"
14 #include "printing/printing_context.h"
15 #include "ui/gfx/native_widget_types.h"
21 class COMPONENT_EXPORT(PRINTING) PrintingContextWin : public PrintingContext {
23 explicit PrintingContextWin(Delegate* delegate);
24 PrintingContextWin(const PrintingContextWin&) = delete;
25 PrintingContextWin& operator=(const PrintingContextWin&) = delete;
26 ~PrintingContextWin() override;
28 // PrintingContext implementation.
29 void AskUserForSettings(int max_pages,
32 PrintSettingsCallback callback) override;
33 mojom::ResultCode UseDefaultSettings() override;
34 gfx::Size GetPdfPaperSizeDeviceUnits() override;
35 mojom::ResultCode UpdatePrinterSettings(
36 const PrinterSettings& printer_settings) override;
37 mojom::ResultCode NewDocument(const std::u16string& document_name) override;
38 mojom::ResultCode RenderPage(const PrintedPage& page,
39 const PageSetup& page_setup) override;
40 mojom::ResultCode PrintDocument(const MetafilePlayer& metafile,
41 const PrintSettings& settings,
42 uint32_t num_pages) override;
43 mojom::ResultCode DocumentDone() override;
44 void Cancel() override;
45 void ReleaseContext() override;
46 printing::NativeDrawingContext context() const override;
47 mojom::ResultCode InitWithSettingsForTest(
48 std::unique_ptr<PrintSettings> settings) override;
51 static HWND GetRootWindow(gfx::NativeView view);
53 // Reads the settings from the selected device context. Updates settings_ and
55 virtual mojom::ResultCode InitializeSettings(const std::wstring& device_name,
58 // PrintingContext implementation.
59 mojom::ResultCode OnError() override;
61 void set_context(HDC context) { context_ = context; }
64 // Used in response to the user canceling the printing.
65 static BOOL CALLBACK AbortProc(HDC hdc, int nCode);
67 // The selected printer context.
71 } // namespace printing
73 #endif // PRINTING_PRINTING_CONTEXT_WIN_H_