OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/net/client_cert_store_chromeos.h" | 5 #include "chrome/browser/chromeos/net/client_cert_store_chromeos.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 return !filter_->IsCertAllowed(cert); | 30 return !filter_->IsCertAllowed(cert); |
31 } | 31 } |
32 | 32 |
33 private: | 33 private: |
34 const ClientCertStoreChromeOS::CertFilter* const filter_; | 34 const ClientCertStoreChromeOS::CertFilter* const filter_; |
35 }; | 35 }; |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 ClientCertStoreChromeOS::ClientCertStoreChromeOS( | 39 ClientCertStoreChromeOS::ClientCertStoreChromeOS( |
40 scoped_ptr<CertificateProvider> cert_provider, | 40 std::unique_ptr<CertificateProvider> cert_provider, |
41 scoped_ptr<CertFilter> cert_filter, | 41 std::unique_ptr<CertFilter> cert_filter, |
42 const PasswordDelegateFactory& password_delegate_factory) | 42 const PasswordDelegateFactory& password_delegate_factory) |
43 : cert_provider_(std::move(cert_provider)), | 43 : cert_provider_(std::move(cert_provider)), |
44 cert_filter_(std::move(cert_filter)) {} | 44 cert_filter_(std::move(cert_filter)) {} |
45 | 45 |
46 ClientCertStoreChromeOS::~ClientCertStoreChromeOS() {} | 46 ClientCertStoreChromeOS::~ClientCertStoreChromeOS() {} |
47 | 47 |
48 void ClientCertStoreChromeOS::GetClientCerts( | 48 void ClientCertStoreChromeOS::GetClientCerts( |
49 const net::SSLCertRequestInfo& cert_request_info, | 49 const net::SSLCertRequestInfo& cert_request_info, |
50 net::CertificateList* selected_certs, | 50 net::CertificateList* selected_certs, |
51 const base::Closure& callback) { | 51 const base::Closure& callback) { |
(...skipping 16 matching lines...) Expand all Loading... |
68 | 68 |
69 if (cert_filter_->Init(get_additional_certs_and_continue)) | 69 if (cert_filter_->Init(get_additional_certs_and_continue)) |
70 get_additional_certs_and_continue.Run(); | 70 get_additional_certs_and_continue.Run(); |
71 } | 71 } |
72 | 72 |
73 void ClientCertStoreChromeOS::GotAdditionalCerts( | 73 void ClientCertStoreChromeOS::GotAdditionalCerts( |
74 const net::SSLCertRequestInfo* request, | 74 const net::SSLCertRequestInfo* request, |
75 net::CertificateList* selected_certs, | 75 net::CertificateList* selected_certs, |
76 const base::Closure& callback, | 76 const base::Closure& callback, |
77 const net::CertificateList& additional_certs) { | 77 const net::CertificateList& additional_certs) { |
78 scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate> password_delegate; | 78 std::unique_ptr<crypto::CryptoModuleBlockingPasswordDelegate> |
| 79 password_delegate; |
79 if (!password_delegate_factory_.is_null()) { | 80 if (!password_delegate_factory_.is_null()) { |
80 password_delegate.reset( | 81 password_delegate.reset( |
81 password_delegate_factory_.Run(request->host_and_port)); | 82 password_delegate_factory_.Run(request->host_and_port)); |
82 } | 83 } |
83 if (base::WorkerPool::PostTaskAndReply( | 84 if (base::WorkerPool::PostTaskAndReply( |
84 FROM_HERE, | 85 FROM_HERE, |
85 base::Bind(&ClientCertStoreChromeOS::GetAndFilterCertsOnWorkerThread, | 86 base::Bind(&ClientCertStoreChromeOS::GetAndFilterCertsOnWorkerThread, |
86 base::Unretained(this), base::Passed(&password_delegate), | 87 base::Unretained(this), base::Passed(&password_delegate), |
87 request, additional_certs, selected_certs), | 88 request, additional_certs, selected_certs), |
88 callback, true)) { | 89 callback, true)) { |
89 return; | 90 return; |
90 } | 91 } |
91 // If the task could not be posted, behave as if there were no certificates | 92 // If the task could not be posted, behave as if there were no certificates |
92 // which requires to clear |selected_certs|. | 93 // which requires to clear |selected_certs|. |
93 selected_certs->clear(); | 94 selected_certs->clear(); |
94 callback.Run(); | 95 callback.Run(); |
95 } | 96 } |
96 | 97 |
97 void ClientCertStoreChromeOS::GetAndFilterCertsOnWorkerThread( | 98 void ClientCertStoreChromeOS::GetAndFilterCertsOnWorkerThread( |
98 scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate> password_delegate, | 99 std::unique_ptr<crypto::CryptoModuleBlockingPasswordDelegate> |
| 100 password_delegate, |
99 const net::SSLCertRequestInfo* request, | 101 const net::SSLCertRequestInfo* request, |
100 const net::CertificateList& additional_certs, | 102 const net::CertificateList& additional_certs, |
101 net::CertificateList* selected_certs) { | 103 net::CertificateList* selected_certs) { |
102 net::CertificateList unfiltered_certs; | 104 net::CertificateList unfiltered_certs; |
103 net::ClientCertStoreNSS::GetPlatformCertsOnWorkerThread( | 105 net::ClientCertStoreNSS::GetPlatformCertsOnWorkerThread( |
104 std::move(password_delegate), &unfiltered_certs); | 106 std::move(password_delegate), &unfiltered_certs); |
105 | 107 |
106 unfiltered_certs.erase( | 108 unfiltered_certs.erase( |
107 std::remove_if(unfiltered_certs.begin(), unfiltered_certs.end(), | 109 std::remove_if(unfiltered_certs.begin(), unfiltered_certs.end(), |
108 CertNotAllowedPredicate(cert_filter_.get())), | 110 CertNotAllowedPredicate(cert_filter_.get())), |
109 unfiltered_certs.end()); | 111 unfiltered_certs.end()); |
110 | 112 |
111 unfiltered_certs.insert(unfiltered_certs.end(), additional_certs.begin(), | 113 unfiltered_certs.insert(unfiltered_certs.end(), additional_certs.begin(), |
112 additional_certs.end()); | 114 additional_certs.end()); |
113 | 115 |
114 net::ClientCertStoreNSS::FilterCertsOnWorkerThread(unfiltered_certs, *request, | 116 net::ClientCertStoreNSS::FilterCertsOnWorkerThread(unfiltered_certs, *request, |
115 selected_certs); | 117 selected_certs); |
116 } | 118 } |
117 | 119 |
118 } // namespace chromeos | 120 } // namespace chromeos |
OLD | NEW |