Upload upstream chromium 94.0.4606.31
[platform/framework/web/chromium-efl.git] / printing / printing_context_win.h
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.
4
5 #ifndef PRINTING_PRINTING_CONTEXT_WIN_H_
6 #define PRINTING_PRINTING_CONTEXT_WIN_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "printing/printing_context.h"
12 #include "ui/gfx/native_widget_types.h"
13
14 namespace printing {
15
16 class MetafileSkia;
17 class PrintSettings;
18
19 class COMPONENT_EXPORT(PRINTING) PrintingContextWin : public PrintingContext {
20  public:
21   explicit PrintingContextWin(Delegate* delegate);
22   PrintingContextWin(const PrintingContextWin&) = delete;
23   PrintingContextWin& operator=(const PrintingContextWin&) = delete;
24   ~PrintingContextWin() override;
25
26   // Prints the document contained in `metafile`.
27   void PrintDocument(const std::wstring& device_name,
28                      const MetafileSkia& metafile);
29
30   // Initializes with predefined settings.
31   Result InitWithSettingsForTest(std::unique_ptr<PrintSettings> settings);
32
33   // PrintingContext implementation.
34   void AskUserForSettings(int max_pages,
35                           bool has_selection,
36                           bool is_scripted,
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;
50
51  protected:
52   static HWND GetRootWindow(gfx::NativeView view);
53
54   // Reads the settings from the selected device context. Updates settings_ and
55   // its margins.
56   virtual Result InitializeSettings(const std::wstring& device_name,
57                                     DEVMODE* dev_mode);
58
59   void set_context(HDC context) { context_ = context; }
60
61  private:
62   // Used in response to the user canceling the printing.
63   static BOOL CALLBACK AbortProc(HDC hdc, int nCode);
64
65   // The selected printer context.
66   HDC context_;
67 };
68
69 }  // namespace printing
70
71 #endif  // PRINTING_PRINTING_CONTEXT_WIN_H_