OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/pdf_metafile_mac.h" | 5 #include "printing/pdf_metafile_mac.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/mac/scoped_cftyperef.h" | 9 #include "base/mac/scoped_cftyperef.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 } | 40 } |
41 context_.reset(CGPDFContextCreate(pdf_consumer, NULL, NULL)); | 41 context_.reset(CGPDFContextCreate(pdf_consumer, NULL, NULL)); |
42 if (!context_.get()) { | 42 if (!context_.get()) { |
43 LOG(ERROR) << "Failed to create pdf context for metafile"; | 43 LOG(ERROR) << "Failed to create pdf context for metafile"; |
44 pdf_data_.reset(NULL); | 44 pdf_data_.reset(NULL); |
45 } | 45 } |
46 | 46 |
47 return true; | 47 return true; |
48 } | 48 } |
49 | 49 |
50 bool PdfMetafile::Init(const void* src_buffer, uint32 src_buffer_size) { | 50 bool PdfMetafile::InitFromData(const void* src_buffer, uint32 src_buffer_size) { |
51 DCHECK(!context_.get()); | 51 DCHECK(!context_.get()); |
52 DCHECK(!pdf_data_.get()); | 52 DCHECK(!pdf_data_.get()); |
53 | 53 |
54 if (!src_buffer || src_buffer_size == 0) { | 54 if (!src_buffer || src_buffer_size == 0) { |
55 return false; | 55 return false; |
56 } | 56 } |
57 | 57 |
58 pdf_data_.reset(CFDataCreateMutable(kCFAllocatorDefault, src_buffer_size)); | 58 pdf_data_.reset(CFDataCreateMutable(kCFAllocatorDefault, src_buffer_size)); |
59 CFDataAppendBytes(pdf_data_, static_cast<const UInt8*>(src_buffer), | 59 CFDataAppendBytes(pdf_data_, static_cast<const UInt8*>(src_buffer), |
60 src_buffer_size); | 60 src_buffer_size); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 if (!pdf_doc_.get()) { | 238 if (!pdf_doc_.get()) { |
239 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider( | 239 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider( |
240 CGDataProviderCreateWithCFData(pdf_data_)); | 240 CGDataProviderCreateWithCFData(pdf_data_)); |
241 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider)); | 241 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider)); |
242 } | 242 } |
243 return pdf_doc_.get(); | 243 return pdf_doc_.get(); |
244 } | 244 } |
245 | 245 |
246 } // namespace printing | 246 } // namespace printing |
OLD | NEW |