| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_cg_mac.h" | 5 #include "printing/pdf_metafile_cg_mac.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 uint32 data_size = GetDataSize(); | 279 uint32 data_size = GetDataSize(); |
| 280 if (dst_buffer_size > data_size) { | 280 if (dst_buffer_size > data_size) { |
| 281 return false; | 281 return false; |
| 282 } | 282 } |
| 283 | 283 |
| 284 CFDataGetBytes(pdf_data_, CFRangeMake(0, dst_buffer_size), | 284 CFDataGetBytes(pdf_data_, CFRangeMake(0, dst_buffer_size), |
| 285 static_cast<UInt8*>(dst_buffer)); | 285 static_cast<UInt8*>(dst_buffer)); |
| 286 return true; | 286 return true; |
| 287 } | 287 } |
| 288 | 288 |
| 289 bool PdfMetafileCg::SaveTo(const FilePath& file_path) const { | 289 bool PdfMetafileCg::SaveTo(const base::FilePath& file_path) const { |
| 290 DCHECK(pdf_data_.get()); | 290 DCHECK(pdf_data_.get()); |
| 291 DCHECK(!context_.get()); | 291 DCHECK(!context_.get()); |
| 292 | 292 |
| 293 std::string path_string = file_path.value(); | 293 std::string path_string = file_path.value(); |
| 294 ScopedCFTypeRef<CFURLRef> path_url(CFURLCreateFromFileSystemRepresentation( | 294 ScopedCFTypeRef<CFURLRef> path_url(CFURLCreateFromFileSystemRepresentation( |
| 295 kCFAllocatorDefault, reinterpret_cast<const UInt8*>(path_string.c_str()), | 295 kCFAllocatorDefault, reinterpret_cast<const UInt8*>(path_string.c_str()), |
| 296 path_string.length(), false)); | 296 path_string.length(), false)); |
| 297 SInt32 error_code; | 297 SInt32 error_code; |
| 298 CFURLWriteDataAndPropertiesToResource(path_url, pdf_data_, NULL, &error_code); | 298 CFURLWriteDataAndPropertiesToResource(path_url, pdf_data_, NULL, &error_code); |
| 299 return error_code == 0; | 299 return error_code == 0; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 310 | 310 |
| 311 if (!pdf_doc_.get()) { | 311 if (!pdf_doc_.get()) { |
| 312 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider( | 312 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider( |
| 313 CGDataProviderCreateWithCFData(pdf_data_)); | 313 CGDataProviderCreateWithCFData(pdf_data_)); |
| 314 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider)); | 314 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider)); |
| 315 } | 315 } |
| 316 return pdf_doc_.get(); | 316 return pdf_doc_.get(); |
| 317 } | 317 } |
| 318 | 318 |
| 319 } // namespace printing | 319 } // namespace printing |
| OLD | NEW |