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> |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 if (!success) { | 395 if (!success) { |
396 LOG(ERROR) << "Saving metafile failed"; | 396 LOG(ERROR) << "Saving metafile failed"; |
397 // Matches AddRef() above. | 397 // Matches AddRef() above. |
398 Release(); | 398 Release(); |
399 return; | 399 return; |
400 } | 400 } |
401 | 401 |
402 // No errors, continue printing. | 402 // No errors, continue printing. |
403 BrowserThread::PostTask( | 403 BrowserThread::PostTask( |
404 BrowserThread::UI, FROM_HERE, | 404 BrowserThread::UI, FROM_HERE, |
405 base::Bind(&PrintDialogGtk2::SendDocumentToPrinter, this, document_name)); | 405 base::BindOnce(&PrintDialogGtk2::SendDocumentToPrinter, this, |
| 406 document_name)); |
406 } | 407 } |
407 | 408 |
408 void PrintDialogGtk2::AddRefToDialog() { | 409 void PrintDialogGtk2::AddRefToDialog() { |
409 AddRef(); | 410 AddRef(); |
410 } | 411 } |
411 | 412 |
412 void PrintDialogGtk2::ReleaseDialog() { | 413 void PrintDialogGtk2::ReleaseDialog() { |
413 Release(); | 414 Release(); |
414 } | 415 } |
415 | 416 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 nullptr); | 523 nullptr); |
523 gtk_print_job_send(print_job, OnJobCompletedThunk, this, nullptr); | 524 gtk_print_job_send(print_job, OnJobCompletedThunk, this, nullptr); |
524 } | 525 } |
525 | 526 |
526 void PrintDialogGtk2::OnJobCompleted(GtkPrintJob* print_job, | 527 void PrintDialogGtk2::OnJobCompleted(GtkPrintJob* print_job, |
527 const GError* error) { | 528 const GError* error) { |
528 if (error) | 529 if (error) |
529 LOG(ERROR) << "Printing failed: " << error->message; | 530 LOG(ERROR) << "Printing failed: " << error->message; |
530 if (print_job) | 531 if (print_job) |
531 g_object_unref(print_job); | 532 g_object_unref(print_job); |
532 BrowserThread::PostTask( | 533 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
533 BrowserThread::FILE, FROM_HERE, | 534 base::BindOnce(base::IgnoreResult(&base::DeleteFile), |
534 base::Bind(base::IgnoreResult(&base::DeleteFile), path_to_pdf_, false)); | 535 path_to_pdf_, false)); |
535 // Printing finished. Matches AddRef() in PrintDocument(); | 536 // Printing finished. Matches AddRef() in PrintDocument(); |
536 Release(); | 537 Release(); |
537 } | 538 } |
538 | 539 |
539 void PrintDialogGtk2::InitPrintSettings(PrintSettings* settings) { | 540 void PrintDialogGtk2::InitPrintSettings(PrintSettings* settings) { |
540 InitPrintSettingsGtk(gtk_settings_, page_setup_, settings); | 541 InitPrintSettingsGtk(gtk_settings_, page_setup_, settings); |
541 context_->InitWithSettings(*settings); | 542 context_->InitWithSettings(*settings); |
542 } | 543 } |
543 | 544 |
544 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) { | 545 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) { |
545 DCHECK_EQ(libgtkui::GetAuraTransientParent(dialog_), window); | 546 DCHECK_EQ(libgtkui::GetAuraTransientParent(dialog_), window); |
546 | 547 |
547 libgtkui::ClearAuraTransientParent(dialog_); | 548 libgtkui::ClearAuraTransientParent(dialog_); |
548 window->RemoveObserver(this); | 549 window->RemoveObserver(this); |
549 if (!callback_.is_null()) { | 550 if (!callback_.is_null()) { |
550 callback_.Run(PrintingContextLinux::CANCEL); | 551 callback_.Run(PrintingContextLinux::CANCEL); |
551 callback_.Reset(); | 552 callback_.Reset(); |
552 } | 553 } |
553 } | 554 } |
OLD | NEW |