1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_
6 #define CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
15 class CryptoModuleBlockingPasswordDelegate
;
20 typedef std::vector
<scoped_refptr
<CryptoModule
> > CryptoModuleList
;
21 class X509Certificate
;
26 // An enum to describe the reason for the password request.
27 enum CryptoModulePasswordReason
{
28 kCryptoModulePasswordKeygen
,
29 kCryptoModulePasswordCertEnrollment
,
30 kCryptoModulePasswordClientAuth
,
31 kCryptoModulePasswordListCerts
,
32 kCryptoModulePasswordCertImport
,
33 kCryptoModulePasswordCertExport
,
36 typedef base::Callback
<void(const char*)> CryptoModulePasswordCallback
;
38 // Display a dialog, prompting the user to authenticate to unlock
39 // |module|. |reason| describes the purpose of the authentication and
40 // affects the message displayed in the dialog. |server| is the name
41 // of the server which requested the access.
42 void ShowCryptoModulePasswordDialog(
43 const std::string
& module_name
,
45 CryptoModulePasswordReason reason
,
46 const std::string
& server
,
47 const CryptoModulePasswordCallback
& callback
);
49 // Returns a CryptoModuleBlockingPasswordDelegate to open a dialog and block
50 // until returning. Should only be used on a worker thread.
51 crypto::CryptoModuleBlockingPasswordDelegate
*
52 NewCryptoModuleBlockingDialogDelegate(CryptoModulePasswordReason reason
,
53 const std::string
& server
);
55 // Asynchronously unlock |modules|, if necessary. |callback| is called when
56 // done (regardless if any modules were successfully unlocked or not). Should
57 // only be called on UI thread.
58 void UnlockSlotsIfNecessary(const net::CryptoModuleList
& modules
,
59 CryptoModulePasswordReason reason
,
60 const std::string
& server
,
61 const base::Closure
& callback
);
63 // Asynchronously unlock the |cert|'s module, if necessary. |callback| is
64 // called when done (regardless if module was successfully unlocked or not).
65 // Should only be called on UI thread.
66 void UnlockCertSlotIfNecessary(net::X509Certificate
* cert
,
67 CryptoModulePasswordReason reason
,
68 const std::string
& server
,
69 const base::Closure
& callback
);
73 #endif // CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_