OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "ppapi/cpp/private/pdf.h" |
| 6 |
| 7 #include "ppapi/cpp/image_data.h" |
| 8 #include "ppapi/cpp/instance_handle.h" |
| 9 #include "ppapi/cpp/module_impl.h" |
| 10 #include "ppapi/cpp/var.h" |
| 11 |
| 12 namespace pp { |
| 13 |
| 14 namespace { |
| 15 |
| 16 template <> const char* interface_name<PPB_PDF>() { |
| 17 return PPB_PDF_INTERFACE; |
| 18 } |
| 19 |
| 20 } // namespace |
| 21 |
| 22 // static |
| 23 bool PDF::IsAvailable() { |
| 24 return has_interface<PPB_PDF>(); |
| 25 } |
| 26 |
| 27 // static |
| 28 Var PDF::GetLocalizedString(const InstanceHandle& instance, |
| 29 PP_ResourceString string_id) { |
| 30 if (has_interface<PPB_PDF>()) { |
| 31 return Var(PASS_REF, |
| 32 get_interface<PPB_PDF>()->GetLocalizedString( |
| 33 instance.pp_instance(), string_id)); |
| 34 } |
| 35 return Var(); |
| 36 } |
| 37 |
| 38 // static |
| 39 ImageData PDF::GetResourceImage(const InstanceHandle& instance, |
| 40 PP_ResourceImage image_id) { |
| 41 if (has_interface<PPB_PDF>()) { |
| 42 return ImageData(PASS_REF, |
| 43 get_interface<PPB_PDF>()->GetResourceImage( |
| 44 instance.pp_instance(), image_id)); |
| 45 } |
| 46 return ImageData(); |
| 47 } |
| 48 |
| 49 // static |
| 50 PP_Resource PDF::GetFontFileWithFallback( |
| 51 const InstanceHandle& instance, |
| 52 const PP_FontDescription_Dev* description, |
| 53 PP_PrivateFontCharset charset) { |
| 54 if (has_interface<PPB_PDF>()) { |
| 55 return get_interface<PPB_PDF>()->GetFontFileWithFallback( |
| 56 instance.pp_instance(), description, charset); |
| 57 } |
| 58 return 0; |
| 59 } |
| 60 |
| 61 // static |
| 62 bool PDF::GetFontTableForPrivateFontFile(const InstanceHandle& /*instance*/, |
| 63 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); |
| 70 } |
| 71 return false; |
| 72 } |
| 73 |
| 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); |
| 84 } |
| 85 } |
| 86 |
| 87 // static |
| 88 void PDF::DidStartLoading(const InstanceHandle& instance) { |
| 89 if (has_interface<PPB_PDF>()) |
| 90 get_interface<PPB_PDF>()->DidStartLoading(instance.pp_instance()); |
| 91 } |
| 92 |
| 93 // static |
| 94 void PDF::DidStopLoading(const InstanceHandle& instance) { |
| 95 if (has_interface<PPB_PDF>()) |
| 96 get_interface<PPB_PDF>()->DidStopLoading(instance.pp_instance()); |
| 97 } |
| 98 |
| 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); |
| 105 } |
| 106 } |
| 107 |
| 108 // static |
| 109 void PDF::HistogramPDFPageCount(const InstanceHandle& /*instance*/, |
| 110 int count) { |
| 111 if (has_interface<PPB_PDF>()) |
| 112 get_interface<PPB_PDF>()->HistogramPDFPageCount(count); |
| 113 } |
| 114 |
| 115 // static |
| 116 void PDF::UserMetricsRecordAction(const InstanceHandle& /*instance*/, |
| 117 const Var& action) { |
| 118 if (has_interface<PPB_PDF>()) |
| 119 get_interface<PPB_PDF>()->UserMetricsRecordAction(action.pp_var()); |
| 120 } |
| 121 |
| 122 // static |
| 123 void PDF::HasUnsupportedFeature(const InstanceHandle& instance) { |
| 124 if (has_interface<PPB_PDF>()) |
| 125 get_interface<PPB_PDF>()->HasUnsupportedFeature(instance.pp_instance()); |
| 126 } |
| 127 |
| 128 // static |
| 129 void PDF::SaveAs(const InstanceHandle& instance) { |
| 130 if (has_interface<PPB_PDF>()) |
| 131 get_interface<PPB_PDF>()->SaveAs(instance.pp_instance()); |
| 132 } |
| 133 |
| 134 // static |
| 135 void PDF::Print(const InstanceHandle& instance) { |
| 136 if (has_interface<PPB_PDF>()) |
| 137 get_interface<PPB_PDF>()->Print(instance.pp_instance()); |
| 138 } |
| 139 |
| 140 // static |
| 141 bool PDF::IsFeatureEnabled(const InstanceHandle& /* instance, */, |
| 142 PP_PDFFeature feature) { |
| 143 if (has_interface<PPB_PDF>()) |
| 144 return PP_ToBool(get_interface<PPB_PDF>()->IsFeatureEnabled(feature)); |
| 145 return false; |
| 146 } |
| 147 |
| 148 // static |
| 149 ImageData PDF::GetResourceImageForScale(const InstanceHandle& instance, |
| 150 PP_ResourceImage image_id, |
| 151 float scale) { |
| 152 if (has_interface<PPB_PDF>()) { |
| 153 return ImageData(PASS_REF, |
| 154 get_interface<PPB_PDF>()->GetResourceImageForScale( |
| 155 instance.pp_instance(), image_id, scale)); |
| 156 } |
| 157 return ImageData(); |
| 158 } |
| 159 |
| 160 } // namespace pp |
OLD | NEW |