| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #import "ios/web/net/crw_cert_policy_cache.h" | |
| 6 | |
| 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" | |
| 12 | |
| 13 @interface CRWCertPolicyCache () { | |
| 14 // Used to remember decisions about how to handle problematic certs. | |
| 15 scoped_refptr<web::CertificatePolicyCache> _impl; | |
| 16 } | |
| 17 @end | |
| 18 | |
| 19 @implementation CRWCertPolicyCache | |
| 20 | |
| 21 - (instancetype)init { | |
| 22 NOTREACHED(); | |
| 23 return self; | |
| 24 } | |
| 25 | |
| 26 - (instancetype)initWithCache:(scoped_refptr<web::CertificatePolicyCache>)impl { | |
| 27 DCHECK(impl); | |
| 28 self = [super init]; | |
| 29 if (self) { | |
| 30 _impl = impl; | |
| 31 } | |
| 32 return self; | |
| 33 } | |
| 34 | |
| 35 - (void)queryJudgementForCert:(scoped_refptr<net::X509Certificate>)cert | |
| 36 forHost:(NSString*)host | |
| 37 status:(net::CertStatus)status | |
| 38 completionHandler:(void (^)(web::CertPolicy::Judgment))handler { | |
| 39 DCHECK(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(), ^{ | |
| 44 handler(policy); | |
| 45 }); | |
| 46 })); | |
| 47 } | |
| 48 | |
| 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); | |
| 54 })); | |
| 55 } | |
| 56 | |
| 57 @end | |
| OLD | NEW |