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 |
index 6dacd4569207e6591bb5bba057388d44e3d802ce..7d4d34d4dd544049941d5b8315e36f305a6ff6ce 100644 |
--- a/net/ssl/client_cert_store_chromeos.cc |
+++ b/net/ssl/client_cert_store_chromeos.cc |
@@ -7,50 +7,16 @@ |
#include <cert.h> |
#include "base/bind.h" |
+#include "base/callback.h" |
#include "crypto/nss_crypto_module_delegate.h" |
-#include "crypto/nss_util_internal.h" |
namespace net { |
-namespace { |
- |
-typedef base::Callback<void(crypto::ScopedPK11Slot system_slot, |
- crypto::ScopedPK11Slot private_slot)> |
- GetSystemAndPrivateSlotCallback; |
- |
-// Gets the private slot for the user with the username hash |username_hash| and |
-// calls |callback| with both |system_slot| and the obtained private slot. |
-void GetPrivateSlotAndCallBack(const std::string& username_hash, |
- const GetSystemAndPrivateSlotCallback& callback, |
- crypto::ScopedPK11Slot system_slot) { |
- base::Callback<void(crypto::ScopedPK11Slot)> wrapped_callback = |
- base::Bind(callback, base::Passed(&system_slot)); |
- |
- crypto::ScopedPK11Slot slot( |
- crypto::GetPrivateSlotForChromeOSUser(username_hash, wrapped_callback)); |
- if (slot) |
- wrapped_callback.Run(slot.Pass()); |
-} |
- |
-// Gets the system slot, then the private slot for the user with the username |
-// hash |username_hash|, and finally calls |callback| with both slots. |
-void GetSystemAndPrivateSlot(const std::string& username_hash, |
- const GetSystemAndPrivateSlotCallback& callback) { |
- crypto::ScopedPK11Slot system_slot(crypto::GetSystemNSSKeySlot( |
- base::Bind(&GetPrivateSlotAndCallBack, username_hash, callback))); |
- if (system_slot) |
- GetPrivateSlotAndCallBack(username_hash, callback, system_slot.Pass()); |
-} |
- |
-} // namespace |
- |
ClientCertStoreChromeOS::ClientCertStoreChromeOS( |
- bool use_system_slot, |
- const std::string& username_hash, |
+ scoped_ptr<NSSProfileFilterChromeOSFactory> profile_filter_factory, |
const PasswordDelegateFactory& password_delegate_factory) |
: ClientCertStoreNSS(password_delegate_factory), |
- use_system_slot_(use_system_slot), |
- username_hash_(username_hash) { |
+ profile_filter_factory_(profile_filter_factory.Pass()) { |
} |
ClientCertStoreChromeOS::~ClientCertStoreChromeOS() {} |
@@ -59,8 +25,8 @@ void ClientCertStoreChromeOS::GetClientCerts( |
const SSLCertRequestInfo& cert_request_info, |
CertificateList* selected_certs, |
const base::Closure& callback) { |
- GetSystemAndPrivateSlotCallback bound_callback = |
- base::Bind(&ClientCertStoreChromeOS::DidGetSystemAndPrivateSlot, |
+ base::Callback<void(const NSSProfileFilterChromeOS&)> bound_callback = |
+ base::Bind(&ClientCertStoreChromeOS::DidGetProfileFilter, |
// Caller is responsible for keeping the ClientCertStore alive |
// until the callback is run. |
base::Unretained(this), |
@@ -68,13 +34,10 @@ void ClientCertStoreChromeOS::GetClientCerts( |
selected_certs, |
callback); |
- if (use_system_slot_) { |
- GetSystemAndPrivateSlot(username_hash_, bound_callback); |
- } else { |
- // Skip getting the system slot. |
- GetPrivateSlotAndCallBack( |
- username_hash_, bound_callback, crypto::ScopedPK11Slot()); |
- } |
+ scoped_ptr<NSSProfileFilterChromeOS> filter( |
+ profile_filter_factory_->CreateFilter(bound_callback)); |
+ if (filter) |
+ bound_callback.Run(*filter); |
} |
void ClientCertStoreChromeOS::GetClientCertsImpl( |
@@ -97,15 +60,12 @@ void ClientCertStoreChromeOS::GetClientCertsImpl( |
<< pre_size << " certs"; |
} |
-void ClientCertStoreChromeOS::DidGetSystemAndPrivateSlot( |
+void ClientCertStoreChromeOS::DidGetProfileFilter( |
const SSLCertRequestInfo* request, |
CertificateList* selected_certs, |
const base::Closure& callback, |
- crypto::ScopedPK11Slot system_slot, |
- crypto::ScopedPK11Slot private_slot) { |
- profile_filter_.Init(crypto::GetPublicSlotForChromeOSUser(username_hash_), |
- private_slot.Pass(), |
- system_slot.Pass()); |
+ const NSSProfileFilterChromeOS& profile_filter) { |
+ profile_filter_ = profile_filter; |
ClientCertStoreNSS::GetClientCerts(*request, selected_certs, callback); |
} |