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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 document->SetPage(params.page_number, std::move(metafile), params.page_size, | 209 document->SetPage(params.page_number, std::move(metafile), params.page_size, |
209 params.content_area); | 210 params.content_area); |
210 | 211 |
211 ShouldQuitFromInnerMessageLoop(); | 212 ShouldQuitFromInnerMessageLoop(); |
212 #endif | 213 #endif |
213 } | 214 } |
214 | 215 |
215 void PrintViewManagerBase::OnPrintingFailed(int cookie) { | 216 void PrintViewManagerBase::OnPrintingFailed(int cookie) { |
216 PrintManager::OnPrintingFailed(cookie); | 217 PrintManager::OnPrintingFailed(cookie); |
217 | 218 |
218 #if defined(ENABLE_PRINT_PREVIEW) | 219 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
219 chrome::ShowPrintErrorDialog(); | 220 chrome::ShowPrintErrorDialog(); |
220 #endif | 221 #endif |
221 | 222 |
222 ReleasePrinterQuery(); | 223 ReleasePrinterQuery(); |
223 | 224 |
224 content::NotificationService::current()->Notify( | 225 content::NotificationService::current()->Notify( |
225 chrome::NOTIFICATION_PRINT_JOB_RELEASED, | 226 chrome::NOTIFICATION_PRINT_JOB_RELEASED, |
226 content::Source<content::WebContents>(web_contents()), | 227 content::Source<content::WebContents>(web_contents()), |
227 content::NotificationService::NoDetails()); | 228 content::NotificationService::NoDetails()); |
228 } | 229 } |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 scoped_refptr<PrinterQuery> printer_query; | 534 scoped_refptr<PrinterQuery> printer_query; |
534 printer_query = queue_->PopPrinterQuery(cookie); | 535 printer_query = queue_->PopPrinterQuery(cookie); |
535 if (!printer_query.get()) | 536 if (!printer_query.get()) |
536 return; | 537 return; |
537 BrowserThread::PostTask( | 538 BrowserThread::PostTask( |
538 BrowserThread::IO, FROM_HERE, | 539 BrowserThread::IO, FROM_HERE, |
539 base::Bind(&PrinterQuery::StopWorker, printer_query)); | 540 base::Bind(&PrinterQuery::StopWorker, printer_query)); |
540 } | 541 } |
541 | 542 |
542 } // namespace printing | 543 } // namespace printing |
OLD | NEW |