Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / ppapi / cpp / private / pdf.cc
blob24127f106895042b5cf11d45badd0d5681bf6ed5
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 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);
48 return 0;
51 // static
52 bool PDF::GetFontTableForPrivateFontFile(PP_Resource font_file,
53 uint32_t table,
54 void* output,
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);
60 return false;
63 // static
64 void PDF::SearchString(const InstanceHandle& instance,
65 const unsigned short* string,
66 const unsigned short* term,
67 bool case_sensitive,
68 PP_PrivateFindResult** results,
69 int* count) {
70 if (has_interface<PPB_PDF>()) {
71 get_interface<PPB_PDF>()->SearchString(instance.pp_instance(), string,
72 term, case_sensitive, results, count);
76 // static
77 void PDF::DidStartLoading(const InstanceHandle& instance) {
78 if (has_interface<PPB_PDF>())
79 get_interface<PPB_PDF>()->DidStartLoading(instance.pp_instance());
82 // static
83 void PDF::DidStopLoading(const InstanceHandle& instance) {
84 if (has_interface<PPB_PDF>())
85 get_interface<PPB_PDF>()->DidStopLoading(instance.pp_instance());
88 // static
89 void PDF::SetContentRestriction(const InstanceHandle& instance,
90 int restrictions) {
91 if (has_interface<PPB_PDF>()) {
92 get_interface<PPB_PDF>()->SetContentRestriction(instance.pp_instance(),
93 restrictions);
97 // static
98 void PDF::UserMetricsRecordAction(const InstanceHandle& instance,
99 const Var& action) {
100 if (has_interface<PPB_PDF>()) {
101 get_interface<PPB_PDF>()->UserMetricsRecordAction(instance.pp_instance(),
102 action.pp_var());
106 // static
107 void PDF::HasUnsupportedFeature(const InstanceHandle& instance) {
108 if (has_interface<PPB_PDF>())
109 get_interface<PPB_PDF>()->HasUnsupportedFeature(instance.pp_instance());
112 // static
113 void PDF::SaveAs(const InstanceHandle& instance) {
114 if (has_interface<PPB_PDF>())
115 get_interface<PPB_PDF>()->SaveAs(instance.pp_instance());
118 // static
119 void PDF::Print(const InstanceHandle& instance) {
120 if (has_interface<PPB_PDF>())
121 get_interface<PPB_PDF>()->Print(instance.pp_instance());
124 // static
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));
130 return false;
133 // static
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(),
138 selected_text);
142 // static
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);
148 // static
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,
157 snapshot_size_out);
158 return;
160 *natives_data_out = NULL;
161 *snapshot_data_out = NULL;
162 *natives_size_out = 0;
163 *snapshot_size_out = 0;
166 } // namespace pp