Update V8 to version 4.6.61.
[chromium-blink-merge.git] / ios / web / net / crw_cert_policy_cache.mm
blobb080a377ef2a03a3ba49c74f01a3194e26e30436
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;
17 @end
19 @implementation CRWCertPolicyCache
21 - (instancetype)init {
22   NOTREACHED();
23   return self;
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;
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   }));
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   }));
57 @end