| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gtkunixprint.h> | 8 #include <gtk/gtkunixprint.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 AddRef(); | 268 AddRef(); |
| 269 | 269 |
| 270 bool error = false; | 270 bool error = false; |
| 271 if (!file_util::CreateTemporaryFile(&path_to_pdf_)) { | 271 if (!file_util::CreateTemporaryFile(&path_to_pdf_)) { |
| 272 LOG(ERROR) << "Creating temporary file failed"; | 272 LOG(ERROR) << "Creating temporary file failed"; |
| 273 error = true; | 273 error = true; |
| 274 } | 274 } |
| 275 | 275 |
| 276 if (!error && !metafile->SaveTo(path_to_pdf_)) { | 276 if (!error && !metafile->SaveTo(path_to_pdf_)) { |
| 277 LOG(ERROR) << "Saving metafile failed"; | 277 LOG(ERROR) << "Saving metafile failed"; |
| 278 base::Delete(path_to_pdf_, false); | 278 base::DeleteFile(path_to_pdf_, false); |
| 279 error = true; | 279 error = true; |
| 280 } | 280 } |
| 281 | 281 |
| 282 if (error) { | 282 if (error) { |
| 283 // Matches AddRef() above. | 283 // Matches AddRef() above. |
| 284 Release(); | 284 Release(); |
| 285 } else { | 285 } else { |
| 286 // No errors, continue printing. | 286 // No errors, continue printing. |
| 287 BrowserThread::PostTask( | 287 BrowserThread::PostTask( |
| 288 BrowserThread::UI, FROM_HERE, | 288 BrowserThread::UI, FROM_HERE, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 gpointer user_data, | 399 gpointer user_data, |
| 400 GError* error) { | 400 GError* error) { |
| 401 static_cast<PrintDialogGtk*>(user_data)->OnJobCompleted(print_job, error); | 401 static_cast<PrintDialogGtk*>(user_data)->OnJobCompleted(print_job, error); |
| 402 } | 402 } |
| 403 | 403 |
| 404 void PrintDialogGtk::OnJobCompleted(GtkPrintJob* print_job, GError* error) { | 404 void PrintDialogGtk::OnJobCompleted(GtkPrintJob* print_job, GError* error) { |
| 405 if (error) | 405 if (error) |
| 406 LOG(ERROR) << "Printing failed: " << error->message; | 406 LOG(ERROR) << "Printing failed: " << error->message; |
| 407 if (print_job) | 407 if (print_job) |
| 408 g_object_unref(print_job); | 408 g_object_unref(print_job); |
| 409 base::FileUtilProxy::Delete( | 409 base::FileUtilProxy::DeleteFile( |
| 410 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(), | 410 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(), |
| 411 path_to_pdf_, | 411 path_to_pdf_, |
| 412 false, | 412 false, |
| 413 base::FileUtilProxy::StatusCallback()); | 413 base::FileUtilProxy::StatusCallback()); |
| 414 // Printing finished. Matches AddRef() in PrintDocument(); | 414 // Printing finished. Matches AddRef() in PrintDocument(); |
| 415 Release(); | 415 Release(); |
| 416 } | 416 } |
| 417 | 417 |
| 418 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges, | 418 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges, |
| 419 PrintSettings* settings) { | 419 PrintSettings* settings) { |
| 420 printing::PrintSettingsInitializerGtk::InitPrintSettings( | 420 printing::PrintSettingsInitializerGtk::InitPrintSettings( |
| 421 gtk_settings_, page_setup_, page_ranges, false, settings); | 421 gtk_settings_, page_setup_, page_ranges, false, settings); |
| 422 context_->InitWithSettings(*settings); | 422 context_->InitWithSettings(*settings); |
| 423 } | 423 } |
| OLD | NEW |