Index: net/ssl/client_cert_store_chromeos.cc |
diff --git a/net/ssl/client_cert_store_chromeos.cc b/net/ssl/client_cert_store_chromeos.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6cd88c7c3e675a34e55d90b9801e95fed964235d |
--- /dev/null |
+++ b/net/ssl/client_cert_store_chromeos.cc |
@@ -0,0 +1,59 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "net/ssl/client_cert_store_chromeos.h" |
+ |
+#include "base/bind.h" |
+#include "crypto/nss_util_internal.h" |
+ |
+namespace net { |
+ |
+ClientCertStoreChromeOS::ClientCertStoreChromeOS( |
+ const std::string& username_hash) |
+ : username_hash_(username_hash) {} |
+ |
+ClientCertStoreChromeOS::~ClientCertStoreChromeOS() {} |
+ |
+void ClientCertStoreChromeOS::GetClientCerts( |
+ const SSLCertRequestInfo& cert_request_info, |
+ CertificateList* selected_certs, |
+ const base::Closure& callback) { |
+ cert_request_info_ = &cert_request_info; |
+ selected_certs_ = selected_certs; |
+ callback_ = callback; |
+ |
+ crypto::ScopedPK11Slot private_slot(crypto::GetPrivateSlotForChromeOSUser( |
+ username_hash_, |
+ base::Bind(&ClientCertStoreChromeOS::DidGetPrivateSlot, |
+ base::Unretained(this)))); |
+ if (private_slot) |
+ DidGetPrivateSlot(private_slot.Pass()); |
+} |
+ |
+void ClientCertStoreChromeOS::DidGetPrivateSlot( |
+ crypto::ScopedPK11Slot private_slot) { |
+ DVLOG(1) << __func__; |
+ profile_filter_.Init(crypto::GetPublicSlotForChromeOSUser(username_hash_), |
+ private_slot.Pass()); |
+ ClientCertStoreImpl::GetClientCerts( |
+ *cert_request_info_, |
+ selected_certs_, |
+ base::Bind(&ClientCertStoreChromeOS::GotClientCerts, |
+ base::Unretained(this))); |
+} |
+ |
+void ClientCertStoreChromeOS::GotClientCerts() { |
+ size_t pre_size = selected_certs_->size(); |
+ selected_certs_->erase( |
+ std::remove_if(selected_certs_->begin(), |
+ selected_certs_->end(), |
+ NSSProfileFilterChromeOS::Predicate(profile_filter_)), |
+ selected_certs_->end()); |
+ DVLOG(1) << "filtered " << pre_size - selected_certs_->size() << " of " |
+ << pre_size << " certs"; |
+ |
+ callback_.Run(); |
+} |
+ |
+} // namespace net |