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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
28 #include "chrome/grit/generated_resources.h" | 28 #include "chrome/grit/generated_resources.h" |
29 #include "components/prefs/pref_service.h" | 29 #include "components/prefs/pref_service.h" |
30 #include "components/printing/common/print_messages.h" | 30 #include "components/printing/common/print_messages.h" |
31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/browser/notification_details.h" | 32 #include "content/public/browser/notification_details.h" |
33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
34 #include "content/public/browser/notification_source.h" | 34 #include "content/public/browser/notification_source.h" |
35 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
36 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
| 37 #include "printing/features/features.h" |
37 #include "printing/pdf_metafile_skia.h" | 38 #include "printing/pdf_metafile_skia.h" |
38 #include "printing/printed_document.h" | 39 #include "printing/printed_document.h" |
39 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
40 | 41 |
41 #if defined(ENABLE_PRINT_PREVIEW) | 42 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
42 #include "chrome/browser/printing/print_error_dialog.h" | 43 #include "chrome/browser/printing/print_error_dialog.h" |
43 #endif | 44 #endif |
44 | 45 |
45 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
46 #include "base/command_line.h" | 47 #include "base/command_line.h" |
47 #include "chrome/common/chrome_switches.h" | 48 #include "chrome/common/chrome_switches.h" |
48 #endif | 49 #endif |
49 | 50 |
50 using base::TimeDelta; | 51 using base::TimeDelta; |
51 using content::BrowserThread; | 52 using content::BrowserThread; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 profile->GetPrefs(), | 84 profile->GetPrefs(), |
84 base::Bind(&PrintViewManagerBase::UpdateScriptedPrintingBlocked, | 85 base::Bind(&PrintViewManagerBase::UpdateScriptedPrintingBlocked, |
85 base::Unretained(this))); | 86 base::Unretained(this))); |
86 } | 87 } |
87 | 88 |
88 PrintViewManagerBase::~PrintViewManagerBase() { | 89 PrintViewManagerBase::~PrintViewManagerBase() { |
89 ReleasePrinterQuery(); | 90 ReleasePrinterQuery(); |
90 DisconnectFromCurrentPrintJob(); | 91 DisconnectFromCurrentPrintJob(); |
91 } | 92 } |
92 | 93 |
93 #if defined(ENABLE_BASIC_PRINTING) | 94 #if BUILDFLAG(ENABLE_BASIC_PRINTING) |
94 bool PrintViewManagerBase::PrintNow() { | 95 bool PrintViewManagerBase::PrintNow() { |
95 return PrintNowInternal(new PrintMsg_PrintPages(routing_id())); | 96 return PrintNowInternal(new PrintMsg_PrintPages(routing_id())); |
96 } | 97 } |
97 #endif | 98 #endif |
98 | 99 |
99 void PrintViewManagerBase::UpdateScriptedPrintingBlocked() { | 100 void PrintViewManagerBase::UpdateScriptedPrintingBlocked() { |
100 Send(new PrintMsg_SetScriptedPrintingBlocked( | 101 Send(new PrintMsg_SetScriptedPrintingBlocked( |
101 routing_id(), | 102 routing_id(), |
102 !printing_enabled_.GetValue())); | 103 !printing_enabled_.GetValue())); |
103 } | 104 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 document->SetPage(params.page_number, std::move(metafile), params.page_size, | 211 document->SetPage(params.page_number, std::move(metafile), params.page_size, |
211 params.content_area); | 212 params.content_area); |
212 | 213 |
213 ShouldQuitFromInnerMessageLoop(); | 214 ShouldQuitFromInnerMessageLoop(); |
214 #endif | 215 #endif |
215 } | 216 } |
216 | 217 |
217 void PrintViewManagerBase::OnPrintingFailed(int cookie) { | 218 void PrintViewManagerBase::OnPrintingFailed(int cookie) { |
218 PrintManager::OnPrintingFailed(cookie); | 219 PrintManager::OnPrintingFailed(cookie); |
219 | 220 |
220 #if defined(ENABLE_PRINT_PREVIEW) | 221 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
221 chrome::ShowPrintErrorDialog(); | 222 chrome::ShowPrintErrorDialog(); |
222 #endif | 223 #endif |
223 | 224 |
224 ReleasePrinterQuery(); | 225 ReleasePrinterQuery(); |
225 | 226 |
226 content::NotificationService::current()->Notify( | 227 content::NotificationService::current()->Notify( |
227 chrome::NOTIFICATION_PRINT_JOB_RELEASED, | 228 chrome::NOTIFICATION_PRINT_JOB_RELEASED, |
228 content::Source<content::WebContents>(web_contents()), | 229 content::Source<content::WebContents>(web_contents()), |
229 content::NotificationService::NoDetails()); | 230 content::NotificationService::NoDetails()); |
230 } | 231 } |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 scoped_refptr<PrinterQuery> printer_query; | 536 scoped_refptr<PrinterQuery> printer_query; |
536 printer_query = queue_->PopPrinterQuery(cookie); | 537 printer_query = queue_->PopPrinterQuery(cookie); |
537 if (!printer_query.get()) | 538 if (!printer_query.get()) |
538 return; | 539 return; |
539 BrowserThread::PostTask( | 540 BrowserThread::PostTask( |
540 BrowserThread::IO, FROM_HERE, | 541 BrowserThread::IO, FROM_HERE, |
541 base::Bind(&PrinterQuery::StopWorker, printer_query)); | 542 base::Bind(&PrinterQuery::StopWorker, printer_query)); |
542 } | 543 } |
543 | 544 |
544 } // namespace printing | 545 } // namespace printing |
OLD | NEW |