Removes some dead accessibility code.
[chromium-blink-merge.git] / printing / printing_context_win.h
blob81a61c34fbf89c796ea752305d1213249a6c2ebb
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_
8 #include <ocidl.h>
9 #include <commdlg.h>
11 #include <string>
13 #include "base/memory/scoped_ptr.h"
14 #include "build/build_config.h"
15 #include "printing/printing_context.h"
16 #include "ui/gfx/native_widget_types.h"
18 namespace printing {
20 class PrintingContextWin : public PrintingContext {
21 public:
22 explicit PrintingContextWin(const std::string& app_locale);
23 ~PrintingContextWin();
25 // PrintingContext implementation.
26 virtual void AskUserForSettings(gfx::NativeView parent_view,
27 int max_pages,
28 bool has_selection,
29 PrintSettingsCallback* callback);
30 virtual Result UseDefaultSettings();
31 virtual Result UpdatePrintSettings(const base::DictionaryValue& job_settings,
32 const PageRanges& ranges);
33 virtual Result InitWithSettings(const PrintSettings& settings);
34 virtual Result NewDocument(const string16& document_name);
35 virtual Result NewPage();
36 virtual Result PageDone();
37 virtual Result DocumentDone();
38 virtual void Cancel();
39 virtual void ReleaseContext();
40 virtual gfx::NativeDrawingContext context() const;
42 #if defined(UNIT_TEST)
43 // Sets a fake PrintDlgEx function pointer in tests.
44 void SetPrintDialog(HRESULT (__stdcall *print_dialog_func)(LPPRINTDLGEX)) {
45 print_dialog_func_ = print_dialog_func;
47 #endif // defined(UNIT_TEST)
49 // Allocates the HDC for a specific DEVMODE.
50 static bool AllocateContext(const std::wstring& printer_name,
51 const DEVMODE* dev_mode,
52 gfx::NativeDrawingContext* context);
54 // Retrieves the content of a GetPrinter call.
55 static void GetPrinterHelper(HANDLE printer, int level,
56 scoped_array<uint8>* buffer);
58 private:
59 // Class that manages the PrintDlgEx() callbacks. This is meant to be a
60 // temporary object used during the Print... dialog display.
61 class CallbackHandler;
63 // Used in response to the user canceling the printing.
64 static BOOL CALLBACK AbortProc(HDC hdc, int nCode);
66 // Reads the settings from the selected device context. Updates settings_ and
67 // its margins.
68 bool InitializeSettings(const DEVMODE& dev_mode,
69 const std::wstring& new_device_name,
70 const PRINTPAGERANGE* ranges,
71 int number_ranges,
72 bool selection_only);
74 // Retrieves the printer's default low-level settings. On Windows, context_ is
75 // allocated with this call.
76 bool GetPrinterSettings(HANDLE printer,
77 const std::wstring& device_name);
79 // Parses the result of a PRINTDLGEX result.
80 Result ParseDialogResultEx(const PRINTDLGEX& dialog_options);
81 Result ParseDialogResult(const PRINTDLG& dialog_options);
83 // The selected printer context.
84 HDC context_;
86 // The dialog box for the time it is shown.
87 volatile HWND dialog_box_;
89 // Function pointer that defaults to PrintDlgEx. It can be changed using
90 // SetPrintDialog() in tests.
91 HRESULT (__stdcall *print_dialog_func_)(LPPRINTDLGEX);
93 DISALLOW_COPY_AND_ASSIGN(PrintingContextWin);
96 } // namespace printing
98 #endif // PRINTING_PRINTING_CONTEXT_WIN_H_