Chromium Code Reviews| 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 pp::Var(pp::PASS_REF, | |
| 32 get_interface<PPB_PDF>()->GetLocalizedString( | |
| 33 instance.pp_instance(), string_id)); | |
| 34 } | |
| 35 return Var(); | |
| 36 } | |
| 37 | |
| 38 // static | |
| 39 pp::ImageData PDF::GetResourceImage(const InstanceHandle& instance, | |
| 40 PP_ResourceImage image_id) { | |
| 41 if (has_interface<PPB_PDF>()) { | |
| 42 return pp::ImageData(pp::PASS_REF, | |
| 43 get_interface<PPB_PDF>()->GetResourceImage( | |
| 44 instance.pp_instance(), image_id)); | |
| 45 } | |
| 46 return pp::ImageData(); | |
| 47 } | |
| 48 | |
| 49 // static | |
| 50 PP_Resource PDF::GetFontFileWithFallback( | |
| 51 const InstanceHandle& instance, | |
| 52 const struct PP_FontDescription_Dev* description, | |
|
yzshen1
2013/03/18 17:55:47
nit: 'struct' is not needed (and there are other p
raymes
2013/03/18 18:15:39
Done.
| |
| 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 struct 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, | |
|
yzshen1
2013/03/18 17:55:47
Please use /* instance */, otherwise it may cause
raymes
2013/03/18 18:15:39
Done.
| |
| 110 int count) { | |
| 111 if (has_interface<PPB_PDF>()) { | |
|
yzshen1
2013/03/18 17:55:47
nit: no need to have {} (as line 95-96).
raymes
2013/03/18 18:15:39
Done.
| |
| 112 get_interface<PPB_PDF>()->HistogramPDFPageCount(count); | |
| 113 } | |
| 114 } | |
| 115 | |
| 116 // static | |
| 117 void PDF::UserMetricsRecordAction(const InstanceHandle& instance, | |
|
yzshen1
2013/03/18 17:55:47
Please use /* instance */, otherwise it may cause
raymes
2013/03/18 18:15:39
Done.
| |
| 118 const Var& action) { | |
| 119 if (has_interface<PPB_PDF>()) | |
| 120 get_interface<PPB_PDF>()->UserMetricsRecordAction(action.pp_var()); | |
| 121 } | |
| 122 | |
| 123 // static | |
| 124 void PDF::HasUnsupportedFeature(const InstanceHandle& instance) { | |
| 125 if (has_interface<PPB_PDF>()) | |
| 126 get_interface<PPB_PDF>()->HasUnsupportedFeature(instance.pp_instance()); | |
| 127 } | |
| 128 | |
| 129 // static | |
| 130 void PDF::SaveAs(const InstanceHandle& instance) { | |
| 131 if (has_interface<PPB_PDF>()) | |
| 132 get_interface<PPB_PDF>()->SaveAs(instance.pp_instance()); | |
| 133 } | |
| 134 | |
| 135 // static | |
| 136 void PDF::Print(const InstanceHandle& instance) { | |
| 137 if (has_interface<PPB_PDF>()) | |
| 138 get_interface<PPB_PDF>()->Print(instance.pp_instance()); | |
| 139 } | |
| 140 | |
| 141 // static | |
| 142 bool PDF::IsFeatureEnabled(const InstanceHandle& instance, | |
|
yzshen1
2013/03/18 17:55:47
ditto.
raymes
2013/03/18 18:15:39
Done.
| |
| 143 PP_PDFFeature feature) { | |
| 144 if (has_interface<PPB_PDF>()) | |
| 145 return get_interface<PPB_PDF>()->IsFeatureEnabled(feature); | |
| 146 return false; | |
| 147 } | |
| 148 | |
| 149 // static | |
| 150 pp::ImageData PDF::GetResourceImageForScale(const InstanceHandle& instance, | |
|
yzshen1
2013/03/18 17:55:47
you don't need pp:: (and there are other places th
raymes
2013/03/18 18:15:39
Done.
| |
| 151 PP_ResourceImage image_id, | |
| 152 float scale) { | |
| 153 if (has_interface<PPB_PDF>()) { | |
| 154 return pp::ImageData(pp::PASS_REF, | |
| 155 get_interface<PPB_PDF>()->GetResourceImageForScale( | |
| 156 instance.pp_instance(), image_id, scale)); | |
| 157 } | |
| 158 return pp::ImageData(); | |
| 159 } | |
| 160 | |
| 161 } // namespace pp | |
| OLD | NEW |