1// Copyright (c) 2010 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#ifndef NET_BASE_ANDROID_NETWORK_LIBRARY_H_ 6#define NET_BASE_ANDROID_NETWORK_LIBRARY_H_ 7#pragma once 8 9#include <string> 10#include <vector> 11 12#include "base/basictypes.h" 13#include "net/base/net_export.h" 14 15namespace net { 16 17class NET_EXPORT AndroidNetworkLibrary { 18 public: 19 static void RegisterSharedInstance(AndroidNetworkLibrary* lib); 20 static void UnregisterSharedInstance(); 21 static AndroidNetworkLibrary* GetSharedInstance(); 22 23 enum VerifyResult { 24 VERIFY_OK, 25 VERIFY_BAD_HOSTNAME, 26 VERIFY_NO_TRUSTED_ROOT, 27 VERIFY_INVOCATION_ERROR, 28 }; 29 // |cert_chain| is DER encoded chain of certificates, with the server's own 30 // certificate listed first. 31 // |hostname| is validated against the supplied cert. |auth_type| is as per 32 // the Java X509Certificate.checkServerTrusted method. 33 virtual VerifyResult VerifyX509CertChain( 34 const std::vector<std::string>& cert_chain, 35 const std::string& hostname, 36 const std::string& auth_type) = 0; 37 38 protected: 39 friend class LibHolder; 40 AndroidNetworkLibrary(); 41 virtual ~AndroidNetworkLibrary(); // use UnregisterSharedInstance() 42 43 DISALLOW_COPY_AND_ASSIGN(AndroidNetworkLibrary); 44}; 45 46} // namespace net 47 48#endif // NET_BASE_ANDROID_NETWORK_LIBRARY_H_ 49