| 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/libgtkui/print_dialog_gtk.h" | 5 #include "chrome/browser/ui/libgtkui/print_dialog_gtk.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" | |
| 17 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 18 #include "base/logging.h" | 17 #include "base/logging.h" |
| 19 #include "base/macros.h" | 18 #include "base/macros.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/values.h" | 20 #include "base/values.h" |
| 22 #include "chrome/browser/ui/libgtkui/gtk_util.h" | 21 #include "chrome/browser/ui/libgtkui/gtk_util.h" |
| 23 #include "chrome/browser/ui/libgtkui/printing_gtk_util.h" | 22 #include "chrome/browser/ui/libgtkui/printing_gtk_util.h" |
| 24 #include "printing/metafile.h" | 23 #include "printing/metafile.h" |
| 25 #include "printing/print_job_constants.h" | 24 #include "printing/print_job_constants.h" |
| 26 #include "printing/print_settings.h" | 25 #include "printing/print_settings.h" |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 gtk_print_job_set_source_file(print_job, path_to_pdf_.value().c_str(), NULL); | 521 gtk_print_job_set_source_file(print_job, path_to_pdf_.value().c_str(), NULL); |
| 523 gtk_print_job_send(print_job, OnJobCompletedThunk, this, NULL); | 522 gtk_print_job_send(print_job, OnJobCompletedThunk, this, NULL); |
| 524 } | 523 } |
| 525 | 524 |
| 526 void PrintDialogGtk2::OnJobCompleted(GtkPrintJob* print_job, | 525 void PrintDialogGtk2::OnJobCompleted(GtkPrintJob* print_job, |
| 527 const GError* error) { | 526 const GError* error) { |
| 528 if (error) | 527 if (error) |
| 529 LOG(ERROR) << "Printing failed: " << error->message; | 528 LOG(ERROR) << "Printing failed: " << error->message; |
| 530 if (print_job) | 529 if (print_job) |
| 531 g_object_unref(print_job); | 530 g_object_unref(print_job); |
| 532 base::FileUtilProxy::DeleteFile( | 531 BrowserThread::PostTask( |
| 533 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get(), | 532 BrowserThread::FILE, FROM_HERE, |
| 534 path_to_pdf_, false, base::FileUtilProxy::StatusCallback()); | 533 base::Bind(base::IgnoreResult(&base::DeleteFile), path_to_pdf_, false)); |
| 535 // Printing finished. Matches AddRef() in PrintDocument(); | 534 // Printing finished. Matches AddRef() in PrintDocument(); |
| 536 Release(); | 535 Release(); |
| 537 } | 536 } |
| 538 | 537 |
| 539 void PrintDialogGtk2::InitPrintSettings(PrintSettings* settings) { | 538 void PrintDialogGtk2::InitPrintSettings(PrintSettings* settings) { |
| 540 InitPrintSettingsGtk(gtk_settings_, page_setup_, settings); | 539 InitPrintSettingsGtk(gtk_settings_, page_setup_, settings); |
| 541 context_->InitWithSettings(*settings); | 540 context_->InitWithSettings(*settings); |
| 542 } | 541 } |
| 543 | 542 |
| 544 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) { | 543 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) { |
| 545 DCHECK_EQ(libgtkui::GetAuraTransientParent(dialog_), window); | 544 DCHECK_EQ(libgtkui::GetAuraTransientParent(dialog_), window); |
| 546 | 545 |
| 547 libgtkui::ClearAuraTransientParent(dialog_); | 546 libgtkui::ClearAuraTransientParent(dialog_); |
| 548 window->RemoveObserver(this); | 547 window->RemoveObserver(this); |
| 549 if (!callback_.is_null()) { | 548 if (!callback_.is_null()) { |
| 550 callback_.Run(PrintingContextLinux::CANCEL); | 549 callback_.Run(PrintingContextLinux::CANCEL); |
| 551 callback_.Reset(); | 550 callback_.Reset(); |
| 552 } | 551 } |
| 553 } | 552 } |
| OLD | NEW |