| 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 CHROME_BROWSER_PRINTING_PRINT_DIALOG_GTK_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_DIALOG_GTK_H_ |
| 6 #define CHROME_BROWSER_PRINTING_PRINT_DIALOG_GTK_H_ | 6 #define CHROME_BROWSER_PRINTING_PRINT_DIALOG_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 #include <gtk/gtkprintunixdialog.h> | 10 #include <gtk/gtkprintunixdialog.h> |
| 11 | 11 |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "content/browser/browser_thread.h" | 15 #include "content/browser/browser_thread.h" |
| 16 #include "printing/native_metafile.h" | |
| 17 #include "printing/print_dialog_gtk_interface.h" | 16 #include "printing/print_dialog_gtk_interface.h" |
| 18 #include "printing/printing_context_cairo.h" | 17 #include "printing/printing_context_cairo.h" |
| 19 #include "ui/base/gtk/gtk_signal.h" | 18 #include "ui/base/gtk/gtk_signal.h" |
| 20 | 19 |
| 21 namespace base { | 20 namespace base { |
| 22 class WaitableEvent; | 21 class WaitableEvent; |
| 23 } | 22 } |
| 24 | 23 |
| 25 using printing::NativeMetafile; | 24 namespace printing { |
| 25 class Metafile; |
| 26 } |
| 27 |
| 26 using printing::PrintingContextCairo; | 28 using printing::PrintingContextCairo; |
| 27 | 29 |
| 28 // Needs to be freed on the UI thread to clean up its GTK members variables. | 30 // Needs to be freed on the UI thread to clean up its GTK members variables. |
| 29 class PrintDialogGtk | 31 class PrintDialogGtk |
| 30 : public printing::PrintDialogGtkInterface, | 32 : public printing::PrintDialogGtkInterface, |
| 31 public base::RefCountedThreadSafe<PrintDialogGtk, | 33 public base::RefCountedThreadSafe<PrintDialogGtk, |
| 32 BrowserThread::DeleteOnUIThread> { | 34 BrowserThread::DeleteOnUIThread> { |
| 33 public: | 35 public: |
| 34 // Creates and returns a print dialog. | 36 // Creates and returns a print dialog. |
| 35 static printing::PrintDialogGtkInterface* CreatePrintDialog( | 37 static printing::PrintDialogGtkInterface* CreatePrintDialog( |
| 36 PrintingContextCairo* context); | 38 PrintingContextCairo* context); |
| 37 | 39 |
| 38 // printing::PrintDialogGtkInterface implementation. | 40 // printing::PrintDialogGtkInterface implementation. |
| 39 virtual void ShowDialog( | 41 virtual void ShowDialog( |
| 40 PrintingContextCairo::PrintSettingsCallback* callback); | 42 PrintingContextCairo::PrintSettingsCallback* callback); |
| 41 virtual void PrintDocument(const NativeMetafile* metafile, | 43 virtual void PrintDocument(const printing::Metafile* metafile, |
| 42 const string16& document_name); | 44 const string16& document_name); |
| 43 virtual void AddRefToDialog(); | 45 virtual void AddRefToDialog(); |
| 44 virtual void ReleaseDialog(); | 46 virtual void ReleaseDialog(); |
| 45 | 47 |
| 46 private: | 48 private: |
| 47 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 49 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
| 48 friend class DeleteTask<PrintDialogGtk>; | 50 friend class DeleteTask<PrintDialogGtk>; |
| 49 | 51 |
| 50 explicit PrintDialogGtk(PrintingContextCairo* context); | 52 explicit PrintDialogGtk(PrintingContextCairo* context); |
| 51 ~PrintDialogGtk(); | 53 ~PrintDialogGtk(); |
| 52 | 54 |
| 53 // Handles dialog response. | 55 // Handles dialog response. |
| 54 CHROMEGTK_CALLBACK_1(PrintDialogGtk, void, OnResponse, int); | 56 CHROMEGTK_CALLBACK_1(PrintDialogGtk, void, OnResponse, int); |
| 55 | 57 |
| 56 // Saves data in |metafile| to disk for document named |document_name|. | 58 // Saves data in |metafile| to disk for document named |document_name|. |
| 57 void SaveDocumentToDisk(const NativeMetafile* metafile, | 59 void SaveDocumentToDisk(const printing::Metafile* metafile, |
| 58 const string16& document_name); | 60 const string16& document_name); |
| 59 | 61 |
| 60 // Prints document named |document_name|. | 62 // Prints document named |document_name|. |
| 61 void SendDocumentToPrinter(const string16& document_name); | 63 void SendDocumentToPrinter(const string16& document_name); |
| 62 | 64 |
| 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); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 79 | 81 |
| 80 // Event to signal when save document finishes. | 82 // Event to signal when save document finishes. |
| 81 scoped_ptr<base::WaitableEvent> save_document_event_; | 83 scoped_ptr<base::WaitableEvent> save_document_event_; |
| 82 | 84 |
| 83 FilePath path_to_pdf_; | 85 FilePath path_to_pdf_; |
| 84 | 86 |
| 85 DISALLOW_COPY_AND_ASSIGN(PrintDialogGtk); | 87 DISALLOW_COPY_AND_ASSIGN(PrintDialogGtk); |
| 86 }; | 88 }; |
| 87 | 89 |
| 88 #endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_GTK_H_ | 90 #endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_GTK_H_ |
| OLD | NEW |