| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_UI_LIBGTK2UI_PRINT_DIALOG_GTK2_H_ | 5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_PRINT_DIALOG_GTK2_H_ |
| 6 #define CHROME_BROWSER_UI_LIBGTK2UI_PRINT_DIALOG_GTK2_H_ | 6 #define CHROME_BROWSER_UI_LIBGTK2UI_PRINT_DIALOG_GTK2_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #include <gtk/gtkunixprint.h> | 9 #include <gtk/gtkunixprint.h> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/sequenced_task_runner_helpers.h" | 14 #include "base/sequenced_task_runner_helpers.h" |
| 15 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" | 15 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "printing/print_dialog_gtk_interface.h" | 17 #include "printing/print_dialog_gtk_interface.h" |
| 18 #include "printing/printing_context_linux.h" | 18 #include "printing/printing_context_linux.h" |
| 19 #include "ui/aura/window_observer.h" |
| 19 | 20 |
| 20 namespace printing { | 21 namespace printing { |
| 21 class Metafile; | 22 class Metafile; |
| 22 class PrintSettings; | 23 class PrintSettings; |
| 23 } | 24 } |
| 24 | 25 |
| 25 using printing::PrintingContextLinux; | 26 using printing::PrintingContextLinux; |
| 26 | 27 |
| 27 // Needs to be freed on the UI thread to clean up its GTK members variables. | 28 // Needs to be freed on the UI thread to clean up its GTK members variables. |
| 28 class PrintDialogGtk2 | 29 class PrintDialogGtk2 |
| 29 : public printing::PrintDialogGtkInterface, | 30 : public printing::PrintDialogGtkInterface, |
| 30 public base::RefCountedThreadSafe< | 31 public base::RefCountedThreadSafe< |
| 31 PrintDialogGtk2, content::BrowserThread::DeleteOnUIThread> { | 32 PrintDialogGtk2, content::BrowserThread::DeleteOnUIThread>, |
| 33 public aura::WindowObserver { |
| 32 public: | 34 public: |
| 33 // Creates and returns a print dialog. | 35 // Creates and returns a print dialog. |
| 34 static printing::PrintDialogGtkInterface* CreatePrintDialog( | 36 static printing::PrintDialogGtkInterface* CreatePrintDialog( |
| 35 PrintingContextLinux* context); | 37 PrintingContextLinux* context); |
| 36 | 38 |
| 37 // printing::PrintDialogGtkInterface implementation. | 39 // printing::PrintDialogGtkInterface implementation. |
| 38 virtual void UseDefaultSettings() OVERRIDE; | 40 virtual void UseDefaultSettings() OVERRIDE; |
| 39 virtual bool UpdateSettings(printing::PrintSettings* settings) OVERRIDE; | 41 virtual bool UpdateSettings(printing::PrintSettings* settings) OVERRIDE; |
| 40 virtual void ShowDialog( | 42 virtual void ShowDialog( |
| 41 gfx::NativeView parent_view, | 43 gfx::NativeView parent_view, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 63 // Handles print job response. | 65 // Handles print job response. |
| 64 static void OnJobCompletedThunk(GtkPrintJob* print_job, | 66 static void OnJobCompletedThunk(GtkPrintJob* print_job, |
| 65 gpointer user_data, | 67 gpointer user_data, |
| 66 GError* error); | 68 GError* error); |
| 67 void OnJobCompleted(GtkPrintJob* print_job, GError* error); | 69 void OnJobCompleted(GtkPrintJob* print_job, GError* error); |
| 68 | 70 |
| 69 // Helper function for initializing |context_|'s PrintSettings with a given | 71 // Helper function for initializing |context_|'s PrintSettings with a given |
| 70 // |settings|. | 72 // |settings|. |
| 71 void InitPrintSettings(printing::PrintSettings* settings); | 73 void InitPrintSettings(printing::PrintSettings* settings); |
| 72 | 74 |
| 75 // aura::WindowObserver implementation. |
| 76 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
| 77 |
| 73 // Printing dialog callback. | 78 // Printing dialog callback. |
| 74 PrintingContextLinux::PrintSettingsCallback callback_; | 79 PrintingContextLinux::PrintSettingsCallback callback_; |
| 75 PrintingContextLinux* context_; | 80 PrintingContextLinux* context_; |
| 76 | 81 |
| 77 // Print dialog settings. PrintDialogGtk2 owns |dialog_| and holds references | 82 // Print dialog settings. PrintDialogGtk2 owns |dialog_| and holds references |
| 78 // to the other objects. | 83 // to the other objects. |
| 79 GtkWidget* dialog_; | 84 GtkWidget* dialog_; |
| 80 GtkPrintSettings* gtk_settings_; | 85 GtkPrintSettings* gtk_settings_; |
| 81 GtkPageSetup* page_setup_; | 86 GtkPageSetup* page_setup_; |
| 82 GtkPrinter* printer_; | 87 GtkPrinter* printer_; |
| 83 | 88 |
| 84 base::FilePath path_to_pdf_; | 89 base::FilePath path_to_pdf_; |
| 85 | 90 |
| 86 DISALLOW_COPY_AND_ASSIGN(PrintDialogGtk2); | 91 DISALLOW_COPY_AND_ASSIGN(PrintDialogGtk2); |
| 87 }; | 92 }; |
| 88 | 93 |
| 89 #endif // CHROME_BROWSER_UI_LIBGTK2UI_PRINT_DIALOG_GTK2_H_ | 94 #endif // CHROME_BROWSER_UI_LIBGTK2UI_PRINT_DIALOG_GTK2_H_ |
| OLD | NEW |