OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "printing/native_metafile_factory.h" | 5 #include "printing/native_metafile_factory.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include "printing/emf_win.h" | 8 #include "printing/emf_win.h" |
9 #elif defined(OS_MACOSX) | 9 #elif defined(OS_MACOSX) |
10 #include "printing/pdf_metafile_mac.h" | 10 #include "printing/pdf_metafile_mac.h" |
11 #elif defined(OS_POSIX) | 11 #elif defined(OS_POSIX) |
12 #include "printing/pdf_ps_metafile_cairo.h" | 12 #include "printing/pdf_ps_metafile_cairo.h" |
13 #endif | 13 #endif |
14 | 14 |
15 namespace printing { | 15 namespace printing { |
16 | 16 |
17 // static | 17 // static |
18 printing::NativeMetafile* NativeMetafileFactory::Create() { | 18 printing::NativeMetafile* NativeMetafileFactory::Create() { |
19 NativeMetafile* metafile; | |
19 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
20 return new printing::Emf; | 21 metafile = new printing::Emf; |
vandebo (ex-Chrome)
2011/03/24 20:11:55
This code is duplicated. You should pull it out i
dpapad
2011/03/24 21:08:14
Done.
| |
21 #elif defined(OS_MACOSX) | 22 #elif defined(OS_MACOSX) |
22 return new printing::PdfMetafile; | 23 metafile = new printing::PdfMetafile; |
23 #elif defined(OS_POSIX) | 24 #elif defined(OS_POSIX) |
24 return new printing::PdfPsMetafile; | 25 metafile = new printing::PdfPsMetafile; |
25 #endif | 26 #endif |
27 if (!metafile->Init()) { | |
28 delete metafile; | |
29 return NULL; | |
30 } | |
31 return metafile; | |
32 } | |
33 | |
34 // static | |
35 printing::NativeMetafile* NativeMetafileFactory::CreateFromData( | |
36 const void* src_buffer, uint32 src_buffer_size) { | |
37 NativeMetafile* metafile; | |
38 #if defined(OS_WIN) | |
39 metafile = new printing::Emf; | |
40 #elif defined(OS_MACOSX) | |
41 metafile = new printing::PdfMetafile; | |
42 #elif defined(OS_POSIX) | |
43 metafile = new printing::PdfPsMetafile; | |
44 #endif | |
45 if (!metafile->InitFromData(src_buffer, src_buffer_size)) { | |
46 delete metafile; | |
47 return NULL; | |
48 } | |
49 return metafile; | |
26 } | 50 } |
27 | 51 |
28 } // namespace printing | 52 } // namespace printing |
OLD | NEW |