This source file includes following definitions.
- IsAvailable
- GetLocalizedString
- GetResourceImage
- GetFontFileWithFallback
- GetFontFileWithFallback
- GetFontTableForPrivateFontFile
- SearchString
- DidStartLoading
- DidStopLoading
- SetContentRestriction
- HistogramPDFPageCount
- UserMetricsRecordAction
- HasUnsupportedFeature
- SaveAs
- Print
- IsFeatureEnabled
- GetResourceImageForScale
- ModalPromptForPassword
- IsOutOfProcess
- SetSelectedText
- SetLinkUnderCursor
#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"
#include "ppapi/cpp/var.h"
namespace pp {
namespace {
template <> const char* interface_name<PPB_PDF>() {
return PPB_PDF_INTERFACE;
}
}
bool PDF::IsAvailable() {
return has_interface<PPB_PDF>();
}
Var PDF::GetLocalizedString(const InstanceHandle& instance,
PP_ResourceString string_id) {
if (has_interface<PPB_PDF>()) {
return Var(PASS_REF,
get_interface<PPB_PDF>()->GetLocalizedString(
instance.pp_instance(), string_id));
}
return Var();
}
ImageData PDF::GetResourceImage(const InstanceHandle& instance,
PP_ResourceImage image_id) {
if (has_interface<PPB_PDF>()) {
return ImageData(PASS_REF,
get_interface<PPB_PDF>()->GetResourceImage(
instance.pp_instance(), image_id));
}
return ImageData();
}
PP_Resource PDF::GetFontFileWithFallback(
const InstanceHandle& instance,
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;
}
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);
}
return 0;
}
bool PDF::GetFontTableForPrivateFontFile(PP_Resource font_file,
uint32_t table,
void* output,
uint32_t* output_length) {
if (has_interface<PPB_PDF>()) {
return get_interface<PPB_PDF>()->GetFontTableForPrivateFontFile(font_file,
table, output, output_length);
}
return false;
}
void PDF::SearchString(const InstanceHandle& instance,
const unsigned short* string,
const unsigned short* term,
bool case_sensitive,
PP_PrivateFindResult** results,
int* count) {
if (has_interface<PPB_PDF>()) {
get_interface<PPB_PDF>()->SearchString(instance.pp_instance(), string,
term, case_sensitive, results, count);
}
}
void PDF::DidStartLoading(const InstanceHandle& instance) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->DidStartLoading(instance.pp_instance());
}
void PDF::DidStopLoading(const InstanceHandle& instance) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->DidStopLoading(instance.pp_instance());
}
void PDF::SetContentRestriction(const InstanceHandle& instance,
int restrictions) {
if (has_interface<PPB_PDF>()) {
get_interface<PPB_PDF>()->SetContentRestriction(instance.pp_instance(),
restrictions);
}
}
void PDF::HistogramPDFPageCount(const InstanceHandle& instance,
int count) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->HistogramPDFPageCount(instance.pp_instance(),
count);
}
void PDF::UserMetricsRecordAction(const InstanceHandle& instance,
const Var& action) {
if (has_interface<PPB_PDF>()) {
get_interface<PPB_PDF>()->UserMetricsRecordAction(instance.pp_instance(),
action.pp_var());
}
}
void PDF::HasUnsupportedFeature(const InstanceHandle& instance) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->HasUnsupportedFeature(instance.pp_instance());
}
void PDF::SaveAs(const InstanceHandle& instance) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->SaveAs(instance.pp_instance());
}
void PDF::Print(const InstanceHandle& instance) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->Print(instance.pp_instance());
}
bool PDF::IsFeatureEnabled(const InstanceHandle& instance,
PP_PDFFeature feature) {
if (has_interface<PPB_PDF>())
return PP_ToBool(get_interface<PPB_PDF>()->IsFeatureEnabled(
instance.pp_instance(), feature));
return false;
}
ImageData PDF::GetResourceImageForScale(const InstanceHandle& instance,
PP_ResourceImage image_id,
float scale) {
if (has_interface<PPB_PDF>()) {
return ImageData(PASS_REF,
get_interface<PPB_PDF>()->GetResourceImageForScale(
instance.pp_instance(), image_id, scale));
}
return ImageData();
}
Var PDF::ModalPromptForPassword(const InstanceHandle& instance,
Var message) {
if (has_interface<PPB_PDF>()) {
return Var(PASS_REF,
get_interface<PPB_PDF>()->ModalPromptForPassword(
instance.pp_instance(),
message.pp_var()));
}
return Var();
}
bool PDF::IsOutOfProcess(const InstanceHandle& instance) {
if (has_interface<PPB_PDF>()) {
return PP_ToBool(get_interface<PPB_PDF>()->IsOutOfProcess(
instance.pp_instance()));
}
return false;
}
void PDF::SetSelectedText(const InstanceHandle& instance,
const char* selected_text) {
if (has_interface<PPB_PDF>()) {
get_interface<PPB_PDF>()->SetSelectedText(instance.pp_instance(),
selected_text);
}
}
void PDF::SetLinkUnderCursor(const InstanceHandle& instance, const char* url) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->SetLinkUnderCursor(instance.pp_instance(), url);
}
}