| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 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 #include "ui/shell_dialogs/print_settings_dialog_win.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/threading/thread.h" |
| 9 |
| 10 #if defined(USE_AURA) |
| 11 #include "ui/aura/root_window.h" |
| 12 #endif |
| 13 |
| 14 namespace ui { |
| 15 |
| 16 PrintSettingsDialogWin::PrintSettingsDialogWin( |
| 17 PrintSettingsDialogWin::Listener* listener) |
| 18 : listener_(listener) { |
| 19 } |
| 20 |
| 21 void PrintSettingsDialogWin::GetPrintSettings(PrintDialogFunc print_dialog_func, |
| 22 HWND owning_window, |
| 23 PRINTDLGEX* dialog_options) { |
| 24 DCHECK(listener_); |
| 25 |
| 26 ExecutePrintSettingsParams execute_params(BeginRun(owning_window), |
| 27 owning_window, |
| 28 print_dialog_func, |
| 29 dialog_options); |
| 30 execute_params.run_state.dialog_thread->message_loop()->PostTask( |
| 31 FROM_HERE, |
| 32 base::Bind( |
| 33 &PrintSettingsDialogWin::ExecutePrintSettings, this, execute_params)); |
| 34 } |
| 35 |
| 36 void PrintSettingsDialogWin::ExecutePrintSettings( |
| 37 const ExecutePrintSettingsParams& params) { |
| 38 HRESULT hr = (*params.print_dialog_func)(params.dialog_options); |
| 39 params.ui_proxy->PostTask( |
| 40 FROM_HERE, |
| 41 base::Bind( |
| 42 &PrintSettingsDialogWin::PrintSettingsCompleted, this, hr, params)); |
| 43 } |
| 44 |
| 45 void PrintSettingsDialogWin::PrintSettingsCompleted( |
| 46 HRESULT hresult, |
| 47 const ExecutePrintSettingsParams& params) { |
| 48 EndRun(params.run_state); |
| 49 if (hresult != S_OK) |
| 50 listener_->PrintSettingsCancelled(params.dialog_options); |
| 51 else |
| 52 listener_->PrintSettingsConfirmed(params.dialog_options); |
| 53 } |
| 54 |
| 55 } // namespace ui |
| OLD | NEW |