BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / libgtk2ui / print_dialog_gtk2.h
blob162e2f68516dff06325fa84c0275ea1799c75252
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.
5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_PRINT_DIALOG_GTK2_H_
6 #define CHROME_BROWSER_UI_LIBGTK2UI_PRINT_DIALOG_GTK2_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 "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "printing/print_dialog_gtk_interface.h"
18 #include "printing/printing_context_linux.h"
19 #include "ui/aura/window_observer.h"
21 namespace printing {
22 class MetafilePlayer;
23 class PrintSettings;
26 using printing::PrintingContextLinux;
28 // Needs to be freed on the UI thread to clean up its GTK members variables.
29 class PrintDialogGtk2
30 : public printing::PrintDialogGtkInterface,
31 public base::RefCountedThreadSafe<
32 PrintDialogGtk2, content::BrowserThread::DeleteOnUIThread>,
33 public aura::WindowObserver {
34 public:
35 // Creates and returns a print dialog.
36 static printing::PrintDialogGtkInterface* CreatePrintDialog(
37 PrintingContextLinux* context);
39 // printing::PrintDialogGtkInterface implementation.
40 void UseDefaultSettings() override;
41 bool UpdateSettings(printing::PrintSettings* settings) override;
42 void ShowDialog(
43 gfx::NativeView parent_view,
44 bool has_selection,
45 const PrintingContextLinux::PrintSettingsCallback& callback) override;
46 void PrintDocument(const printing::MetafilePlayer& metafile,
47 const base::string16& document_name) override;
48 void AddRefToDialog() override;
49 void ReleaseDialog() override;
51 // Handles print job response.
52 void OnJobCompleted(GtkPrintJob* print_job, const GError* error);
54 private:
55 friend struct content::BrowserThread::DeleteOnThread<
56 content::BrowserThread::UI>;
57 friend class base::DeleteHelper<PrintDialogGtk2>;
59 explicit PrintDialogGtk2(PrintingContextLinux* context);
60 ~PrintDialogGtk2() override;
62 // Handles dialog response.
63 CHROMEGTK_CALLBACK_1(PrintDialogGtk2, void, OnResponse, int);
65 // Prints document named |document_name|.
66 void SendDocumentToPrinter(const base::string16& document_name);
68 // Helper function for initializing |context_|'s PrintSettings with a given
69 // |settings|.
70 void InitPrintSettings(printing::PrintSettings* settings);
72 // aura::WindowObserver implementation.
73 void OnWindowDestroying(aura::Window* window) override;
75 // Printing dialog callback.
76 PrintingContextLinux::PrintSettingsCallback callback_;
77 PrintingContextLinux* context_;
79 // Print dialog settings. PrintDialogGtk2 owns |dialog_| and holds references
80 // to the other objects.
81 GtkWidget* dialog_;
82 GtkPrintSettings* gtk_settings_;
83 GtkPageSetup* page_setup_;
84 GtkPrinter* printer_;
86 base::FilePath path_to_pdf_;
88 DISALLOW_COPY_AND_ASSIGN(PrintDialogGtk2);
91 #endif // CHROME_BROWSER_UI_LIBGTK2UI_PRINT_DIALOG_GTK2_H_