Index: chrome/browser/chromeos/net/client_cert_store_cros.cc |
diff --git a/chrome/browser/chromeos/net/client_cert_store_cros.cc b/chrome/browser/chromeos/net/client_cert_store_cros.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f8e06d3084d73c6a870dd23fa6888b103948327b |
--- /dev/null |
+++ b/chrome/browser/chromeos/net/client_cert_store_cros.cc |
@@ -0,0 +1,57 @@ |
+// 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 "chrome/browser/chromeos/net/client_cert_store_cros.h" |
+ |
+#include "base/barrier_closure.h" |
+#include "base/bind.h" |
+#include "crypto/scoped_nss_types.h" |
+ |
+namespace chromeos { |
+ |
+ClientCertStoreCros::ClientCertStoreCros(content::ResourceContext* context) { |
+ // There are two subtasks that must be completed before we can retrieve the |
+ // list of certs and filter them: initializing the filter, and getting the |
+ // SSLCertRequestInfo/etc from the GetClientCerts call. |
+ ready_to_get_certs_barrier_ = |
+ base::BarrierClosure(2, |
+ base::Bind(&ClientCertStoreCros::ReadyToGetCerts, |
+ base::Unretained(this))); |
+ |
+ // XXX Could remove the barrier if we moved this Init call into |
+ // GetClientCerts, but then we would have to save the |context| value ... |
+ profile_cert_filter_.Init(context, ready_to_get_certs_barrier_); |
+} |
+ |
+void ClientCertStoreCros::GetClientCerts( |
+ const net::SSLCertRequestInfo& cert_request_info, |
+ net::CertificateList* selected_certs, |
+ const base::Closure& callback) { |
+ cert_request_info_ = &cert_request_info; |
+ selected_certs_ = selected_certs; |
+ callback_ = callback; |
+ ready_to_get_certs_barrier_.Run(); |
+} |
+ |
+void ClientCertStoreCros::ReadyToGetCerts() { |
+ LOG(WARNING) << __func__; |
+ net_client_cert_store_impl_.GetClientCerts( |
+ *cert_request_info_, selected_certs_, |
+ base::Bind(&ClientCertStoreCros::GotClientCerts, |
+ base::Unretained(this))); |
+} |
+ |
+void ClientCertStoreCros::GotClientCerts(){ |
+ size_t pre_size = selected_certs_->size(); |
+ selected_certs_->erase( |
+ std::remove_if(selected_certs_->begin(), selected_certs_->end(), |
+ ProfileCertFilter::Predicate(profile_cert_filter_)), |
+ selected_certs_->end()); |
+ LOG(WARNING) << "filtered " << pre_size - selected_certs_->size() << " of " |
+ << pre_size << " certs"; |
+ |
+ callback_.Run(); |
+} |
+ |
+} // namespace chromeos |