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_chromeos.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "content/public/browser/nss_context.h" |
| 9 |
| 10 namespace chromeos { |
| 11 |
| 12 ClientCertStoreChromeOS::ClientCertStoreChromeOS( |
| 13 content::ResourceContext* context) |
| 14 : context_(context) {} |
| 15 |
| 16 ClientCertStoreChromeOS::~ClientCertStoreChromeOS() {} |
| 17 |
| 18 void ClientCertStoreChromeOS::GetClientCerts( |
| 19 const net::SSLCertRequestInfo& cert_request_info, |
| 20 net::CertificateList* selected_certs, |
| 21 const base::Closure& callback) { |
| 22 cert_request_info_ = &cert_request_info; |
| 23 selected_certs_ = selected_certs; |
| 24 callback_ = callback; |
| 25 |
| 26 content::OnNSSKeySlotsForResourceContextReady( |
| 27 context_, |
| 28 base::Bind(&ClientCertStoreChromeOS::DidGetSlots, |
| 29 base::Unretained(this))); |
| 30 } |
| 31 |
| 32 void ClientCertStoreChromeOS::DidGetSlots(crypto::ScopedPK11Slot public_slot, |
| 33 crypto::ScopedPK11Slot private_slot) { |
| 34 VLOG(1) << __func__; |
| 35 profile_filter_.Init(public_slot.Pass(), private_slot.Pass()); |
| 36 net_client_cert_store_impl_.GetClientCerts( |
| 37 *cert_request_info_, selected_certs_, |
| 38 base::Bind(&ClientCertStoreChromeOS::GotClientCerts, |
| 39 base::Unretained(this))); |
| 40 } |
| 41 |
| 42 void ClientCertStoreChromeOS::GotClientCerts(){ |
| 43 size_t pre_size = selected_certs_->size(); |
| 44 selected_certs_->erase( |
| 45 std::remove_if(selected_certs_->begin(), |
| 46 selected_certs_->end(), |
| 47 net::NSSProfileFilterChromeOS::Predicate(profile_filter_)), |
| 48 selected_certs_->end()); |
| 49 VLOG(1) << "filtered " << pre_size - selected_certs_->size() << " of " |
| 50 << pre_size << " certs"; |
| 51 |
| 52 callback_.Run(); |
| 53 } |
| 54 |
| 55 } // namespace chromeos |
OLD | NEW |