Chromium Code Reviews| Index: chrome/browser/printing/print_dialog_gtk.h |
| =================================================================== |
| --- chrome/browser/printing/print_dialog_gtk.h (revision 74844) |
| +++ chrome/browser/printing/print_dialog_gtk.h (working copy) |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| @@ -7,41 +7,75 @@ |
| #pragma once |
| #include <gtk/gtk.h> |
| +#include <gtk/gtkprintunixdialog.h> |
| -#include "base/basictypes.h" |
| #include "base/file_path.h" |
| +#include "base/ref_counted.h" |
| +#include "printing/native_metafile.h" |
| +#include "printing/printing_context_cairo.h" |
| #include "ui/base/gtk/gtk_signal.h" |
| -class Browser; |
| +namespace base { |
| +class WaitableEvent; |
| +} |
| -typedef struct _GtkPrintJob GtkPrintJob; |
| +using printing::NativeMetafile; |
| +using printing::PrintingContextCairo; |
| -// Currently this dialog only allows the user to choose a printer. |
| -class PrintDialogGtk { |
| +class PrintDialogGtk : public base::RefCountedThreadSafe<PrintDialogGtk> { |
| public: |
| - static bool DialogShowing(); |
| + // Creates and returns a print dialog. The dialog will initialize the settings |
| + // for |context| and call |callback| to inform the print workflow of the |
| + // dialog results. |
| + static void* CreatePrintDialog( |
|
Marc-Antoine Ruel (Google)
2011/02/15 14:18:23
nit: It doesn't need to be public?
Lei Zhang
2011/02/15 21:20:11
It does. I put it under private: and chrome/browse
|
| + PrintingContextCairo::PrintSettingsCallback* callback, |
| + PrintingContextCairo* context); |
| - // Called on the IO thread. |
| - static void CreatePrintDialogForPdf(const FilePath& path); |
| + // Prints a document named |document_name| based on the settings in |
| + // |print_dialog|, with data from |metafile|. |
| + // Called from the print worker thread. |
| + static void PrintDocument(void* print_dialog, |
| + const NativeMetafile* metafile, |
| + const string16& document_name); |
| private: |
| - explicit PrintDialogGtk(const FilePath& path_to_pdf); |
| + friend class base::RefCountedThreadSafe<PrintDialogGtk>; |
| + |
| + PrintDialogGtk(PrintingContextCairo::PrintSettingsCallback* callback, |
| + PrintingContextCairo* context); |
| ~PrintDialogGtk(); |
| - static void CreateDialogImpl(const FilePath& path); |
| - |
| + // Handles dialog response. |
| CHROMEGTK_CALLBACK_1(PrintDialogGtk, void, OnResponse, gint); |
| + // Saves data in |metafile| to disk for document named |document_name|. |
| + void SaveDocumentToDisk(const NativeMetafile* metafile, |
| + const string16& document_name); |
| + |
| + // Prints document named |document_name|. |
| + void SendDocumentToPrinter(const string16& document_name); |
| + |
| + // Handles print job response. |
| static void OnJobCompletedThunk(GtkPrintJob* print_job, |
| gpointer user_data, |
| GError* error); |
| - void OnJobCompleted(GtkPrintJob* job, GError* error); |
| + void OnJobCompleted(GtkPrintJob* print_job, GError* error); |
| - FilePath path_to_pdf_; |
| + void set_save_document_event(base::WaitableEvent* event); |
| + // Printing dialog callback. |
| + PrintingContextCairo::PrintSettingsCallback* callback_; |
| + PrintingContextCairo* context_; |
| + |
| + // Print dialog settings. |
| GtkWidget* dialog_; |
| + GtkPageSetup* page_setup_; |
| + GtkPrinter* printer_; |
| + GtkPrintSettings* gtk_settings_; |
| - Browser* browser_; |
| + // Event to signal when save document finishes. |
| + base::WaitableEvent* save_document_event_; |
| + FilePath path_to_pdf_; |
| DISALLOW_COPY_AND_ASSIGN(PrintDialogGtk); |
| }; |