summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp
diff options
context:
space:
mode:
authorraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-04 17:15:48 +0000
committerraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-04 17:15:48 +0000
commitde289526526174fcea503e55153e21411a944fee (patch)
tree2c3dc5498cf014c19877ef663fe3b9dd10a8426b /ppapi/cpp
parenteb63d674308842a51494c543565389dd08059c45 (diff)
downloadchromium_src-de289526526174fcea503e55153e21411a944fee.zip
chromium_src-de289526526174fcea503e55153e21411a944fee.tar.gz
chromium_src-de289526526174fcea503e55153e21411a944fee.tar.bz2
Add the PPAPI X509 Certificate interface and implementation.
Adds the interface for accessing X509 certificate fields. Note that the interface uses a GetField(field) method for accessing various fields of the certificate and all resuls are returned as pp::Var. This greatly simplifies the implementation of the interface and process of adding/changing fields so it is probably better (at least in the short term for flash). BUG=114626 TEST=out/Debug/ui_tests --gtest_filter=*PPAPITest.*X509Certificate* NOTRY=true Review URL: http://codereview.chromium.org/9693024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r--ppapi/cpp/private/x509_certificate_private.cc56
-rw-r--r--ppapi/cpp/private/x509_certificate_private.h35
2 files changed, 91 insertions, 0 deletions
diff --git a/ppapi/cpp/private/x509_certificate_private.cc b/ppapi/cpp/private/x509_certificate_private.cc
new file mode 100644
index 0000000..c23481c
--- /dev/null
+++ b/ppapi/cpp/private/x509_certificate_private.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 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/x509_certificate_private.h"
+
+#include "ppapi/cpp/module_impl.h"
+#include "ppapi/cpp/var.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_X509Certificate_Private_0_1>() {
+ return PPB_X509CERTIFICATE_PRIVATE_INTERFACE_0_1;
+}
+
+} // namespace
+
+X509Certificate::X509Certificate() : Resource() {
+}
+
+X509Certificate::X509Certificate(PP_Resource resource) : Resource(resource) {
+}
+
+X509Certificate::X509Certificate(const InstanceHandle& instance) {
+ if (has_interface<PPB_X509Certificate_Private_0_1>()) {
+ PassRefFromConstructor(get_interface<PPB_X509Certificate_Private_0_1>()->
+ Create(instance.pp_instance()));
+ }
+}
+
+// static
+bool X509Certificate::IsAvailable() {
+ return has_interface<PPB_X509Certificate_Private_0_1>();
+}
+
+bool X509Certificate::Initialize(const char* bytes, uint32_t length) {
+ if (!has_interface<PPB_X509Certificate_Private_0_1>())
+ return false;
+ PP_Bool result = get_interface<PPB_X509Certificate_Private_0_1>()->Initialize(
+ pp_resource(),
+ bytes,
+ length);
+ return PP_ToBool(result);
+}
+
+Var X509Certificate::GetField(PP_X509Certificate_Private_Field field) const {
+ if (!has_interface<PPB_X509Certificate_Private_0_1>())
+ return Var();
+ return Var(PassRef(),
+ get_interface<PPB_X509Certificate_Private_0_1>()->GetField(pp_resource(),
+ field));
+}
+
+} // namespace pp
diff --git a/ppapi/cpp/private/x509_certificate_private.h b/ppapi/cpp/private/x509_certificate_private.h
new file mode 100644
index 0000000..5b316b4
--- /dev/null
+++ b/ppapi/cpp/private/x509_certificate_private.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 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.
+
+#ifndef PPAPI_CPP_PRIVATE_X509_CERTIFICATE_PRIVATE_H_
+#define PPAPI_CPP_PRIVATE_X509_CERTIFICATE_PRIVATE_H_
+
+#include "ppapi/c/pp_stdint.h"
+#include "ppapi/c/private/ppb_x509_certificate_private.h"
+#include "ppapi/cpp/resource.h"
+
+namespace pp {
+
+class Var;
+
+class X509Certificate : public Resource {
+ public:
+ // Creates an is_null() object.
+ X509Certificate();
+ explicit X509Certificate(PP_Resource resource);
+ explicit X509Certificate(const InstanceHandle& instance);
+
+ // Returns true if the required interface is available.
+ static bool IsAvailable();
+
+ // Creates a new certificate from a DER-encoded representation. Returns true
+ // if the certificate was successfully created.
+ bool Initialize(const char* bytes, uint32_t length);
+ // Returns the specified field as a |Var|.
+ Var GetField(PP_X509Certificate_Private_Field field) const;
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_PRIVATE_X509_CERTIFICATE_PRIVATE_H_