Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: chrome/browser/printing/print_view_manager_base.cc

Issue 516833002: Removed NativeMetafile and PreviewMetafile typedef as it's always PdfMetafileSkia. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_pdf
Patch Set: Thu Aug 28 02:43:23 PDT 2014 Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/printing/print_job.h" 14 #include "chrome/browser/printing/print_job.h"
15 #include "chrome/browser/printing/print_job_manager.h" 15 #include "chrome/browser/printing/print_job_manager.h"
16 #include "chrome/browser/printing/printer_query.h" 16 #include "chrome/browser/printing/printer_query.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/simple_message_box.h" 18 #include "chrome/browser/ui/simple_message_box.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/common/print_messages.h" 20 #include "chrome/common/print_messages.h"
21 #include "chrome/grit/generated_resources.h" 21 #include "chrome/grit/generated_resources.h"
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/metafile_impl.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_FULL_PRINTING)
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 #if defined(WIN_PDF_METAFILE_FOR_PRINTING) 36 #if defined(WIN_PDF_METAFILE_FOR_PRINTING)
37 #include "base/memory/ref_counted.h" 37 #include "base/memory/ref_counted.h"
38 #include "base/memory/ref_counted_memory.h" 38 #include "base/memory/ref_counted_memory.h"
39 #include "chrome/browser/printing/pdf_to_emf_converter.h" 39 #include "chrome/browser/printing/pdf_to_emf_converter.h"
40 #include "printing/emf_win.h"
40 #include "printing/pdf_render_settings.h" 41 #include "printing/pdf_render_settings.h"
41 #endif 42 #endif
42 43
43 using base::TimeDelta; 44 using base::TimeDelta;
44 using content::BrowserThread; 45 using content::BrowserThread;
45 46
46 namespace printing { 47 namespace printing {
47 48
48 namespace { 49 namespace {
49 50
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 183
183 base::SharedMemory shared_buf(params.metafile_data_handle, true); 184 base::SharedMemory shared_buf(params.metafile_data_handle, true);
184 if (metafile_must_be_valid) { 185 if (metafile_must_be_valid) {
185 if (!shared_buf.Map(params.data_size)) { 186 if (!shared_buf.Map(params.data_size)) {
186 NOTREACHED() << "couldn't map"; 187 NOTREACHED() << "couldn't map";
187 web_contents()->Stop(); 188 web_contents()->Stop();
188 return; 189 return;
189 } 190 }
190 } 191 }
191 192
192 scoped_ptr<NativeMetafile> metafile(new NativeMetafile); 193 scoped_ptr<PdfMetafileSkia> metafile(new PdfMetafileSkia);
193 if (metafile_must_be_valid) { 194 if (metafile_must_be_valid) {
194 if (!metafile->InitFromData(shared_buf.memory(), params.data_size)) { 195 if (!metafile->InitFromData(shared_buf.memory(), params.data_size)) {
195 NOTREACHED() << "Invalid metafile header"; 196 NOTREACHED() << "Invalid metafile header";
196 web_contents()->Stop(); 197 web_contents()->Stop();
197 return; 198 return;
198 } 199 }
199 } 200 }
200 201
201 #if defined(OS_WIN) && !defined(WIN_PDF_METAFILE_FOR_PRINTING) 202 #if defined(OS_WIN) && !defined(WIN_PDF_METAFILE_FOR_PRINTING)
202 bool big_emf = (params.data_size && params.data_size >= kMetafileMaxSize); 203 bool big_emf = (params.data_size && params.data_size >= kMetafileMaxSize);
203 int raster_size = 204 int raster_size =
204 std::min(params.page_size.GetArea(), kMaxRasterSizeInPixels); 205 std::min(params.page_size.GetArea(), kMaxRasterSizeInPixels);
205 if (big_emf) { 206 if (big_emf) {
206 scoped_ptr<NativeMetafile> raster_metafile( 207 scoped_ptr<PdfMetafileSkia> raster_metafile(
Lei Zhang 2014/08/28 18:11:23 Shouldn't this be Emf?
Vitaly Buka (NO REVIEWS) 2014/08/28 18:28:48 It would go away with WIN_PDF_METAFILE_FOR_PRINTIN
Vitaly Buka (NO REVIEWS) 2014/08/28 20:18:46 Done.
207 metafile->RasterizeMetafile(raster_size)); 208 metafile->RasterizeMetafile(raster_size));
208 if (raster_metafile.get()) { 209 if (raster_metafile.get()) {
209 metafile.swap(raster_metafile); 210 metafile.swap(raster_metafile);
210 } else if (big_emf) { 211 } else if (big_emf) {
211 // Don't fall back to emf here. 212 // Don't fall back to emf here.
212 NOTREACHED() << "size:" << params.data_size; 213 NOTREACHED() << "size:" << params.data_size;
213 TerminatePrintJob(true); 214 TerminatePrintJob(true);
214 web_contents()->Stop(); 215 web_contents()->Stop();
215 return; 216 return;
216 } 217 }
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 scoped_refptr<printing::PrinterQuery> printer_query; 593 scoped_refptr<printing::PrinterQuery> printer_query;
593 printer_query = queue_->PopPrinterQuery(cookie); 594 printer_query = queue_->PopPrinterQuery(cookie);
594 if (!printer_query.get()) 595 if (!printer_query.get())
595 return; 596 return;
596 BrowserThread::PostTask( 597 BrowserThread::PostTask(
597 BrowserThread::IO, FROM_HERE, 598 BrowserThread::IO, FROM_HERE,
598 base::Bind(&PrinterQuery::StopWorker, printer_query.get())); 599 base::Bind(&PrinterQuery::StopWorker, printer_query.get()));
599 } 600 }
600 601
601 } // namespace printing 602 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698