Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ppapi/cpp/private/flash_font_file.h" | |
| 6 | |
| 7 #include "ppapi/c/dev/ppb_font_dev.h" | |
| 8 #include "ppapi/c/private/ppb_flash_font_file.h" | |
| 9 #include "ppapi/c/private/ppb_pdf.h" | |
| 10 #include "ppapi/cpp/instance_handle.h" | |
| 11 #include "ppapi/cpp/module_impl.h" | |
| 12 | |
| 13 namespace pp { | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 // TODO(yzshen): Once PPB_Flash_FontFile gets to the stable channel, we can | |
| 18 // remove the code of using PPB_PDF in this file. | |
| 19 template <> const char* interface_name<PPB_PDF>() { | |
|
brettw
2012/10/08 22:44:45
I think we usually skip the space after "template"
yzshen1
2012/10/08 23:09:07
I think we have this space for files in ppapi/cpp.
| |
| 20 return PPB_PDF_INTERFACE; | |
| 21 } | |
| 22 | |
| 23 template <> const char* interface_name<PPB_Flash_FontFile_0_1>() { | |
| 24 return PPB_FLASH_FONTFILE_INTERFACE_0_1; | |
| 25 } | |
| 26 | |
| 27 } // namespace | |
| 28 | |
| 29 namespace flash { | |
| 30 | |
| 31 FontFile::FontFile(const InstanceHandle& instance, | |
| 32 const PP_FontDescription_Dev* description, | |
| 33 PP_PrivateFontCharset charset) : Resource() { | |
| 34 if (has_interface<PPB_Flash_FontFile_0_1>()) { | |
| 35 PassRefFromConstructor(get_interface<PPB_Flash_FontFile_0_1>()->Create( | |
| 36 instance.pp_instance(), description, charset)); | |
| 37 } else if (has_interface<PPB_PDF>()) { | |
| 38 PassRefFromConstructor(get_interface<PPB_PDF>()->GetFontFileWithFallback( | |
| 39 instance.pp_instance(), description, charset)); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 FontFile::~FontFile() { | |
| 44 } | |
| 45 | |
| 46 // static | |
| 47 bool FontFile::IsAvailable() { | |
| 48 return has_interface<PPB_Flash_FontFile_0_1>() || has_interface<PPB_PDF>(); | |
| 49 } | |
| 50 | |
| 51 bool FontFile::GetFontTable(uint32_t table, | |
| 52 void* output, | |
| 53 uint32_t* output_length) { | |
| 54 if (has_interface<PPB_Flash_FontFile_0_1>()) { | |
| 55 return !!get_interface<PPB_Flash_FontFile_0_1>()-> | |
| 56 GetFontTable(pp_resource(), table, output, output_length); | |
| 57 } | |
| 58 if (has_interface<PPB_PDF>()) { | |
| 59 return get_interface<PPB_PDF>()->GetFontTableForPrivateFontFile( | |
| 60 pp_resource(), table, output, output_length); | |
| 61 } | |
| 62 return false; | |
| 63 } | |
| 64 | |
| 65 } // namespace flash | |
| 66 } // namespace pp | |
| OLD | NEW |