OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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 #include "chrome/browser/chromeos/net/client_cert_store_cros.h" |
| 6 |
| 7 #include "base/barrier_closure.h" |
| 8 #include "base/bind.h" |
| 9 #include "crypto/scoped_nss_types.h" |
| 10 |
| 11 namespace chromeos { |
| 12 |
| 13 ClientCertStoreCros::ClientCertStoreCros(content::ResourceContext* context) { |
| 14 // There are two subtasks that must be completed before we can retrieve the |
| 15 // list of certs and filter them: initializing the filter, and getting the |
| 16 // SSLCertRequestInfo/etc from the GetClientCerts call. |
| 17 ready_to_get_certs_barrier_ = |
| 18 base::BarrierClosure(2, |
| 19 base::Bind(&ClientCertStoreCros::ReadyToGetCerts, |
| 20 base::Unretained(this))); |
| 21 |
| 22 // XXX Could remove the barrier if we moved this Init call into |
| 23 // GetClientCerts, but then we would have to save the |context| value ... |
| 24 profile_cert_filter_.Init(context, ready_to_get_certs_barrier_); |
| 25 } |
| 26 |
| 27 void ClientCertStoreCros::GetClientCerts( |
| 28 const net::SSLCertRequestInfo& cert_request_info, |
| 29 net::CertificateList* selected_certs, |
| 30 const base::Closure& callback) { |
| 31 cert_request_info_ = &cert_request_info; |
| 32 selected_certs_ = selected_certs; |
| 33 callback_ = callback; |
| 34 ready_to_get_certs_barrier_.Run(); |
| 35 } |
| 36 |
| 37 void ClientCertStoreCros::ReadyToGetCerts() { |
| 38 LOG(WARNING) << __func__; |
| 39 net_client_cert_store_impl_.GetClientCerts( |
| 40 *cert_request_info_, selected_certs_, |
| 41 base::Bind(&ClientCertStoreCros::GotClientCerts, |
| 42 base::Unretained(this))); |
| 43 } |
| 44 |
| 45 void ClientCertStoreCros::GotClientCerts(){ |
| 46 size_t pre_size = selected_certs_->size(); |
| 47 selected_certs_->erase( |
| 48 std::remove_if(selected_certs_->begin(), selected_certs_->end(), |
| 49 ProfileCertFilter::Predicate(profile_cert_filter_)), |
| 50 selected_certs_->end()); |
| 51 LOG(WARNING) << "filtered " << pre_size - selected_certs_->size() << " of " |
| 52 << pre_size << " certs"; |
| 53 |
| 54 callback_.Run(); |
| 55 } |
| 56 |
| 57 } // namespace chromeos |
OLD | NEW |