diff options
-rw-r--r-- | chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc | 31 | ||||
-rw-r--r-- | chrome/renderer/pepper/ppb_pdf_impl.cc | 4 | ||||
-rw-r--r-- | ppapi/c/private/ppb_pdf.h | 2 | ||||
-rw-r--r-- | ppapi/cpp/private/pdf.cc | 24 | ||||
-rw-r--r-- | ppapi/cpp/private/pdf.h | 8 | ||||
-rw-r--r-- | ppapi/ppapi_shared.gypi | 1 | ||||
-rw-r--r-- | ppapi/thunk/ppb_pdf_thunk.cc | 24 |
7 files changed, 74 insertions, 20 deletions
diff --git a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc index f243c3f..2946061 100644 --- a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc +++ b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc @@ -47,16 +47,6 @@ ChromeRendererPepperHostFactory::CreateResourceHost( return scoped_ptr<ResourceHost>(new PepperFlashRendererHost( host_, instance, params.pp_resource())); } - case PpapiHostMsg_FlashFontFile_Create::ID: { - ppapi::proxy::SerializedFontDescription description; - PP_PrivateFontCharset charset; - if (ppapi::UnpackMessage<PpapiHostMsg_FlashFontFile_Create>( - message, &description, &charset)) { - return scoped_ptr<ResourceHost>(new PepperFlashFontFileHost( - host_, instance, params.pp_resource(), description, charset)); - } - break; - } case PpapiHostMsg_FlashFullscreen_Create::ID: { return scoped_ptr<ResourceHost>(new PepperFlashFullscreenHost( host_, instance, params.pp_resource())); @@ -73,6 +63,27 @@ ChromeRendererPepperHostFactory::CreateResourceHost( } } + // TODO(raymes): PDF also needs access to the FlashFontFileHost currently. + // We should either rename PPB_FlashFont_File to PPB_FontFile_Private or get + // rid of its use in PDF if possible. + if (host_->GetPpapiHost()->permissions().HasPermission( + ppapi::PERMISSION_FLASH) || + host_->GetPpapiHost()->permissions().HasPermission( + ppapi::PERMISSION_PRIVATE)) { + switch (message.type()) { + case PpapiHostMsg_FlashFontFile_Create::ID: { + ppapi::proxy::SerializedFontDescription description; + PP_PrivateFontCharset charset; + if (ppapi::UnpackMessage<PpapiHostMsg_FlashFontFile_Create>( + message, &description, &charset)) { + return scoped_ptr<ResourceHost>(new PepperFlashFontFileHost( + host_, instance, params.pp_resource(), description, charset)); + } + break; + } + } + } + return scoped_ptr<ResourceHost>(); } diff --git a/chrome/renderer/pepper/ppb_pdf_impl.cc b/chrome/renderer/pepper/ppb_pdf_impl.cc index accb8b6..dd4c1d1 100644 --- a/chrome/renderer/pepper/ppb_pdf_impl.cc +++ b/chrome/renderer/pepper/ppb_pdf_impl.cc @@ -158,7 +158,7 @@ PP_Var GetLocalizedString(PP_Instance instance_id, PP_Resource GetFontFileWithFallback( PP_Instance instance_id, - const PP_FontDescription_Dev* description, + const PP_BrowserFont_Trusted_Description* description, PP_PrivateFontCharset charset) { #if defined(OS_LINUX) || defined(OS_OPENBSD) // Validate the instance before using it below. @@ -172,7 +172,7 @@ PP_Resource GetFontFileWithFallback( int fd = content::MatchFontWithFallback( face_name->value().c_str(), - description->weight >= PP_FONTWEIGHT_BOLD, + description->weight >= PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD, description->italic, charset); if (fd == -1) diff --git a/ppapi/c/private/ppb_pdf.h b/ppapi/c/private/ppb_pdf.h index e9a6d78..553eea8 100644 --- a/ppapi/c/private/ppb_pdf.h +++ b/ppapi/c/private/ppb_pdf.h @@ -102,7 +102,7 @@ struct PPB_PDF { // Currently Linux-only. PP_Resource (*GetFontFileWithFallback)( PP_Instance instance, - const struct PP_FontDescription_Dev* description, + const struct PP_BrowserFont_Trusted_Description* description, PP_PrivateFontCharset charset); // Given a resource previously returned by GetFontFileWithFallback, returns diff --git a/ppapi/cpp/private/pdf.cc b/ppapi/cpp/private/pdf.cc index e61cefc..753613c 100644 --- a/ppapi/cpp/private/pdf.cc +++ b/ppapi/cpp/private/pdf.cc @@ -4,6 +4,7 @@ #include "ppapi/cpp/private/pdf.h" +#include "ppapi/c/trusted/ppb_browser_font_trusted.h" #include "ppapi/cpp/image_data.h" #include "ppapi/cpp/instance_handle.h" #include "ppapi/cpp/module_impl.h" @@ -52,6 +53,29 @@ PP_Resource PDF::GetFontFileWithFallback( const PP_FontDescription_Dev* description, PP_PrivateFontCharset charset) { if (has_interface<PPB_PDF>()) { + PP_BrowserFont_Trusted_Description converted_desc; + converted_desc.face = description->face; + converted_desc.family = static_cast<PP_BrowserFont_Trusted_Family>( + description->family); + converted_desc.size = description->size; + converted_desc.weight = static_cast<PP_BrowserFont_Trusted_Weight>( + description->weight); + converted_desc.italic = description->italic; + converted_desc.small_caps = description->small_caps; + converted_desc.letter_spacing = description->letter_spacing; + converted_desc.word_spacing = description->word_spacing; + return get_interface<PPB_PDF>()->GetFontFileWithFallback( + instance.pp_instance(), &converted_desc, charset); + } + return 0; +} + +// static +PP_Resource PDF::GetFontFileWithFallback( + const InstanceHandle& instance, + const PP_BrowserFont_Trusted_Description* description, + PP_PrivateFontCharset charset) { + if (has_interface<PPB_PDF>()) { return get_interface<PPB_PDF>()->GetFontFileWithFallback( instance.pp_instance(), description, charset); } diff --git a/ppapi/cpp/private/pdf.h b/ppapi/cpp/private/pdf.h index 570c0e7..893f9e3 100644 --- a/ppapi/cpp/private/pdf.h +++ b/ppapi/cpp/private/pdf.h @@ -9,6 +9,8 @@ #include "ppapi/c/private/ppb_pdf.h" +struct PP_BrowserFont_Trusted_Description; + namespace pp { class ImageData; @@ -24,10 +26,16 @@ class PDF { PP_ResourceString string_id); static ImageData GetResourceImage(const InstanceHandle& instance, PP_ResourceImage image_id); + // TODO(raymes): Remove this version when the PDF code is changed to use + // PP_BrowserFont_Trusted_Description. static PP_Resource GetFontFileWithFallback( const InstanceHandle& instance, const PP_FontDescription_Dev* description, PP_PrivateFontCharset charset); + static PP_Resource GetFontFileWithFallback( + const InstanceHandle& instance, + const PP_BrowserFont_Trusted_Description* description, + PP_PrivateFontCharset charset); static bool GetFontTableForPrivateFontFile(PP_Resource font_file, uint32_t table, void* output, diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 3b81c00..0d0521a 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -292,6 +292,7 @@ 'thunk/ppb_gles_chromium_texture_mapping_thunk.cc', 'thunk/ppb_graphics_3d_trusted_thunk.cc', 'thunk/ppb_image_data_trusted_thunk.cc', + 'thunk/ppb_pdf_thunk.cc', 'thunk/ppb_scrollbar_thunk.cc', 'thunk/ppb_talk_private_thunk.cc', 'thunk/ppb_transport_thunk.cc', diff --git a/ppapi/thunk/ppb_pdf_thunk.cc b/ppapi/thunk/ppb_pdf_thunk.cc index 4216a2b..1d018dc 100644 --- a/ppapi/thunk/ppb_pdf_thunk.cc +++ b/ppapi/thunk/ppb_pdf_thunk.cc @@ -6,7 +6,9 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_pdf.h" #include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_flash_font_file_api.h" #include "ppapi/thunk/ppb_pdf_api.h" +#include "ppapi/thunk/resource_creation_api.h" #include "ppapi/thunk/thunk.h" namespace ppapi { @@ -31,20 +33,28 @@ PP_Resource GetResourceImage(PP_Instance instance, PP_Resource GetFontFileWithFallback( PP_Instance instance, - const PP_FontDescription_Dev* description, + const PP_BrowserFont_Trusted_Description* description, PP_PrivateFontCharset charset) { - // Not implemented out-of-process. - NOTIMPLEMENTED(); - return 0; + // TODO(raymes): Eventually we should replace the use of this function with + // either PPB_Flash_Font_File or PPB_TrueType_Font directly in the PDF code. + // For now just call into PPB_Flash_Font_File which has the exact same API. + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreateFlashFontFile(instance, description, charset); } bool GetFontTableForPrivateFontFile(PP_Resource font_file, uint32_t table, void* output, uint32_t* output_length) { - // Not implemented out-of-process. - NOTIMPLEMENTED(); - return false; + // TODO(raymes): Eventually we should replace the use of this function with + // either PPB_Flash_Font_File or PPB_TrueType_Font directly in the PDF code. + // For now just call into PPB_Flash_Font_File which has the exact same API. + EnterResource<PPB_Flash_FontFile_API> enter(font_file, true); + if (enter.failed()) + return PP_FALSE; + return PP_ToBool(enter.object()->GetFontTable(table, output, output_length)); } void SearchString(PP_Instance instance, |