| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_view_manager_base.h" | 5 #include "chrome/browser/printing/print_view_manager_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
| 24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
| 26 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
| 27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 28 #include "printing/pdf_metafile_skia.h" | 28 #include "printing/pdf_metafile_skia.h" |
| 29 #include "printing/printed_document.h" | 29 #include "printing/printed_document.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 31 | 31 |
| 32 #if defined(ENABLE_FULL_PRINTING) | 32 #if defined(ENABLE_PRINT_PREVIEW) |
| 33 #include "chrome/browser/printing/print_error_dialog.h" | 33 #include "chrome/browser/printing/print_error_dialog.h" |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 using base::TimeDelta; | 36 using base::TimeDelta; |
| 37 using content::BrowserThread; | 37 using content::BrowserThread; |
| 38 | 38 |
| 39 namespace printing { | 39 namespace printing { |
| 40 | 40 |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 60 profile->GetPrefs(), | 60 profile->GetPrefs(), |
| 61 base::Bind(&PrintViewManagerBase::UpdateScriptedPrintingBlocked, | 61 base::Bind(&PrintViewManagerBase::UpdateScriptedPrintingBlocked, |
| 62 base::Unretained(this))); | 62 base::Unretained(this))); |
| 63 } | 63 } |
| 64 | 64 |
| 65 PrintViewManagerBase::~PrintViewManagerBase() { | 65 PrintViewManagerBase::~PrintViewManagerBase() { |
| 66 ReleasePrinterQuery(); | 66 ReleasePrinterQuery(); |
| 67 DisconnectFromCurrentPrintJob(); | 67 DisconnectFromCurrentPrintJob(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 #if !defined(DISABLE_BASIC_PRINTING) | 70 #if defined(ENABLE_BASIC_PRINTING) |
| 71 bool PrintViewManagerBase::PrintNow() { | 71 bool PrintViewManagerBase::PrintNow() { |
| 72 return PrintNowInternal(new PrintMsg_PrintPages(routing_id())); | 72 return PrintNowInternal(new PrintMsg_PrintPages(routing_id())); |
| 73 } | 73 } |
| 74 #endif // !DISABLE_BASIC_PRINTING | 74 #endif // ENABLE_BASIC_PRINTING |
| 75 | 75 |
| 76 void PrintViewManagerBase::UpdateScriptedPrintingBlocked() { | 76 void PrintViewManagerBase::UpdateScriptedPrintingBlocked() { |
| 77 Send(new PrintMsg_SetScriptedPrintingBlocked( | 77 Send(new PrintMsg_SetScriptedPrintingBlocked( |
| 78 routing_id(), | 78 routing_id(), |
| 79 !printing_enabled_.GetValue())); | 79 !printing_enabled_.GetValue())); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void PrintViewManagerBase::NavigationStopped() { | 82 void PrintViewManagerBase::NavigationStopped() { |
| 83 // Cancel the current job, wait for the worker to finish. | 83 // Cancel the current job, wait for the worker to finish. |
| 84 TerminatePrintJob(true); | 84 TerminatePrintJob(true); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 176 #endif // !OS_WIN | 176 #endif // !OS_WIN |
| 177 } | 177 } |
| 178 | 178 |
| 179 void PrintViewManagerBase::OnPrintingFailed(int cookie) { | 179 void PrintViewManagerBase::OnPrintingFailed(int cookie) { |
| 180 if (cookie != cookie_) { | 180 if (cookie != cookie_) { |
| 181 NOTREACHED(); | 181 NOTREACHED(); |
| 182 return; | 182 return; |
| 183 } | 183 } |
| 184 | 184 |
| 185 #if defined(ENABLE_FULL_PRINTING) | 185 #if defined(ENABLE_PRINT_PREVIEW) |
| 186 chrome::ShowPrintErrorDialog(); | 186 chrome::ShowPrintErrorDialog(); |
| 187 #endif | 187 #endif |
| 188 | 188 |
| 189 ReleasePrinterQuery(); | 189 ReleasePrinterQuery(); |
| 190 | 190 |
| 191 content::NotificationService::current()->Notify( | 191 content::NotificationService::current()->Notify( |
| 192 chrome::NOTIFICATION_PRINT_JOB_RELEASED, | 192 chrome::NOTIFICATION_PRINT_JOB_RELEASED, |
| 193 content::Source<content::WebContents>(web_contents()), | 193 content::Source<content::WebContents>(web_contents()), |
| 194 content::NotificationService::NoDetails()); | 194 content::NotificationService::NoDetails()); |
| 195 } | 195 } |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 scoped_refptr<printing::PrinterQuery> printer_query; | 515 scoped_refptr<printing::PrinterQuery> printer_query; |
| 516 printer_query = queue_->PopPrinterQuery(cookie); | 516 printer_query = queue_->PopPrinterQuery(cookie); |
| 517 if (!printer_query.get()) | 517 if (!printer_query.get()) |
| 518 return; | 518 return; |
| 519 BrowserThread::PostTask( | 519 BrowserThread::PostTask( |
| 520 BrowserThread::IO, FROM_HERE, | 520 BrowserThread::IO, FROM_HERE, |
| 521 base::Bind(&PrinterQuery::StopWorker, printer_query.get())); | 521 base::Bind(&PrinterQuery::StopWorker, printer_query.get())); |
| 522 } | 522 } |
| 523 | 523 |
| 524 } // namespace printing | 524 } // namespace printing |
| OLD | NEW |