crypto_module_password_dialog.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
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. 4 5#ifndef CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_ 6#define CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_ 7 8#include <string> 9#include <vector> 10 11#include "base/callback.h" 12#include "base/memory/ref_counted.h" 13 14namespace crypto { 15class CryptoModuleBlockingPasswordDelegate; 16} 17 18namespace net { 19class CryptoModule; 20typedef std::vector<scoped_refptr<CryptoModule> > CryptoModuleList; 21class X509Certificate; 22} 23 24namespace chrome { 25 26// An enum to describe the reason for the password request. 27enum CryptoModulePasswordReason { 28 kCryptoModulePasswordKeygen, 29 kCryptoModulePasswordCertEnrollment, 30 kCryptoModulePasswordClientAuth, 31 kCryptoModulePasswordListCerts, 32 kCryptoModulePasswordCertImport, 33 kCryptoModulePasswordCertExport, 34}; 35 36typedef base::Callback<void(const char*)> CryptoModulePasswordCallback; 37 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. 42void ShowCryptoModulePasswordDialog( 43 const std::string& module_name, 44 bool retry, 45 CryptoModulePasswordReason reason, 46 const std::string& server, 47 const CryptoModulePasswordCallback& callback); 48 49// Returns a CryptoModuleBlockingPasswordDelegate to open a dialog and block 50// until returning. Should only be used on a worker thread. 51crypto::CryptoModuleBlockingPasswordDelegate* 52 NewCryptoModuleBlockingDialogDelegate(CryptoModulePasswordReason reason, 53 const std::string& server); 54 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. 58void UnlockSlotsIfNecessary(const net::CryptoModuleList& modules, 59 CryptoModulePasswordReason reason, 60 const std::string& server, 61 const base::Closure& callback); 62 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. 66void UnlockCertSlotIfNecessary(net::X509Certificate* cert, 67 CryptoModulePasswordReason reason, 68 const std::string& server, 69 const base::Closure& callback); 70 71} // namespace chrome 72 73#endif // CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_ 74