| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 CHROME_BROWSER_UI_LIBGTK2UI_PRINT_DIALOG_GTK2_H_ | |
| 6 #define CHROME_BROWSER_UI_LIBGTK2UI_PRINT_DIALOG_GTK2_H_ | |
| 7 | |
| 8 #include <gtk/gtk.h> | |
| 9 #include <gtk/gtkunixprint.h> | |
| 10 | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/files/file_path.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "base/sequenced_task_runner_helpers.h" | |
| 16 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" | |
| 17 #include "content/public/browser/browser_thread.h" | |
| 18 #include "printing/print_dialog_gtk_interface.h" | |
| 19 #include "printing/printing_context_linux.h" | |
| 20 #include "ui/aura/window_observer.h" | |
| 21 | |
| 22 namespace printing { | |
| 23 class MetafilePlayer; | |
| 24 class PrintSettings; | |
| 25 } | |
| 26 | |
| 27 using printing::PrintingContextLinux; | |
| 28 | |
| 29 // Needs to be freed on the UI thread to clean up its GTK members variables. | |
| 30 class PrintDialogGtk2 | |
| 31 : public printing::PrintDialogGtkInterface, | |
| 32 public base::RefCountedThreadSafe< | |
| 33 PrintDialogGtk2, content::BrowserThread::DeleteOnUIThread>, | |
| 34 public aura::WindowObserver { | |
| 35 public: | |
| 36 // Creates and returns a print dialog. | |
| 37 static printing::PrintDialogGtkInterface* CreatePrintDialog( | |
| 38 PrintingContextLinux* context); | |
| 39 | |
| 40 // printing::PrintDialogGtkInterface implementation. | |
| 41 void UseDefaultSettings() override; | |
| 42 bool UpdateSettings(printing::PrintSettings* settings) override; | |
| 43 void ShowDialog( | |
| 44 gfx::NativeView parent_view, | |
| 45 bool has_selection, | |
| 46 const PrintingContextLinux::PrintSettingsCallback& callback) override; | |
| 47 void PrintDocument(const printing::MetafilePlayer& metafile, | |
| 48 const base::string16& document_name) override; | |
| 49 void AddRefToDialog() override; | |
| 50 void ReleaseDialog() override; | |
| 51 | |
| 52 // Handles print job response. | |
| 53 void OnJobCompleted(GtkPrintJob* print_job, const GError* error); | |
| 54 | |
| 55 private: | |
| 56 friend struct content::BrowserThread::DeleteOnThread< | |
| 57 content::BrowserThread::UI>; | |
| 58 friend class base::DeleteHelper<PrintDialogGtk2>; | |
| 59 | |
| 60 explicit PrintDialogGtk2(PrintingContextLinux* context); | |
| 61 ~PrintDialogGtk2() override; | |
| 62 | |
| 63 // Handles dialog response. | |
| 64 CHROMEGTK_CALLBACK_1(PrintDialogGtk2, void, OnResponse, int); | |
| 65 | |
| 66 // Prints document named |document_name|. | |
| 67 void SendDocumentToPrinter(const base::string16& document_name); | |
| 68 | |
| 69 // Helper function for initializing |context_|'s PrintSettings with a given | |
| 70 // |settings|. | |
| 71 void InitPrintSettings(printing::PrintSettings* settings); | |
| 72 | |
| 73 // aura::WindowObserver implementation. | |
| 74 void OnWindowDestroying(aura::Window* window) override; | |
| 75 | |
| 76 // Printing dialog callback. | |
| 77 PrintingContextLinux::PrintSettingsCallback callback_; | |
| 78 PrintingContextLinux* context_; | |
| 79 | |
| 80 // Print dialog settings. PrintDialogGtk2 owns |dialog_| and holds references | |
| 81 // to the other objects. | |
| 82 GtkWidget* dialog_; | |
| 83 GtkPrintSettings* gtk_settings_; | |
| 84 GtkPageSetup* page_setup_; | |
| 85 GtkPrinter* printer_; | |
| 86 | |
| 87 base::FilePath path_to_pdf_; | |
| 88 | |
| 89 DISALLOW_COPY_AND_ASSIGN(PrintDialogGtk2); | |
| 90 }; | |
| 91 | |
| 92 #endif // CHROME_BROWSER_UI_LIBGTK2UI_PRINT_DIALOG_GTK2_H_ | |
| OLD | NEW |