1 // Copyright (c) 2013 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.
5 #include "ppapi/cpp/private/pdf.h"
7 #include "ppapi/c/trusted/ppb_browser_font_trusted.h"
8 #include "ppapi/cpp/image_data.h"
9 #include "ppapi/cpp/instance_handle.h"
10 #include "ppapi/cpp/module_impl.h"
11 #include "ppapi/cpp/var.h"
17 template <> const char* interface_name
<PPB_PDF
>() {
18 return PPB_PDF_INTERFACE
;
24 bool PDF::IsAvailable() {
25 return has_interface
<PPB_PDF
>();
29 Var
PDF::GetLocalizedString(const InstanceHandle
& instance
,
30 PP_ResourceString string_id
) {
31 if (has_interface
<PPB_PDF
>()) {
33 get_interface
<PPB_PDF
>()->GetLocalizedString(
34 instance
.pp_instance(), string_id
));
40 PP_Resource
PDF::GetFontFileWithFallback(
41 const InstanceHandle
& instance
,
42 const PP_BrowserFont_Trusted_Description
* description
,
43 PP_PrivateFontCharset charset
) {
44 if (has_interface
<PPB_PDF
>()) {
45 return get_interface
<PPB_PDF
>()->GetFontFileWithFallback(
46 instance
.pp_instance(), description
, charset
);
52 bool PDF::GetFontTableForPrivateFontFile(PP_Resource font_file
,
55 uint32_t* output_length
) {
56 if (has_interface
<PPB_PDF
>()) {
57 return get_interface
<PPB_PDF
>()->GetFontTableForPrivateFontFile(font_file
,
58 table
, output
, output_length
);
64 void PDF::SearchString(const InstanceHandle
& instance
,
65 const unsigned short* string
,
66 const unsigned short* term
,
68 PP_PrivateFindResult
** results
,
70 if (has_interface
<PPB_PDF
>()) {
71 get_interface
<PPB_PDF
>()->SearchString(instance
.pp_instance(), string
,
72 term
, case_sensitive
, results
, count
);
77 void PDF::DidStartLoading(const InstanceHandle
& instance
) {
78 if (has_interface
<PPB_PDF
>())
79 get_interface
<PPB_PDF
>()->DidStartLoading(instance
.pp_instance());
83 void PDF::DidStopLoading(const InstanceHandle
& instance
) {
84 if (has_interface
<PPB_PDF
>())
85 get_interface
<PPB_PDF
>()->DidStopLoading(instance
.pp_instance());
89 void PDF::SetContentRestriction(const InstanceHandle
& instance
,
91 if (has_interface
<PPB_PDF
>()) {
92 get_interface
<PPB_PDF
>()->SetContentRestriction(instance
.pp_instance(),
98 void PDF::UserMetricsRecordAction(const InstanceHandle
& instance
,
100 if (has_interface
<PPB_PDF
>()) {
101 get_interface
<PPB_PDF
>()->UserMetricsRecordAction(instance
.pp_instance(),
107 void PDF::HasUnsupportedFeature(const InstanceHandle
& instance
) {
108 if (has_interface
<PPB_PDF
>())
109 get_interface
<PPB_PDF
>()->HasUnsupportedFeature(instance
.pp_instance());
113 void PDF::SaveAs(const InstanceHandle
& instance
) {
114 if (has_interface
<PPB_PDF
>())
115 get_interface
<PPB_PDF
>()->SaveAs(instance
.pp_instance());
119 void PDF::Print(const InstanceHandle
& instance
) {
120 if (has_interface
<PPB_PDF
>())
121 get_interface
<PPB_PDF
>()->Print(instance
.pp_instance());
125 bool PDF::IsFeatureEnabled(const InstanceHandle
& instance
,
126 PP_PDFFeature feature
) {
127 if (has_interface
<PPB_PDF
>())
128 return PP_ToBool(get_interface
<PPB_PDF
>()->IsFeatureEnabled(
129 instance
.pp_instance(), feature
));
134 void PDF::SetSelectedText(const InstanceHandle
& instance
,
135 const char* selected_text
) {
136 if (has_interface
<PPB_PDF
>()) {
137 get_interface
<PPB_PDF
>()->SetSelectedText(instance
.pp_instance(),
143 void PDF::SetLinkUnderCursor(const InstanceHandle
& instance
, const char* url
) {
144 if (has_interface
<PPB_PDF
>())
145 get_interface
<PPB_PDF
>()->SetLinkUnderCursor(instance
.pp_instance(), url
);
149 void PDF::GetV8ExternalSnapshotData(const InstanceHandle
& instance
,
150 const char** natives_data_out
,
151 int* natives_size_out
,
152 const char** snapshot_data_out
,
153 int* snapshot_size_out
) {
154 if (has_interface
<PPB_PDF
>()) {
155 get_interface
<PPB_PDF
>()->GetV8ExternalSnapshotData(instance
.pp_instance(),
156 natives_data_out
, natives_size_out
, snapshot_data_out
,
160 *natives_data_out
= NULL
;
161 *snapshot_data_out
= NULL
;
162 *natives_size_out
= 0;
163 *snapshot_size_out
= 0;