| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/callback.h" |
| 5 #include "content/test/mock_ssl_host_state_delegate.h" | 6 #include "content/test/mock_ssl_host_state_delegate.h" |
| 6 | 7 |
| 7 namespace content { | 8 namespace content { |
| 8 | 9 |
| 9 MockSSLHostStateDelegate::MockSSLHostStateDelegate() {} | 10 MockSSLHostStateDelegate::MockSSLHostStateDelegate() {} |
| 10 | 11 |
| 11 MockSSLHostStateDelegate::~MockSSLHostStateDelegate() {} | 12 MockSSLHostStateDelegate::~MockSSLHostStateDelegate() {} |
| 12 | 13 |
| 13 void MockSSLHostStateDelegate::AllowCert(const std::string& host, | 14 void MockSSLHostStateDelegate::AllowCert(const std::string& host, |
| 14 const net::X509Certificate& cert, | 15 const net::X509Certificate& cert, |
| 15 net::CertStatus error) { | 16 net::CertStatus error) { |
| 16 exceptions_.insert(host); | 17 exceptions_.insert(host); |
| 17 } | 18 } |
| 18 | 19 |
| 19 void MockSSLHostStateDelegate::Clear() { | 20 void MockSSLHostStateDelegate::Clear( |
| 20 exceptions_.clear(); | 21 const base::Callback<bool(const std::string&)>& host_filter) { |
| 22 if (host_filter.is_null()) { |
| 23 exceptions_.clear(); |
| 24 } else { |
| 25 for (auto it = exceptions_.begin(); it != exceptions_.end();) { |
| 26 auto next_it = std::next(it); |
| 27 |
| 28 if (host_filter.Run(*it)) |
| 29 exceptions_.erase(it); |
| 30 |
| 31 it = next_it; |
| 32 } |
| 33 } |
| 21 } | 34 } |
| 22 | 35 |
| 23 SSLHostStateDelegate::CertJudgment MockSSLHostStateDelegate::QueryPolicy( | 36 SSLHostStateDelegate::CertJudgment MockSSLHostStateDelegate::QueryPolicy( |
| 24 const std::string& host, | 37 const std::string& host, |
| 25 const net::X509Certificate& cert, | 38 const net::X509Certificate& cert, |
| 26 net::CertStatus error, | 39 net::CertStatus error, |
| 27 bool* expired_previous_decision) { | 40 bool* expired_previous_decision) { |
| 28 if (exceptions_.find(host) == exceptions_.end()) | 41 if (exceptions_.find(host) == exceptions_.end()) |
| 29 return SSLHostStateDelegate::DENIED; | 42 return SSLHostStateDelegate::DENIED; |
| 30 | 43 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 47 const std::string& host) { | 60 const std::string& host) { |
| 48 exceptions_.erase(exceptions_.find(host)); | 61 exceptions_.erase(exceptions_.find(host)); |
| 49 } | 62 } |
| 50 | 63 |
| 51 bool MockSSLHostStateDelegate::HasAllowException( | 64 bool MockSSLHostStateDelegate::HasAllowException( |
| 52 const std::string& host) const { | 65 const std::string& host) const { |
| 53 return exceptions_.find(host) != exceptions_.end(); | 66 return exceptions_.find(host) != exceptions_.end(); |
| 54 } | 67 } |
| 55 | 68 |
| 56 } // namespace content | 69 } // namespace content |
| OLD | NEW |