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 e50779ce5fb9da6df15836c34fc522493e7cec96..ef1bda1a6125831660e20cccc82ae06e303d429c 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" |
@@ -103,7 +104,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" |
#endif |
using content::BrowserContext; |
@@ -340,6 +341,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()); |
+}; |
+#endif // defined(USE_NSS) |
+ |
} // namespace |
void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
@@ -826,7 +835,7 @@ ProfileIOData::ResourceContext::CreateClientCertStore() { |
scoped_ptr<net::ClientCertStoreImpl> store(new net::ClientCertStoreImpl()); |
#if defined(USE_NSS) |
store->set_password_delegate_factory( |
- base::Bind(&chrome::NewCryptoModuleBlockingDialogDelegate, |
+ base::Bind(&CreateCryptoModuleBlockingPasswordDelegate, |
chrome::kCryptoModulePasswordClientAuth)); |
#endif |
return store.PassAs<net::ClientCertStore>(); |
@@ -838,6 +847,44 @@ 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) |
+ scoped_ptr<net::KeygenHandler>* keygen_handler = |
sky
2013/12/11 00:26:00
Can't you use a scoped_ptr rather than scoped_ptr*
mattm
2013/12/11 01:10:46
see the comment on line 869, I'll add a comment he
sky
2013/12/11 14:20:42
I thought base::Passed(XXX) was the preferred way
|
+ 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); |
} |