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 23 matching lines...) Expand all Loading... |
34 #include "content/public/browser/render_view_host.h" | 34 #include "content/public/browser/render_view_host.h" |
35 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
36 #include "printing/pdf_metafile_skia.h" | 36 #include "printing/pdf_metafile_skia.h" |
37 #include "printing/printed_document.h" | 37 #include "printing/printed_document.h" |
38 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
39 | 39 |
40 #if defined(ENABLE_PRINT_PREVIEW) | 40 #if defined(ENABLE_PRINT_PREVIEW) |
41 #include "chrome/browser/printing/print_error_dialog.h" | 41 #include "chrome/browser/printing/print_error_dialog.h" |
42 #endif | 42 #endif |
43 | 43 |
| 44 #if defined(OS_WIN) |
| 45 #include "base/command_line.h" |
| 46 #include "chrome/common/chrome_switches.h" |
| 47 #endif |
| 48 |
44 using base::TimeDelta; | 49 using base::TimeDelta; |
45 using content::BrowserThread; | 50 using content::BrowserThread; |
46 | 51 |
47 namespace printing { | 52 namespace printing { |
48 | 53 |
49 namespace { | 54 namespace { |
50 | 55 |
51 void ShowWarningMessageBox(const base::string16& message) { | 56 void ShowWarningMessageBox(const base::string16& message) { |
52 // Runs always on the UI thread. | 57 // Runs always on the UI thread. |
53 static bool is_dialog_shown = false; | 58 static bool is_dialog_shown = false; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 if (metafile_must_be_valid) { | 182 if (metafile_must_be_valid) { |
178 if (!metafile->InitFromData(shared_buf->memory(), params.data_size)) { | 183 if (!metafile->InitFromData(shared_buf->memory(), params.data_size)) { |
179 NOTREACHED() << "Invalid metafile header"; | 184 NOTREACHED() << "Invalid metafile header"; |
180 web_contents()->Stop(); | 185 web_contents()->Stop(); |
181 return; | 186 return; |
182 } | 187 } |
183 } | 188 } |
184 | 189 |
185 #if defined(OS_WIN) | 190 #if defined(OS_WIN) |
186 if (metafile_must_be_valid) { | 191 if (metafile_must_be_valid) { |
| 192 bool print_text_with_gdi = |
| 193 document->settings().print_text_with_gdi() && |
| 194 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 195 switches::kEnableGDITextPrinting); |
187 scoped_refptr<base::RefCountedBytes> bytes = new base::RefCountedBytes( | 196 scoped_refptr<base::RefCountedBytes> bytes = new base::RefCountedBytes( |
188 reinterpret_cast<const unsigned char*>(shared_buf->memory()), | 197 reinterpret_cast<const unsigned char*>(shared_buf->memory()), |
189 params.data_size); | 198 params.data_size); |
190 | 199 |
191 document->DebugDumpData(bytes.get(), FILE_PATH_LITERAL(".pdf")); | 200 document->DebugDumpData(bytes.get(), FILE_PATH_LITERAL(".pdf")); |
192 print_job_->StartPdfToEmfConversion( | 201 print_job_->StartPdfToEmfConversion( |
193 bytes, params.page_size, params.content_area); | 202 bytes, params.page_size, params.content_area, print_text_with_gdi); |
194 } | 203 } |
195 #else | 204 #else |
196 // Update the rendered document. It will send notifications to the listener. | 205 // Update the rendered document. It will send notifications to the listener. |
197 document->SetPage(params.page_number, std::move(metafile), params.page_size, | 206 document->SetPage(params.page_number, std::move(metafile), params.page_size, |
198 params.content_area); | 207 params.content_area); |
199 | 208 |
200 ShouldQuitFromInnerMessageLoop(); | 209 ShouldQuitFromInnerMessageLoop(); |
201 #endif | 210 #endif |
202 } | 211 } |
203 | 212 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 scoped_refptr<PrinterQuery> printer_query; | 531 scoped_refptr<PrinterQuery> printer_query; |
523 printer_query = queue_->PopPrinterQuery(cookie); | 532 printer_query = queue_->PopPrinterQuery(cookie); |
524 if (!printer_query.get()) | 533 if (!printer_query.get()) |
525 return; | 534 return; |
526 BrowserThread::PostTask( | 535 BrowserThread::PostTask( |
527 BrowserThread::IO, FROM_HERE, | 536 BrowserThread::IO, FROM_HERE, |
528 base::Bind(&PrinterQuery::StopWorker, printer_query.get())); | 537 base::Bind(&PrinterQuery::StopWorker, printer_query.get())); |
529 } | 538 } |
530 | 539 |
531 } // namespace printing | 540 } // namespace printing |
OLD | NEW |