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

Unified Diff: chrome/browser/profiles/profile_io_data.cc

Issue 384413004: Remove default key slot from KeygenHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compilation, addressed suggestions. Created 6 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/ui/crypto_module_delegate_nss.h » ('j') | net/base/keygen_handler.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_io_data.cc
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index dcf3bcf9d593e80c22e8e293bff942b704ac5f2a..69a2bbd627c32fae9c28f634f1dfe5c02314e6fb 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -41,6 +41,7 @@
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/net/chrome_network_delegate.h"
#include "chrome/browser/net/cookie_store_util.h"
+#include "chrome/browser/net/nss_context.h"
#include "chrome/browser/net/proxy_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -317,6 +318,22 @@ void StartNSSInitOnIOThread(const std::string& username,
}
#endif // defined(OS_CHROMEOS)
+#if defined(USE_NSS)
+void CreateKeygenHandlerWithSlot(
+ const GURL& url,
+ const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback,
+ scoped_ptr<net::KeygenHandler> keygen_handler,
+ crypto::ScopedPK11Slot slot) {
+ scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate> delegate(
+ new ChromeNSSCryptoModuleDelegate(chrome::kCryptoModulePasswordKeygen,
+ net::HostPortPair::FromURL(url)));
+ keygen_handler->set_crypto_module_delegate(delegate.Pass());
+ keygen_handler->set_key_slot(slot.get());
+
+ callback.Run(keygen_handler.Pass());
+}
+#endif // defined(USE_NSS)
+
} // namespace
void ProfileIOData::InitializeOnUIThread(Profile* profile) {
@@ -908,21 +925,22 @@ void ProfileIOData::ResourceContext::CreateKeygenHandler(
scoped_ptr<net::KeygenHandler> keygen_handler(
new net::KeygenHandler(key_size_in_bits, challenge_string, url));
- scoped_ptr<ChromeNSSCryptoModuleDelegate> delegate(
- new ChromeNSSCryptoModuleDelegate(chrome::kCryptoModulePasswordKeygen,
- net::HostPortPair::FromURL(url)));
- ChromeNSSCryptoModuleDelegate* delegate_ptr = delegate.get();
- keygen_handler->set_crypto_module_delegate(
- delegate.PassAs<crypto::NSSCryptoModuleDelegate>());
-
- base::Closure bound_callback =
- base::Bind(callback, base::Passed(&keygen_handler));
- if (delegate_ptr->InitializeSlot(this, bound_callback)) {
- // Initialization complete, run the callback synchronously.
- bound_callback.Run();
+ base::Callback<void(crypto::ScopedPK11Slot)> get_slot_callback =
+ base::Bind(&CreateKeygenHandlerWithSlot,
+ url,
+ callback,
+ base::Passed(&keygen_handler));
+
+ crypto::ScopedPK11Slot slot =
+ GetPrivateNSSKeySlotForResourceContext(this, get_slot_callback);
+
+ if (slot) {
+ // Obtained the slot synchronously, run the callback synchronously.
+ get_slot_callback.Run(slot.Pass());
return;
}
- // Otherwise, the InitializeSlot will run the callback asynchronously.
+ // Otherwise, GetPrivateNSSKeySlotForResourceContext will run the callback
+ // asynchronously.
#else
callback.Run(make_scoped_ptr(
new net::KeygenHandler(key_size_in_bits, challenge_string, url)));
« no previous file with comments | « no previous file | chrome/browser/ui/crypto_module_delegate_nss.h » ('j') | net/base/keygen_handler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698