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