OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_ | 5 #ifndef CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_NSS_H_ |
6 #define CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_ | 6 #define CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_NSS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback_forward.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "chrome/browser/ui/crypto_module_password_dialog.h" |
13 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
14 | 15 |
15 namespace crypto { | |
16 class CryptoModuleBlockingPasswordDelegate; | |
17 } | |
18 | |
19 namespace net { | 16 namespace net { |
20 class CryptoModule; | 17 class CryptoModule; |
21 typedef std::vector<scoped_refptr<CryptoModule> > CryptoModuleList; | 18 typedef std::vector<scoped_refptr<CryptoModule> > CryptoModuleList; |
22 class X509Certificate; | 19 class X509Certificate; |
23 } | 20 } |
24 | 21 |
25 namespace chrome { | 22 namespace chrome { |
26 | 23 |
27 // An enum to describe the reason for the password request. | |
28 enum CryptoModulePasswordReason { | |
29 kCryptoModulePasswordKeygen, | |
30 kCryptoModulePasswordCertEnrollment, | |
31 kCryptoModulePasswordClientAuth, | |
32 kCryptoModulePasswordListCerts, | |
33 kCryptoModulePasswordCertImport, | |
34 kCryptoModulePasswordCertExport, | |
35 }; | |
36 | |
37 typedef base::Callback<void(const char*)> CryptoModulePasswordCallback; | |
38 | |
39 // Display a dialog, prompting the user to authenticate to unlock | |
40 // |module|. |reason| describes the purpose of the authentication and | |
41 // affects the message displayed in the dialog. |server| is the name | |
42 // of the server which requested the access. | |
43 void ShowCryptoModulePasswordDialog( | |
44 const std::string& module_name, | |
45 bool retry, | |
46 CryptoModulePasswordReason reason, | |
47 const std::string& server, | |
48 gfx::NativeWindow parent, | |
49 const CryptoModulePasswordCallback& callback); | |
50 | |
51 // Returns a CryptoModuleBlockingPasswordDelegate to open a dialog and block | |
52 // until returning. Should only be used on a worker thread. | |
53 crypto::CryptoModuleBlockingPasswordDelegate* | |
54 NewCryptoModuleBlockingDialogDelegate(CryptoModulePasswordReason reason, | |
55 const std::string& server); | |
56 | |
57 // Asynchronously unlock |modules|, if necessary. |callback| is called when | 24 // Asynchronously unlock |modules|, if necessary. |callback| is called when |
58 // done (regardless if any modules were successfully unlocked or not). Should | 25 // done (regardless if any modules were successfully unlocked or not). Should |
59 // only be called on UI thread. | 26 // only be called on UI thread. |
60 void UnlockSlotsIfNecessary(const net::CryptoModuleList& modules, | 27 void UnlockSlotsIfNecessary(const net::CryptoModuleList& modules, |
61 CryptoModulePasswordReason reason, | 28 CryptoModulePasswordReason reason, |
62 const std::string& server, | 29 const std::string& server, |
63 gfx::NativeWindow parent, | 30 gfx::NativeWindow parent, |
64 const base::Closure& callback); | 31 const base::Closure& callback); |
65 | 32 |
66 // Asynchronously unlock the |cert|'s module, if necessary. |callback| is | 33 // Asynchronously unlock the |cert|'s module, if necessary. |callback| is |
67 // called when done (regardless if module was successfully unlocked or not). | 34 // called when done (regardless if module was successfully unlocked or not). |
68 // Should only be called on UI thread. | 35 // Should only be called on UI thread. |
69 void UnlockCertSlotIfNecessary(net::X509Certificate* cert, | 36 void UnlockCertSlotIfNecessary(net::X509Certificate* cert, |
70 CryptoModulePasswordReason reason, | 37 CryptoModulePasswordReason reason, |
71 const std::string& server, | 38 const std::string& server, |
72 gfx::NativeWindow parent, | 39 gfx::NativeWindow parent, |
73 const base::Closure& callback); | 40 const base::Closure& callback); |
74 | 41 |
75 } // namespace chrome | 42 } // namespace chrome |
76 | 43 |
77 #endif // CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_ | 44 #endif // CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_NSS_H_ |
OLD | NEW |