Upload upstream chromium 73.0.3683.0
[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 "base/macros.h"
12 #include "printing/printing_context.h"
13 #include "ui/gfx/native_widget_types.h"
14
15 namespace printing {
16
17 class PrintSettings;
18
19 class PRINTING_EXPORT PrintingContextWin : public PrintingContext {
20  public:
21   explicit PrintingContextWin(Delegate* delegate);
22   ~PrintingContextWin() override;
23
24   // Initializes with predefined settings.
25   Result InitWithSettingsForTest(const PrintSettings& settings);
26
27   // PrintingContext implementation.
28   void AskUserForSettings(int max_pages,
29                           bool has_selection,
30                           bool is_scripted,
31                           PrintSettingsCallback callback) override;
32   Result UseDefaultSettings() override;
33   gfx::Size GetPdfPaperSizeDeviceUnits() override;
34   Result UpdatePrinterSettings(bool external_preview,
35                                bool show_system_dialog,
36                                int page_count) override;
37   Result NewDocument(const base::string16& document_name) override;
38   Result NewPage() override;
39   Result PageDone() override;
40   Result DocumentDone() override;
41   void Cancel() override;
42   void ReleaseContext() override;
43   printing::NativeDrawingContext context() const override;
44
45  protected:
46   static HWND GetRootWindow(gfx::NativeView view);
47
48   // Reads the settings from the selected device context. Updates settings_ and
49   // its margins.
50   virtual Result InitializeSettings(const base::string16& device_name,
51                                     DEVMODE* dev_mode);
52
53   void set_context(HDC context) { context_ = context; }
54
55  private:
56   // Used in response to the user canceling the printing.
57   static BOOL CALLBACK AbortProc(HDC hdc, int nCode);
58
59   // The selected printer context.
60   HDC context_;
61
62   DISALLOW_COPY_AND_ASSIGN(PrintingContextWin);
63 };
64
65 }  // namespace printing
66
67 #endif  // PRINTING_PRINTING_CONTEXT_WIN_H_