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 b80b6e0abd876151afd88f2702975817d6f466b0..0bd06e0de548ac04e9286051c147256d9875bb17 100644 |
--- a/chrome/browser/profiles/profile_io_data.cc |
+++ b/chrome/browser/profiles/profile_io_data.cc |
@@ -62,6 +62,7 @@ |
#include "content/public/browser/resource_context.h" |
#include "extensions/browser/info_map.h" |
#include "extensions/common/constants.h" |
+#include "net/base/keygen_handler.h" |
#include "net/cookies/canonical_cookie.h" |
#include "net/cookies/cookie_monster.h" |
#include "net/http/http_transaction_factory.h" |
@@ -102,7 +103,7 @@ |
#endif // defined(OS_CHROMEOS) |
#if defined(USE_NSS) |
-#include "chrome/browser/ui/crypto_module_password_dialog.h" |
+#include "chrome/browser/ui/crypto_module_delegate_nss.h" |
#include "net/ssl/client_cert_store_nss.h" |
#endif |
@@ -348,6 +349,14 @@ void StartNSSInitOnIOThread(const std::string& username, |
} |
#endif // defined(OS_CHROMEOS) |
+#if defined(USE_NSS) |
+void KeygenHandlerCallbackHelper( |
+ const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback, |
+ scoped_ptr<net::KeygenHandler>* keygen_handler) { |
+ callback.Run(keygen_handler->Pass()); |
+}; |
sky
2013/12/11 14:20:42
nit: no ;
mattm
2013/12/11 23:12:09
Done.
|
+#endif // defined(USE_NSS) |
+ |
} // namespace |
void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
@@ -832,7 +841,7 @@ scoped_ptr<net::ClientCertStore> |
ProfileIOData::ResourceContext::CreateClientCertStore() { |
#if defined(USE_NSS) |
return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS( |
- base::Bind(&chrome::NewCryptoModuleBlockingDialogDelegate, |
+ base::Bind(&CreateCryptoModuleBlockingPasswordDelegate, |
chrome::kCryptoModulePasswordClientAuth))); |
#elif defined(OS_WIN) |
return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreWin()); |
@@ -848,6 +857,47 @@ ProfileIOData::ResourceContext::CreateClientCertStore() { |
#endif |
} |
+scoped_ptr<net::KeygenHandler> |
+ProfileIOData::ResourceContext::CreateKeygenHandler( |
+ uint32 key_size_in_bits, |
+ const std::string& challenge_string, |
+ const GURL& url, |
+ const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback) { |
+ DCHECK(!callback.is_null()); |
+#if defined(USE_NSS) |
+ // Store the KeygenHandler scoped_ptr on the heap, which will be Owned by |
+ // the helper_callback below. This allows the KeygenHandler to be retrieved |
+ // and returned directly in the synchronous success case. |
+ scoped_ptr<net::KeygenHandler>* keygen_handler = |
+ new scoped_ptr<net::KeygenHandler>( |
+ new net::KeygenHandler(key_size_in_bits, challenge_string, url)); |
+ |
+ scoped_ptr<ChromeNSSCryptoModuleDelegate> delegate( |
+ new ChromeNSSCryptoModuleDelegate(chrome::kCryptoModulePasswordKeygen, |
+ url.host())); |
+ ChromeNSSCryptoModuleDelegate* delegate_ptr = delegate.get(); |
+ (*keygen_handler)->set_crypto_module_delegate( |
+ delegate.PassAs<crypto::NSSCryptoModuleDelegate>()); |
+ |
+ // Keep |helper_callback| on the stack, since ownership of |
+ // |keygen_handler| is transferred to |helper_callback|. This allows |
+ // |keygen_handler| to still be accessed if InitializeSlot returns with |
+ // synchronous success. |
+ base::Closure helper_callback = base::Bind( |
+ &KeygenHandlerCallbackHelper, callback, base::Owned(keygen_handler)); |
+ if (delegate_ptr->InitializeSlot(this, helper_callback)) { |
+ // Synchronous success, return the KeygenHandler directly. |
+ return keygen_handler->Pass(); |
+ } |
+ // The KeygenHandler will be passed to |callback| by |
+ // KeygenHandlerCallbackHelper. |
+ return scoped_ptr<net::KeygenHandler>(); |
+#else |
+ return scoped_ptr<net::KeygenHandler>( |
+ new net::KeygenHandler(key_size_in_bits, challenge_string, url)); |
+#endif |
+} |
+ |
bool ProfileIOData::ResourceContext::AllowMicAccess(const GURL& origin) { |
return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
} |