1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
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_
11 #include "printing/printing_context.h"
12 #include "ui/gfx/native_widget_types.h"
19 class COMPONENT_EXPORT(PRINTING) PrintingContextWin : public PrintingContext {
21 explicit PrintingContextWin(Delegate* delegate);
22 PrintingContextWin(const PrintingContextWin&) = delete;
23 PrintingContextWin& operator=(const PrintingContextWin&) = delete;
24 ~PrintingContextWin() override;
26 // Prints the document contained in `metafile`.
27 void PrintDocument(const std::wstring& device_name,
28 const MetafileSkia& metafile);
30 // Initializes with predefined settings.
31 Result InitWithSettingsForTest(std::unique_ptr<PrintSettings> settings);
33 // PrintingContext implementation.
34 void AskUserForSettings(int max_pages,
37 PrintSettingsCallback callback) override;
38 Result UseDefaultSettings() override;
39 gfx::Size GetPdfPaperSizeDeviceUnits() override;
40 Result UpdatePrinterSettings(bool external_preview,
41 bool show_system_dialog,
42 int page_count) override;
43 Result NewDocument(const std::u16string& document_name) override;
44 Result NewPage() override;
45 Result PageDone() override;
46 Result DocumentDone() override;
47 void Cancel() override;
48 void ReleaseContext() override;
49 printing::NativeDrawingContext context() const override;
52 static HWND GetRootWindow(gfx::NativeView view);
54 // Reads the settings from the selected device context. Updates settings_ and
56 virtual Result InitializeSettings(const std::wstring& device_name,
59 void set_context(HDC context) { context_ = context; }
62 // Used in response to the user canceling the printing.
63 static BOOL CALLBACK AbortProc(HDC hdc, int nCode);
65 // The selected printer context.
69 } // namespace printing
71 #endif // PRINTING_PRINTING_CONTEXT_WIN_H_