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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if (!metafile->InitFromData(shared_buf->memory(), params.data_size)) { | 175 if (!metafile->InitFromData(shared_buf->memory(), params.data_size)) { |
176 NOTREACHED() << "Invalid metafile header"; | 176 NOTREACHED() << "Invalid metafile header"; |
177 web_contents()->Stop(); | 177 web_contents()->Stop(); |
178 return; | 178 return; |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 #if defined(OS_WIN) | 182 #if defined(OS_WIN) |
183 print_job_->AppendPrintedPage(params.page_number); | 183 print_job_->AppendPrintedPage(params.page_number); |
184 if (metafile_must_be_valid) { | 184 if (metafile_must_be_valid) { |
185 // TODO(thestig): Figure out why rendering text with GDI results in random | |
186 // missing characters for some users. https://crbug.com/658606 | |
187 bool print_text_with_gdi = | |
188 document->settings().print_text_with_gdi() && | |
189 !document->settings().printer_is_xps() && | |
190 base::FeatureList::IsEnabled(features::kGdiTextPrinting); | |
191 scoped_refptr<base::RefCountedBytes> bytes = new base::RefCountedBytes( | 185 scoped_refptr<base::RefCountedBytes> bytes = new base::RefCountedBytes( |
192 reinterpret_cast<const unsigned char*>(shared_buf->memory()), | 186 reinterpret_cast<const unsigned char*>(shared_buf->memory()), |
193 params.data_size); | 187 params.data_size); |
| 188 document->DebugDumpData(bytes.get(), FILE_PATH_LITERAL(".pdf")); |
194 | 189 |
195 document->DebugDumpData(bytes.get(), FILE_PATH_LITERAL(".pdf")); | 190 const auto& settings = document->settings(); |
196 print_job_->StartPdfToEmfConversion( | 191 if ((settings.printer_is_ps2() || settings.printer_is_ps3()) && |
197 bytes, params.page_size, params.content_area, | 192 base::FeatureList::IsEnabled(features::kPostScriptPrinting)) { |
198 print_text_with_gdi); | 193 print_job_->StartPdfToPostScriptConversion(bytes, params.content_area, |
| 194 params.physical_offsets, |
| 195 settings.printer_is_ps2()); |
| 196 } else { |
| 197 // TODO(thestig): Figure out why rendering text with GDI results in random |
| 198 // missing characters for some users. https://crbug.com/658606 |
| 199 // Update : The missing letters seem to have been caused by the same |
| 200 // problem as https://crbug.com/659604 which was resolved. GDI printing |
| 201 // seems to work with the fix for this bug applied. |
| 202 bool print_text_with_gdi = settings.print_text_with_gdi() && |
| 203 !settings.printer_is_xps() && |
| 204 base::FeatureList::IsEnabled( |
| 205 features::kGdiTextPrinting); |
| 206 print_job_->StartPdfToEmfConversion( |
| 207 bytes, params.page_size, params.content_area, print_text_with_gdi); |
| 208 } |
199 } | 209 } |
200 #else | 210 #else |
201 // Update the rendered document. It will send notifications to the listener. | 211 // Update the rendered document. It will send notifications to the listener. |
202 document->SetPage(params.page_number, std::move(metafile), params.page_size, | 212 document->SetPage(params.page_number, |
| 213 std::move(metafile), |
| 214 #if defined(OS_WIN) |
| 215 0.0f /* dummy shrink_factor */, |
| 216 #endif |
| 217 params.page_size, |
203 params.content_area); | 218 params.content_area); |
204 | 219 |
205 ShouldQuitFromInnerMessageLoop(); | 220 ShouldQuitFromInnerMessageLoop(); |
206 #endif | 221 #endif |
207 } | 222 } |
208 | 223 |
209 void PrintViewManagerBase::OnPrintingFailed(int cookie) { | 224 void PrintViewManagerBase::OnPrintingFailed(int cookie) { |
210 PrintManager::OnPrintingFailed(cookie); | 225 PrintManager::OnPrintingFailed(cookie); |
211 | 226 |
212 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) | 227 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 BrowserThread::IO, FROM_HERE, | 577 BrowserThread::IO, FROM_HERE, |
563 base::Bind(&PrinterQuery::StopWorker, printer_query)); | 578 base::Bind(&PrinterQuery::StopWorker, printer_query)); |
564 } | 579 } |
565 | 580 |
566 void PrintViewManagerBase::SendPrintingEnabled(bool enabled, | 581 void PrintViewManagerBase::SendPrintingEnabled(bool enabled, |
567 content::RenderFrameHost* rfh) { | 582 content::RenderFrameHost* rfh) { |
568 rfh->Send(new PrintMsg_SetPrintingEnabled(rfh->GetRoutingID(), enabled)); | 583 rfh->Send(new PrintMsg_SetPrintingEnabled(rfh->GetRoutingID(), enabled)); |
569 } | 584 } |
570 | 585 |
571 } // namespace printing | 586 } // namespace printing |
OLD | NEW |