1 // Copyright 2017 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 IOS_WEB_SESSION_SESSION_CERTIFICATE_POLICY_CACHE_IMPL_H_
6 #define IOS_WEB_SESSION_SESSION_CERTIFICATE_POLICY_CACHE_IMPL_H_
7 
8 #import <Foundation/Foundation.h>
9 
10 #include "ios/web/public/session/session_certificate_policy_cache.h"
11 
12 namespace net {
13 class X509Certificate;
14 }
15 
16 namespace web {
17 
18 // Concrete implementation of SessionCertificatePolicyCache.
19 class SessionCertificatePolicyCacheImpl : public SessionCertificatePolicyCache {
20  public:
21   SessionCertificatePolicyCacheImpl(BrowserState* browser_state);
22   ~SessionCertificatePolicyCacheImpl() override;
23 
24   // SessionCertificatePolicyCache:
25   void UpdateCertificatePolicyCache(
26       const scoped_refptr<web::CertificatePolicyCache>& cache) const override;
27   void RegisterAllowedCertificate(
28       scoped_refptr<net::X509Certificate> certificate,
29       const std::string& host,
30       net::CertStatus status) override;
31 
32   // Allows for batch updating the allowed certificate storages.
33   void SetAllowedCerts(NSSet* allowed_certs);
34   NSSet* GetAllowedCerts() const;
35 
36  private:
37   // An set of CRWSessionCertificateStorages representing allowed certs.
38   NSMutableSet* allowed_certs_;
39 
40   DISALLOW_COPY_AND_ASSIGN(SessionCertificatePolicyCacheImpl);
41 };
42 
43 }  // namespace web
44 
45 #endif  // IOS_WEB_SESSION_SESSION_CERTIFICATE_POLICY_CACHE_IMPL_H_
46