| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PRINTING_PRINTING_CONTEXT_WIN_H_ | 5 #ifndef PRINTING_PRINTING_CONTEXT_WIN_H_ |
| 6 #define PRINTING_PRINTING_CONTEXT_WIN_H_ | 6 #define PRINTING_PRINTING_CONTEXT_WIN_H_ |
| 7 | 7 |
| 8 #include <ocidl.h> | 8 #include <ocidl.h> |
| 9 #include <commdlg.h> | 9 #include <commdlg.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "printing/printing_context.h" | 15 #include "printing/printing_context.h" |
| 16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 17 #include "ui/shell_dialogs/print_settings_dialog_win.h" |
| 17 | 18 |
| 18 namespace printing { | 19 namespace printing { |
| 19 | 20 |
| 20 class PRINTING_EXPORT PrintingContextWin : public PrintingContext { | 21 class PRINTING_EXPORT PrintingContextWin |
| 22 : public PrintingContext, |
| 23 public ui::PrintSettingsDialogWin::Listener { |
| 21 public: | 24 public: |
| 22 explicit PrintingContextWin(const std::string& app_locale); | 25 explicit PrintingContextWin(const std::string& app_locale); |
| 23 ~PrintingContextWin(); | 26 ~PrintingContextWin(); |
| 24 | 27 |
| 25 // PrintingContext implementation. | 28 // PrintingContext implementation. |
| 26 virtual void AskUserForSettings( | 29 virtual void AskUserForSettings( |
| 27 gfx::NativeView parent_view, | 30 gfx::NativeView parent_view, |
| 28 int max_pages, | 31 int max_pages, |
| 29 bool has_selection, | 32 bool has_selection, |
| 30 const PrintSettingsCallback& callback) OVERRIDE; | 33 const PrintSettingsCallback& callback) OVERRIDE; |
| 31 virtual Result UseDefaultSettings() OVERRIDE; | 34 virtual Result UseDefaultSettings() OVERRIDE; |
| 32 virtual Result UpdatePrinterSettings( | 35 virtual Result UpdatePrinterSettings( |
| 33 const base::DictionaryValue& job_settings, | 36 const base::DictionaryValue& job_settings, |
| 34 const PageRanges& ranges) OVERRIDE; | 37 const PageRanges& ranges) OVERRIDE; |
| 35 virtual Result InitWithSettings(const PrintSettings& settings) OVERRIDE; | 38 virtual Result InitWithSettings(const PrintSettings& settings) OVERRIDE; |
| 36 virtual Result NewDocument(const base::string16& document_name) OVERRIDE; | 39 virtual Result NewDocument(const base::string16& document_name) OVERRIDE; |
| 37 virtual Result NewPage() OVERRIDE; | 40 virtual Result NewPage() OVERRIDE; |
| 38 virtual Result PageDone() OVERRIDE; | 41 virtual Result PageDone() OVERRIDE; |
| 39 virtual Result DocumentDone() OVERRIDE; | 42 virtual Result DocumentDone() OVERRIDE; |
| 40 virtual void Cancel() OVERRIDE; | 43 virtual void Cancel() OVERRIDE; |
| 41 virtual void ReleaseContext() OVERRIDE; | 44 virtual void ReleaseContext() OVERRIDE; |
| 42 virtual gfx::NativeDrawingContext context() const OVERRIDE; | 45 virtual gfx::NativeDrawingContext context() const OVERRIDE; |
| 43 | 46 |
| 47 // PrintSettingsDialogWin::Listener implementation: |
| 48 virtual void PrintSettingsConfirmed(PRINTDLGEX* dialog_options) OVERRIDE; |
| 49 virtual void PrintSettingsCancelled(PRINTDLGEX* dialog_options) OVERRIDE; |
| 50 |
| 44 #if defined(UNIT_TEST) || defined(PRINTING_IMPLEMENTATION) | 51 #if defined(UNIT_TEST) || defined(PRINTING_IMPLEMENTATION) |
| 45 // Sets a fake PrintDlgEx function pointer in tests. | 52 // Sets a fake PrintDlgEx function pointer in tests. |
| 46 void SetPrintDialog(HRESULT (__stdcall *print_dialog_func)(LPPRINTDLGEX)) { | 53 void SetPrintDialog(HRESULT (__stdcall *print_dialog_func)(LPPRINTDLGEX)) { |
| 47 print_dialog_func_ = print_dialog_func; | 54 print_dialog_func_ = print_dialog_func; |
| 48 } | 55 } |
| 49 #endif // defined(UNIT_TEST) | 56 #endif // defined(UNIT_TEST) |
| 50 | 57 |
| 51 // Allocates the HDC for a specific DEVMODE. | 58 // Allocates the HDC for a specific DEVMODE. |
| 52 static bool AllocateContext(const std::wstring& printer_name, | 59 static bool AllocateContext(const std::wstring& printer_name, |
| 53 const DEVMODE* dev_mode, | 60 const DEVMODE* dev_mode, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 81 // The selected printer context. | 88 // The selected printer context. |
| 82 HDC context_; | 89 HDC context_; |
| 83 | 90 |
| 84 // The dialog box for the time it is shown. | 91 // The dialog box for the time it is shown. |
| 85 volatile HWND dialog_box_; | 92 volatile HWND dialog_box_; |
| 86 | 93 |
| 87 // Function pointer that defaults to PrintDlgEx. It can be changed using | 94 // Function pointer that defaults to PrintDlgEx. It can be changed using |
| 88 // SetPrintDialog() in tests. | 95 // SetPrintDialog() in tests. |
| 89 HRESULT (__stdcall *print_dialog_func_)(LPPRINTDLGEX); | 96 HRESULT (__stdcall *print_dialog_func_)(LPPRINTDLGEX); |
| 90 | 97 |
| 98 // Where to notify when the dialog is closed. |
| 99 PrintSettingsCallback callback_; |
| 100 |
| 101 // Wrapper around native print dialog that runs it on a background thread. |
| 102 scoped_refptr<ui::PrintSettingsDialogWin> print_settings_dialog_; |
| 103 |
| 91 DISALLOW_COPY_AND_ASSIGN(PrintingContextWin); | 104 DISALLOW_COPY_AND_ASSIGN(PrintingContextWin); |
| 92 }; | 105 }; |
| 93 | 106 |
| 94 } // namespace printing | 107 } // namespace printing |
| 95 | 108 |
| 96 #endif // PRINTING_PRINTING_CONTEXT_WIN_H_ | 109 #endif // PRINTING_PRINTING_CONTEXT_WIN_H_ |
| OLD | NEW |