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_H_ |
6 #define CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_ | 6 #define CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | |
10 | 9 |
11 #include "base/callback.h" | 10 #include "base/callback.h" |
12 #include "base/memory/ref_counted.h" | |
13 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
14 | 12 |
15 namespace crypto { | |
16 class CryptoModuleBlockingPasswordDelegate; | |
17 } | |
18 | |
19 namespace net { | |
20 class CryptoModule; | |
21 typedef std::vector<scoped_refptr<CryptoModule> > CryptoModuleList; | |
22 class X509Certificate; | |
23 } | |
24 | |
25 namespace chrome { | 13 namespace chrome { |
26 | 14 |
27 // An enum to describe the reason for the password request. | 15 // An enum to describe the reason for the password request. |
28 enum CryptoModulePasswordReason { | 16 enum CryptoModulePasswordReason { |
29 kCryptoModulePasswordKeygen, | 17 kCryptoModulePasswordKeygen, |
30 kCryptoModulePasswordCertEnrollment, | 18 kCryptoModulePasswordCertEnrollment, |
31 kCryptoModulePasswordClientAuth, | 19 kCryptoModulePasswordClientAuth, |
32 kCryptoModulePasswordListCerts, | 20 kCryptoModulePasswordListCerts, |
33 kCryptoModulePasswordCertImport, | 21 kCryptoModulePasswordCertImport, |
34 kCryptoModulePasswordCertExport, | 22 kCryptoModulePasswordCertExport, |
35 }; | 23 }; |
36 | 24 |
37 typedef base::Callback<void(const char*)> CryptoModulePasswordCallback; | 25 typedef base::Callback<void(const std::string&)> CryptoModulePasswordCallback; |
38 | 26 |
39 // Display a dialog, prompting the user to authenticate to unlock | 27 // Display a dialog, prompting the user to authenticate to unlock |
40 // |module|. |reason| describes the purpose of the authentication and | 28 // |module|. |reason| describes the purpose of the authentication and |
41 // affects the message displayed in the dialog. |server| is the name | 29 // affects the message displayed in the dialog. |server| is the name |
42 // of the server which requested the access. | 30 // of the server which requested the access. |
43 void ShowCryptoModulePasswordDialog( | 31 void ShowCryptoModulePasswordDialog( |
44 const std::string& module_name, | 32 const std::string& module_name, |
45 bool retry, | 33 bool retry, |
46 CryptoModulePasswordReason reason, | 34 CryptoModulePasswordReason reason, |
47 const std::string& server, | 35 const std::string& server, |
48 gfx::NativeWindow parent, | 36 gfx::NativeWindow parent, |
49 const CryptoModulePasswordCallback& callback); | 37 const CryptoModulePasswordCallback& callback); |
50 | 38 |
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 | |
58 // done (regardless if any modules were successfully unlocked or not). Should | |
59 // only be called on UI thread. | |
60 void UnlockSlotsIfNecessary(const net::CryptoModuleList& modules, | |
61 CryptoModulePasswordReason reason, | |
62 const std::string& server, | |
63 gfx::NativeWindow parent, | |
64 const base::Closure& callback); | |
65 | |
66 // Asynchronously unlock the |cert|'s module, if necessary. |callback| is | |
67 // called when done (regardless if module was successfully unlocked or not). | |
68 // Should only be called on UI thread. | |
69 void UnlockCertSlotIfNecessary(net::X509Certificate* cert, | |
70 CryptoModulePasswordReason reason, | |
71 const std::string& server, | |
72 gfx::NativeWindow parent, | |
73 const base::Closure& callback); | |
74 | |
75 } // namespace chrome | 39 } // namespace chrome |
76 | 40 |
77 #endif // CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_ | 41 #endif // CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_ |
OLD | NEW |