| 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 #include "chrome/browser/ui/libgtk2ui/print_dialog_gtk2.h" | 5 #include "chrome/browser/ui/libgtk2ui/print_dialog_gtk2.h" |
| 6 | 6 |
| 7 #include <gtk/gtkunixprint.h> | 7 #include <gtk/gtkunixprint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 16 #include "base/files/file_util_proxy.h" | 16 #include "base/files/file_util_proxy.h" |
| 17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/values.h" | 21 #include "base/values.h" |
| 22 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 22 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" |
| 23 #include "chrome/browser/ui/libgtk2ui/printing_gtk2_util.h" | 23 #include "chrome/browser/ui/libgtk2ui/printing_gtk2_util.h" |
| 24 #include "printing/metafile.h" | 24 #include "printing/metafile.h" |
| 25 #include "printing/print_job_constants.h" | 25 #include "printing/print_job_constants.h" |
| 26 #include "printing/print_settings.h" | 26 #include "printing/print_settings.h" |
| 27 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
| 28 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" | 28 #include "ui/events/platform/x11/x11_event_source.h" |
| 29 | 29 |
| 30 using content::BrowserThread; | 30 using content::BrowserThread; |
| 31 using printing::PageRanges; | 31 using printing::PageRanges; |
| 32 using printing::PrintSettings; | 32 using printing::PrintSettings; |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 #if defined(USE_CUPS) | 36 #if defined(USE_CUPS) |
| 37 // CUPS Duplex attribute and values. | 37 // CUPS Duplex attribute and values. |
| 38 const char kCUPSDuplex[] = "cups-Duplex"; | 38 const char kCUPSDuplex[] = "cups-Duplex"; |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 TRUE); | 359 TRUE); |
| 360 gtk_print_unix_dialog_set_has_selection(GTK_PRINT_UNIX_DIALOG(dialog_), | 360 gtk_print_unix_dialog_set_has_selection(GTK_PRINT_UNIX_DIALOG(dialog_), |
| 361 has_selection); | 361 has_selection); |
| 362 gtk_print_unix_dialog_set_settings(GTK_PRINT_UNIX_DIALOG(dialog_), | 362 gtk_print_unix_dialog_set_settings(GTK_PRINT_UNIX_DIALOG(dialog_), |
| 363 gtk_settings_); | 363 gtk_settings_); |
| 364 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); | 364 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); |
| 365 gtk_widget_show(dialog_); | 365 gtk_widget_show(dialog_); |
| 366 | 366 |
| 367 // We need to call gtk_window_present after making the widgets visible to make | 367 // We need to call gtk_window_present after making the widgets visible to make |
| 368 // sure window gets correctly raised and gets focus. | 368 // sure window gets correctly raised and gets focus. |
| 369 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); | 369 gtk_window_present_with_time( |
| 370 gtk_window_present_with_time(GTK_WINDOW(dialog_), time); | 370 GTK_WINDOW(dialog_), ui::X11EventSource::GetInstance()->GetTimestamp()); |
| 371 } | 371 } |
| 372 | 372 |
| 373 void PrintDialogGtk2::PrintDocument(const printing::MetafilePlayer& metafile, | 373 void PrintDialogGtk2::PrintDocument(const printing::MetafilePlayer& metafile, |
| 374 const base::string16& document_name) { | 374 const base::string16& document_name) { |
| 375 // This runs on the print worker thread, does not block the UI thread. | 375 // This runs on the print worker thread, does not block the UI thread. |
| 376 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 376 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 377 | 377 |
| 378 // The document printing tasks can outlive the PrintingContext that created | 378 // The document printing tasks can outlive the PrintingContext that created |
| 379 // this dialog. | 379 // this dialog. |
| 380 AddRef(); | 380 AddRef(); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) { | 549 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) { |
| 550 DCHECK_EQ(libgtk2ui::GetAuraTransientParent(dialog_), window); | 550 DCHECK_EQ(libgtk2ui::GetAuraTransientParent(dialog_), window); |
| 551 | 551 |
| 552 libgtk2ui::ClearAuraTransientParent(dialog_); | 552 libgtk2ui::ClearAuraTransientParent(dialog_); |
| 553 window->RemoveObserver(this); | 553 window->RemoveObserver(this); |
| 554 if (!callback_.is_null()) { | 554 if (!callback_.is_null()) { |
| 555 callback_.Run(PrintingContextLinux::CANCEL); | 555 callback_.Run(PrintingContextLinux::CANCEL); |
| 556 callback_.Reset(); | 556 callback_.Reset(); |
| 557 } | 557 } |
| 558 } | 558 } |
| OLD | NEW |