Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / printing / print_dialog_gtk.h
blob39a014ae54d80dd92a4a3563200258ca46918c00
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_PRINTING_PRINT_DIALOG_GTK_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_DIALOG_GTK_H_
8 #include <gtk/gtk.h>
9 #include <gtk/gtkunixprint.h>
11 #include "base/compiler_specific.h"
12 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/sequenced_task_runner_helpers.h"
15 #include "content/public/browser/browser_thread.h"
16 #include "printing/print_dialog_gtk_interface.h"
17 #include "printing/printing_context_linux.h"
18 #include "ui/base/gtk/gtk_signal.h"
20 namespace printing {
21 class Metafile;
22 class PrintSettings;
25 using printing::PrintingContextLinux;
27 // Needs to be freed on the UI thread to clean up its GTK members variables.
28 class PrintDialogGtk
29 : public printing::PrintDialogGtkInterface,
30 public base::RefCountedThreadSafe<
31 PrintDialogGtk, content::BrowserThread::DeleteOnUIThread> {
32 public:
33 // Creates and returns a print dialog.
34 static printing::PrintDialogGtkInterface* CreatePrintDialog(
35 PrintingContextLinux* context);
37 // printing::PrintDialogGtkInterface implementation.
38 virtual void UseDefaultSettings() OVERRIDE;
39 virtual bool UpdateSettings(printing::PrintSettings* settings) OVERRIDE;
40 virtual void ShowDialog(
41 gfx::NativeView parent_view,
42 bool has_selection,
43 const PrintingContextLinux::PrintSettingsCallback& callback) OVERRIDE;
44 virtual void PrintDocument(const printing::Metafile* metafile,
45 const base::string16& document_name) OVERRIDE;
46 virtual void AddRefToDialog() OVERRIDE;
47 virtual void ReleaseDialog() OVERRIDE;
49 private:
50 friend struct content::BrowserThread::DeleteOnThread<
51 content::BrowserThread::UI>;
52 friend class base::DeleteHelper<PrintDialogGtk>;
54 explicit PrintDialogGtk(PrintingContextLinux* context);
55 virtual ~PrintDialogGtk();
57 // Handles dialog response.
58 CHROMEGTK_CALLBACK_1(PrintDialogGtk, void, OnResponse, int);
60 // Prints document named |document_name|.
61 void SendDocumentToPrinter(const base::string16& document_name);
63 // Handles print job response.
64 static void OnJobCompletedThunk(GtkPrintJob* print_job,
65 gpointer user_data,
66 GError* error);
67 void OnJobCompleted(GtkPrintJob* print_job, GError* error);
69 // Helper function for initializing |context_|'s PrintSettings with a given
70 // |settings|.
71 void InitPrintSettings(printing::PrintSettings* settings);
73 // Printing dialog callback.
74 PrintingContextLinux::PrintSettingsCallback callback_;
75 PrintingContextLinux* context_;
77 // Print dialog settings. PrintDialogGtk owns |dialog_| and holds references
78 // to the other objects.
79 GtkWidget* dialog_;
80 GtkPrintSettings* gtk_settings_;
81 GtkPageSetup* page_setup_;
82 GtkPrinter* printer_;
84 base::FilePath path_to_pdf_;
86 DISALLOW_COPY_AND_ASSIGN(PrintDialogGtk);
89 #endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_GTK_H_