crypto_module_password_dialog.h revision f2477e01787aa58f445919b809d89e252beef54f
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#include "ui/gfx/native_widget_types.h" 14 15namespace crypto { 16class CryptoModuleBlockingPasswordDelegate; 17} 18 19namespace net { 20class CryptoModule; 21typedef std::vector<scoped_refptr<CryptoModule> > CryptoModuleList; 22class X509Certificate; 23} 24 25namespace chrome { 26 27// An enum to describe the reason for the password request. 28enum CryptoModulePasswordReason { 29 kCryptoModulePasswordKeygen, 30 kCryptoModulePasswordCertEnrollment, 31 kCryptoModulePasswordClientAuth, 32 kCryptoModulePasswordListCerts, 33 kCryptoModulePasswordCertImport, 34 kCryptoModulePasswordCertExport, 35}; 36 37typedef 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. 43void 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. 53crypto::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. 60void 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. 69void 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 76 77#endif // CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_ 78