| Index: chrome/renderer/pepper/ppb_pdf_impl.cc
|
| diff --git a/chrome/renderer/pepper/ppb_pdf_impl.cc b/chrome/renderer/pepper/ppb_pdf_impl.cc
|
| index 057d0a6143484bd0f4b97a5712344edd9df7ca6c..cfdde8a2d7719c0ed12100bfc06fac1ab848e1ce 100644
|
| --- a/chrome/renderer/pepper/ppb_pdf_impl.cc
|
| +++ b/chrome/renderer/pepper/ppb_pdf_impl.cc
|
| @@ -17,7 +17,6 @@
|
| #include "content/public/renderer/render_view.h"
|
| #include "grit/webkit_resources.h"
|
| #include "grit/webkit_strings.h"
|
| -#include "ppapi/c/pp_resource.h"
|
| #include "ppapi/c/private/ppb_pdf.h"
|
| #include "ppapi/shared_impl/resource.h"
|
| #include "ppapi/shared_impl/resource_tracker.h"
|
| @@ -156,55 +155,6 @@ PP_Var GetLocalizedString(PP_Instance instance_id,
|
| return ppapi::StringVar::StringToPPVar(rv);
|
| }
|
|
|
| -PP_Resource GetFontFileWithFallback(
|
| - PP_Instance instance_id,
|
| - const PP_FontDescription_Dev* description,
|
| - PP_PrivateFontCharset charset) {
|
| -#if defined(OS_LINUX) || defined(OS_OPENBSD)
|
| - // Validate the instance before using it below.
|
| - if (!content::GetHostGlobals()->GetInstance(instance_id))
|
| - return 0;
|
| -
|
| - scoped_refptr<ppapi::StringVar> face_name(ppapi::StringVar::FromPPVar(
|
| - description->face));
|
| - if (!face_name)
|
| - return 0;
|
| -
|
| - int fd = content::MatchFontWithFallback(
|
| - face_name->value().c_str(),
|
| - description->weight >= PP_FONTWEIGHT_BOLD,
|
| - description->italic,
|
| - charset);
|
| - if (fd == -1)
|
| - return 0;
|
| -
|
| - scoped_refptr<PrivateFontFile> font(new PrivateFontFile(instance_id, fd));
|
| -
|
| - return font->GetReference();
|
| -#else
|
| - // For trusted PPAPI plugins, this is only needed in Linux since font loading
|
| - // on Windows and Mac works through the renderer sandbox.
|
| - return 0;
|
| -#endif
|
| -}
|
| -
|
| -bool GetFontTableForPrivateFontFile(PP_Resource font_file,
|
| - uint32_t table,
|
| - void* output,
|
| - uint32_t* output_length) {
|
| -#if defined(OS_LINUX) || defined(OS_OPENBSD)
|
| - ppapi::Resource* resource =
|
| - PpapiGlobals::Get()->GetResourceTracker()->GetResource(font_file);
|
| - if (!resource)
|
| - return false;
|
| -
|
| - PrivateFontFile* font = static_cast<PrivateFontFile*>(resource);
|
| - return font->GetFontTable(table, output, output_length);
|
| -#else
|
| - return false;
|
| -#endif
|
| -}
|
| -
|
| void SearchString(PP_Instance instance,
|
| const unsigned short* input_string,
|
| const unsigned short* input_term,
|
| @@ -387,8 +337,8 @@ PP_Resource GetResourceImage(PP_Instance instance_id,
|
| const PPB_PDF ppb_pdf = {
|
| &GetLocalizedString,
|
| &GetResourceImage,
|
| - &GetFontFileWithFallback,
|
| - &GetFontTableForPrivateFontFile,
|
| + &PPB_PDF_Impl::GetFontFileWithFallback,
|
| + &PPB_PDF_Impl::GetFontTableForPrivateFontFile,
|
| &SearchString,
|
| &DidStartLoading,
|
| &DidStopLoading,
|
| @@ -410,6 +360,57 @@ const PPB_PDF* PPB_PDF_Impl::GetInterface() {
|
| }
|
|
|
| // static
|
| +PP_Resource PPB_PDF_Impl::GetFontFileWithFallback(
|
| + PP_Instance instance_id,
|
| + const PP_FontDescription_Dev* description,
|
| + PP_PrivateFontCharset charset) {
|
| +#if defined(OS_LINUX) || defined(OS_OPENBSD)
|
| + // Validate the instance before using it below.
|
| + if (!content::GetHostGlobals()->GetInstance(instance_id))
|
| + return 0;
|
| +
|
| + scoped_refptr<ppapi::StringVar> face_name(ppapi::StringVar::FromPPVar(
|
| + description->face));
|
| + if (!face_name)
|
| + return 0;
|
| +
|
| + int fd = content::MatchFontWithFallback(
|
| + face_name->value().c_str(),
|
| + description->weight >= PP_FONTWEIGHT_BOLD,
|
| + description->italic,
|
| + charset);
|
| + if (fd == -1)
|
| + return 0;
|
| +
|
| + scoped_refptr<PrivateFontFile> font(new PrivateFontFile(instance_id, fd));
|
| +
|
| + return font->GetReference();
|
| +#else
|
| + // For trusted PPAPI plugins, this is only needed in Linux since font loading
|
| + // on Windows and Mac works through the renderer sandbox.
|
| + return 0;
|
| +#endif
|
| +}
|
| +
|
| +// static
|
| +bool PPB_PDF_Impl::GetFontTableForPrivateFontFile(PP_Resource font_file,
|
| + uint32_t table,
|
| + void* output,
|
| + uint32_t* output_length) {
|
| +#if defined(OS_LINUX) || defined(OS_OPENBSD)
|
| + ppapi::Resource* resource =
|
| + PpapiGlobals::Get()->GetResourceTracker()->GetResource(font_file);
|
| + if (!resource)
|
| + return false;
|
| +
|
| + PrivateFontFile* font = static_cast<PrivateFontFile*>(resource);
|
| + return font->GetFontTable(table, output, output_length);
|
| +#else
|
| + return false;
|
| +#endif
|
| +}
|
| +
|
| +// static
|
| void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) {
|
| #if defined(ENABLE_PRINTING)
|
| PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
|
|
|