OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ssl/ssl_client_auth_requestor_mock.h" | 5 #include "chrome/browser/ssl/ssl_client_auth_requestor_mock.h" |
6 | 6 |
| 7 #include "base/macros.h" |
| 8 #include "content/public/browser/client_certificate_delegate.h" |
7 #include "net/ssl/ssl_cert_request_info.h" | 9 #include "net/ssl/ssl_cert_request_info.h" |
8 #include "net/url_request/url_request.h" | 10 #include "net/url_request/url_request.h" |
9 | 11 |
| 12 namespace { |
| 13 |
| 14 class FakeClientCertificateDelegate |
| 15 : public content::ClientCertificateDelegate { |
| 16 public: |
| 17 explicit FakeClientCertificateDelegate(SSLClientAuthRequestorMock* requestor) |
| 18 : requestor_(requestor) {} |
| 19 |
| 20 ~FakeClientCertificateDelegate() override { |
| 21 if (requestor_) |
| 22 requestor_->CancelCertificateSelection(); |
| 23 } |
| 24 |
| 25 // content::ClientCertificateDelegate implementation: |
| 26 void ContinueWithCertificate(net::X509Certificate* cert) override { |
| 27 requestor_->CertificateSelected(cert); |
| 28 requestor_ = nullptr; |
| 29 } |
| 30 |
| 31 private: |
| 32 scoped_refptr<SSLClientAuthRequestorMock> requestor_; |
| 33 |
| 34 DISALLOW_COPY_AND_ASSIGN(FakeClientCertificateDelegate); |
| 35 }; |
| 36 |
| 37 } // namespace |
| 38 |
10 SSLClientAuthRequestorMock::SSLClientAuthRequestorMock( | 39 SSLClientAuthRequestorMock::SSLClientAuthRequestorMock( |
11 net::URLRequest* request, | 40 net::URLRequest* request, |
12 const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info) | 41 const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info) |
13 : cert_request_info_(cert_request_info) { | 42 : cert_request_info_(cert_request_info) { |
14 } | 43 } |
15 | 44 |
16 SSLClientAuthRequestorMock::~SSLClientAuthRequestorMock() {} | 45 SSLClientAuthRequestorMock::~SSLClientAuthRequestorMock() {} |
| 46 |
| 47 scoped_ptr<content::ClientCertificateDelegate> |
| 48 SSLClientAuthRequestorMock::CreateDelegate() { |
| 49 return make_scoped_ptr(new FakeClientCertificateDelegate(this)); |
| 50 } |
OLD | NEW |