1 // Copyright (c) 2012 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/x509_certificate_private.h" 6 7 #include "ppapi/cpp/module_impl.h" 8 #include "ppapi/cpp/pass_ref.h" 9 #include "ppapi/cpp/var.h" 10 11 namespace pp { 12 13 namespace { 14 interface_name()15template <> const char* interface_name<PPB_X509Certificate_Private_0_1>() { 16 return PPB_X509CERTIFICATE_PRIVATE_INTERFACE_0_1; 17 } 18 19 } // namespace 20 X509CertificatePrivate()21X509CertificatePrivate::X509CertificatePrivate() : Resource() {} 22 X509CertificatePrivate(PassRef,PP_Resource resource)23X509CertificatePrivate::X509CertificatePrivate(PassRef, PP_Resource resource) 24 : Resource(PASS_REF, resource) { 25 } 26 X509CertificatePrivate(const InstanceHandle & instance)27X509CertificatePrivate::X509CertificatePrivate(const InstanceHandle& instance) { 28 if (has_interface<PPB_X509Certificate_Private_0_1>()) { 29 PassRefFromConstructor(get_interface<PPB_X509Certificate_Private_0_1>()-> 30 Create(instance.pp_instance())); 31 } 32 } 33 34 // static IsAvailable()35bool X509CertificatePrivate::IsAvailable() { 36 return has_interface<PPB_X509Certificate_Private_0_1>(); 37 } 38 Initialize(const char * bytes,uint32_t length)39bool X509CertificatePrivate::Initialize(const char* bytes, uint32_t length) { 40 if (!has_interface<PPB_X509Certificate_Private_0_1>()) 41 return false; 42 PP_Bool result = get_interface<PPB_X509Certificate_Private_0_1>()->Initialize( 43 pp_resource(), 44 bytes, 45 length); 46 return PP_ToBool(result); 47 } 48 GetField(PP_X509Certificate_Private_Field field) const49Var X509CertificatePrivate::GetField( 50 PP_X509Certificate_Private_Field field) const { 51 if (!has_interface<PPB_X509Certificate_Private_0_1>()) 52 return Var(); 53 return Var(PassRef(), 54 get_interface<PPB_X509Certificate_Private_0_1>()->GetField(pp_resource(), 55 field)); 56 } 57 58 } // namespace pp 59