Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ppapi / cpp / private / pdf.cc
blob17b0b4d2a712948535f0c813b9abf55430593562
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"
13 namespace pp {
15 namespace {
17 template <> const char* interface_name<PPB_PDF>() {
18 return PPB_PDF_INTERFACE;
21 } // namespace
23 // static
24 bool PDF::IsAvailable() {
25 return has_interface<PPB_PDF>();
28 // static
29 Var PDF::GetLocalizedString(const InstanceHandle& instance,
30 PP_ResourceString string_id) {
31 if (has_interface<PPB_PDF>()) {
32 return Var(PASS_REF,
33 get_interface<PPB_PDF>()->GetLocalizedString(
34 instance.pp_instance(), string_id));
36 return Var();
39 // static
40 ImageData PDF::GetResourceImage(const InstanceHandle& instance,
41 PP_ResourceImage image_id) {
42 if (has_interface<PPB_PDF>()) {
43 return ImageData(PASS_REF,
44 get_interface<PPB_PDF>()->GetResourceImage(
45 instance.pp_instance(), image_id));
47 return ImageData();
50 // static
51 PP_Resource PDF::GetFontFileWithFallback(
52 const InstanceHandle& instance,
53 const PP_BrowserFont_Trusted_Description* description,
54 PP_PrivateFontCharset charset) {
55 if (has_interface<PPB_PDF>()) {
56 return get_interface<PPB_PDF>()->GetFontFileWithFallback(
57 instance.pp_instance(), description, charset);
59 return 0;
62 // static
63 bool PDF::GetFontTableForPrivateFontFile(PP_Resource font_file,
64 uint32_t table,
65 void* output,
66 uint32_t* output_length) {
67 if (has_interface<PPB_PDF>()) {
68 return get_interface<PPB_PDF>()->GetFontTableForPrivateFontFile(font_file,
69 table, output, output_length);
71 return false;
74 // static
75 void PDF::SearchString(const InstanceHandle& instance,
76 const unsigned short* string,
77 const unsigned short* term,
78 bool case_sensitive,
79 PP_PrivateFindResult** results,
80 int* count) {
81 if (has_interface<PPB_PDF>()) {
82 get_interface<PPB_PDF>()->SearchString(instance.pp_instance(), string,
83 term, case_sensitive, results, count);
87 // static
88 void PDF::DidStartLoading(const InstanceHandle& instance) {
89 if (has_interface<PPB_PDF>())
90 get_interface<PPB_PDF>()->DidStartLoading(instance.pp_instance());
93 // static
94 void PDF::DidStopLoading(const InstanceHandle& instance) {
95 if (has_interface<PPB_PDF>())
96 get_interface<PPB_PDF>()->DidStopLoading(instance.pp_instance());
99 // static
100 void PDF::SetContentRestriction(const InstanceHandle& instance,
101 int restrictions) {
102 if (has_interface<PPB_PDF>()) {
103 get_interface<PPB_PDF>()->SetContentRestriction(instance.pp_instance(),
104 restrictions);
108 // static
109 void PDF::HistogramPDFPageCount(const InstanceHandle& instance,
110 int count) {
111 if (has_interface<PPB_PDF>())
112 get_interface<PPB_PDF>()->HistogramPDFPageCount(instance.pp_instance(),
113 count);
116 // static
117 void PDF::UserMetricsRecordAction(const InstanceHandle& instance,
118 const Var& action) {
119 if (has_interface<PPB_PDF>()) {
120 get_interface<PPB_PDF>()->UserMetricsRecordAction(instance.pp_instance(),
121 action.pp_var());
125 // static
126 void PDF::HasUnsupportedFeature(const InstanceHandle& instance) {
127 if (has_interface<PPB_PDF>())
128 get_interface<PPB_PDF>()->HasUnsupportedFeature(instance.pp_instance());
131 // static
132 void PDF::SaveAs(const InstanceHandle& instance) {
133 if (has_interface<PPB_PDF>())
134 get_interface<PPB_PDF>()->SaveAs(instance.pp_instance());
137 // static
138 void PDF::Print(const InstanceHandle& instance) {
139 if (has_interface<PPB_PDF>())
140 get_interface<PPB_PDF>()->Print(instance.pp_instance());
143 // static
144 bool PDF::IsFeatureEnabled(const InstanceHandle& instance,
145 PP_PDFFeature feature) {
146 if (has_interface<PPB_PDF>())
147 return PP_ToBool(get_interface<PPB_PDF>()->IsFeatureEnabled(
148 instance.pp_instance(), feature));
149 return false;
152 // static
153 ImageData PDF::GetResourceImageForScale(const InstanceHandle& instance,
154 PP_ResourceImage image_id,
155 float scale) {
156 if (has_interface<PPB_PDF>()) {
157 return ImageData(PASS_REF,
158 get_interface<PPB_PDF>()->GetResourceImageForScale(
159 instance.pp_instance(), image_id, scale));
161 return ImageData();
164 // static
165 Var PDF::ModalPromptForPassword(const InstanceHandle& instance,
166 Var message) {
167 if (has_interface<PPB_PDF>()) {
168 return Var(PASS_REF,
169 get_interface<PPB_PDF>()->ModalPromptForPassword(
170 instance.pp_instance(),
171 message.pp_var()));
173 return Var();
176 // static
177 bool PDF::IsOutOfProcess(const InstanceHandle& instance) {
178 if (has_interface<PPB_PDF>()) {
179 return PP_ToBool(get_interface<PPB_PDF>()->IsOutOfProcess(
180 instance.pp_instance()));
182 return false;
185 // static
186 void PDF::SetSelectedText(const InstanceHandle& instance,
187 const char* selected_text) {
188 if (has_interface<PPB_PDF>()) {
189 get_interface<PPB_PDF>()->SetSelectedText(instance.pp_instance(),
190 selected_text);
194 // static
195 void PDF::SetLinkUnderCursor(const InstanceHandle& instance, const char* url) {
196 if (has_interface<PPB_PDF>())
197 get_interface<PPB_PDF>()->SetLinkUnderCursor(instance.pp_instance(), url);
200 // static
201 void PDF::GetV8ExternalSnapshotData(const InstanceHandle& instance,
202 const char** natives_data_out,
203 int* natives_size_out,
204 const char** snapshot_data_out,
205 int* snapshot_size_out) {
206 if (has_interface<PPB_PDF>()) {
207 get_interface<PPB_PDF>()->GetV8ExternalSnapshotData(instance.pp_instance(),
208 natives_data_out, natives_size_out, snapshot_data_out,
209 snapshot_size_out);
210 return;
212 *natives_data_out = NULL;
213 *snapshot_data_out = NULL;
214 *natives_size_out = 0;
215 *snapshot_size_out = 0;
218 } // namespace pp