Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(909)

Unified Diff: net/ssl/client_cert_store_chromeos.cc

Issue 419013003: Replace c/b/nss_context by a KeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added cert_database namespace. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}
« net/ssl/client_cert_store_chromeos.h ('K') | « net/ssl/client_cert_store_chromeos.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698