1 // Copyright 2015 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.
5 #import "ios/web/net/crw_cert_policy_cache.h"
7 #include "base/location.h"
8 #include "base/mac/bind_objc_block.h"
9 #include "base/strings/sys_string_conversions.h"
10 #include "ios/web/public/certificate_policy_cache.h"
11 #include "ios/web/public/web_thread.h"
13 @interface CRWCertPolicyCache () {
14 // Used to remember decisions about how to handle problematic certs.
15 scoped_refptr<web::CertificatePolicyCache> _impl;
19 @implementation CRWCertPolicyCache
21 - (instancetype)init {
26 - (instancetype)initWithCache:(scoped_refptr<web::CertificatePolicyCache>)impl {
35 - (void)queryJudgementForCert:(scoped_refptr<net::X509Certificate>)cert
36 forHost:(NSString*)host
37 status:(net::CertStatus)status
38 completionHandler:(void (^)(web::CertPolicy::Judgment))handler {
40 web::WebThread::PostTask(web::WebThread::IO, FROM_HERE, base::BindBlock(^{
41 web::CertPolicy::Judgment policy =
42 _impl->QueryPolicy(cert.get(), base::SysNSStringToUTF8(host), status);
43 dispatch_async(dispatch_get_main_queue(), ^{
49 - (void)allowCert:(scoped_refptr<net::X509Certificate>)cert
50 forHost:(NSString*)host
51 status:(net::CertStatus)status {
52 web::WebThread::PostTask(web::WebThread::IO, FROM_HERE, base::BindBlock(^{
53 _impl->AllowCertForHost(cert.get(), base::SysNSStringToUTF8(host), status);