OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/printing/print_dialog_gtk.h" | 5 #include "chrome/browser/printing/print_dialog_gtk.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <gtk/gtkpagesetupunixdialog.h> | 8 #include <gtk/gtkpagesetupunixdialog.h> |
9 #include <gtk/gtkprintjob.h> | 9 #include <gtk/gtkprintjob.h> |
10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
11 #include <sys/types.h> | 11 #include <sys/types.h> |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
| 16 #include "base/bind.h" |
16 #include "base/file_util.h" | 17 #include "base/file_util.h" |
17 #include "base/file_util_proxy.h" | |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
21 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
22 #include "printing/metafile.h" | 22 #include "printing/metafile.h" |
23 #include "printing/print_job_constants.h" | 23 #include "printing/print_job_constants.h" |
24 #include "printing/print_settings_initializer_gtk.h" | 24 #include "printing/print_settings_initializer_gtk.h" |
25 | 25 |
26 using printing::PageRanges; | 26 using printing::PageRanges; |
27 using printing::PrintSettings; | 27 using printing::PrintSettings; |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 gpointer user_data, | 393 gpointer user_data, |
394 GError* error) { | 394 GError* error) { |
395 static_cast<PrintDialogGtk*>(user_data)->OnJobCompleted(print_job, error); | 395 static_cast<PrintDialogGtk*>(user_data)->OnJobCompleted(print_job, error); |
396 } | 396 } |
397 | 397 |
398 void PrintDialogGtk::OnJobCompleted(GtkPrintJob* print_job, GError* error) { | 398 void PrintDialogGtk::OnJobCompleted(GtkPrintJob* print_job, GError* error) { |
399 if (error) | 399 if (error) |
400 LOG(ERROR) << "Printing failed: " << error->message; | 400 LOG(ERROR) << "Printing failed: " << error->message; |
401 if (print_job) | 401 if (print_job) |
402 g_object_unref(print_job); | 402 g_object_unref(print_job); |
403 base::FileUtilProxy::Delete( | 403 BrowserThread::PostTask( |
404 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 404 BrowserThread::FILE, |
405 path_to_pdf_, | 405 FROM_HERE, |
406 false, | 406 base::IgnoreReturn(base::Callback<bool(void)>( |
407 NULL); | 407 base::Bind(&file_util::Delete, path_to_pdf_, false)))); |
408 // Printing finished. Matches AddRef() in PrintDocument(); | 408 // Printing finished. Matches AddRef() in PrintDocument(); |
409 Release(); | 409 Release(); |
410 } | 410 } |
411 | 411 |
412 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { | 412 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { |
413 PrintSettings settings; | 413 PrintSettings settings; |
414 printing::PrintSettingsInitializerGtk::InitPrintSettings( | 414 printing::PrintSettingsInitializerGtk::InitPrintSettings( |
415 gtk_settings_, page_setup_, page_ranges, false, &settings); | 415 gtk_settings_, page_setup_, page_ranges, false, &settings); |
416 context_->InitWithSettings(settings); | 416 context_->InitWithSettings(settings); |
417 } | 417 } |
OLD | NEW |