Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: ppapi/cpp/private/pdf.cc

Issue 12527012: Add PPAPI C++ wrappers for PDF. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/cpp/private/pdf.cc
diff --git a/ppapi/cpp/private/pdf.cc b/ppapi/cpp/private/pdf.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1c64840272df57fcac774aba136fae626cca0f18
--- /dev/null
+++ b/ppapi/cpp/private/pdf.cc
@@ -0,0 +1,161 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/private/pdf.h"
+
+#include "ppapi/cpp/image_data.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/module_impl.h"
+#include "ppapi/cpp/var.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_PDF>() {
+ return PPB_PDF_INTERFACE;
+}
+
+} // namespace
+
+// static
+bool PDF::IsAvailable() {
+ return has_interface<PPB_PDF>();
+}
+
+// static
+Var PDF::GetLocalizedString(const InstanceHandle& instance,
+ PP_ResourceString string_id) {
+ if (has_interface<PPB_PDF>()) {
+ return pp::Var(pp::PASS_REF,
+ get_interface<PPB_PDF>()->GetLocalizedString(
+ instance.pp_instance(), string_id));
+ }
+ return Var();
+}
+
+// static
+pp::ImageData PDF::GetResourceImage(const InstanceHandle& instance,
+ PP_ResourceImage image_id) {
+ if (has_interface<PPB_PDF>()) {
+ return pp::ImageData(pp::PASS_REF,
+ get_interface<PPB_PDF>()->GetResourceImage(
+ instance.pp_instance(), image_id));
+ }
+ return pp::ImageData();
+}
+
+// static
+PP_Resource PDF::GetFontFileWithFallback(
+ const InstanceHandle& instance,
+ 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.
+ PP_PrivateFontCharset charset) {
+ if (has_interface<PPB_PDF>()) {
+ return get_interface<PPB_PDF>()->GetFontFileWithFallback(
+ instance.pp_instance(), description, charset);
+ }
+ return 0;
+}
+
+// static
+bool PDF::GetFontTableForPrivateFontFile(const InstanceHandle& instance,
+ PP_Resource font_file,
+ uint32_t table,
+ void* output,
+ uint32_t* output_length) {
+ if (has_interface<PPB_PDF>()) {
+ return get_interface<PPB_PDF>()->GetFontTableForPrivateFontFile(font_file,
+ table, output, output_length);
+ }
+ return false;
+}
+
+// static
+void PDF::SearchString(const InstanceHandle& instance,
+ const unsigned short* string,
+ const unsigned short* term,
+ bool case_sensitive,
+ struct PP_PrivateFindResult** results,
+ int* count) {
+ if (has_interface<PPB_PDF>()) {
+ get_interface<PPB_PDF>()->SearchString(instance.pp_instance(), string,
+ term, case_sensitive, results, count);
+ }
+}
+
+// static
+void PDF::DidStartLoading(const InstanceHandle& instance) {
+ if (has_interface<PPB_PDF>())
+ get_interface<PPB_PDF>()->DidStartLoading(instance.pp_instance());
+}
+
+// static
+void PDF::DidStopLoading(const InstanceHandle& instance) {
+ if (has_interface<PPB_PDF>())
+ get_interface<PPB_PDF>()->DidStopLoading(instance.pp_instance());
+}
+
+// static
+void PDF::SetContentRestriction(const InstanceHandle& instance,
+ int restrictions) {
+ if (has_interface<PPB_PDF>()) {
+ get_interface<PPB_PDF>()->SetContentRestriction(instance.pp_instance(),
+ restrictions);
+ }
+}
+
+// static
+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.
+ int count) {
+ 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.
+ get_interface<PPB_PDF>()->HistogramPDFPageCount(count);
+ }
+}
+
+// static
+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.
+ const Var& action) {
+ if (has_interface<PPB_PDF>())
+ get_interface<PPB_PDF>()->UserMetricsRecordAction(action.pp_var());
+}
+
+// static
+void PDF::HasUnsupportedFeature(const InstanceHandle& instance) {
+ if (has_interface<PPB_PDF>())
+ get_interface<PPB_PDF>()->HasUnsupportedFeature(instance.pp_instance());
+}
+
+// static
+void PDF::SaveAs(const InstanceHandle& instance) {
+ if (has_interface<PPB_PDF>())
+ get_interface<PPB_PDF>()->SaveAs(instance.pp_instance());
+}
+
+// static
+void PDF::Print(const InstanceHandle& instance) {
+ if (has_interface<PPB_PDF>())
+ get_interface<PPB_PDF>()->Print(instance.pp_instance());
+}
+
+// static
+bool PDF::IsFeatureEnabled(const InstanceHandle& instance,
yzshen1 2013/03/18 17:55:47 ditto.
raymes 2013/03/18 18:15:39 Done.
+ PP_PDFFeature feature) {
+ if (has_interface<PPB_PDF>())
+ return get_interface<PPB_PDF>()->IsFeatureEnabled(feature);
+ return false;
+}
+
+// static
+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.
+ PP_ResourceImage image_id,
+ float scale) {
+ if (has_interface<PPB_PDF>()) {
+ return pp::ImageData(pp::PASS_REF,
+ get_interface<PPB_PDF>()->GetResourceImageForScale(
+ instance.pp_instance(), image_id, scale));
+ }
+ return pp::ImageData();
+}
+
+} // namespace pp
« ppapi/cpp/private/pdf.h ('K') | « ppapi/cpp/private/pdf.h ('k') | ppapi/ppapi_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698