[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 1 | // Copyright (c) 2009 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 | |||||
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
6 | #define CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | ||||
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 8 | |
9 | #include "base/basictypes.h" | ||||
10 | #include "base/ref_counted.h" | ||||
[email protected] | 8281e48e | 2010-10-12 18:54:49 | [diff] [blame] | 11 | #include "chrome/browser/browser_thread.h" |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 12 | #include "net/base/ssl_cert_request_info.h" |
13 | |||||
14 | namespace net { | ||||
15 | class X509Certificate; | ||||
16 | } | ||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 17 | class URLRequest; |
18 | |||||
19 | // This class handles the approval and selection of a certificate for SSL client | ||||
20 | // authentication by the user. | ||||
21 | // It is self-owned and deletes itself when the UI reports the user selection or | ||||
22 | // when the URLRequest is cancelled. | ||||
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 23 | class SSLClientAuthHandler |
[email protected] | 1f18184a | 2010-07-21 19:34:49 | [diff] [blame] | 24 | : public base::RefCountedThreadSafe<SSLClientAuthHandler, |
[email protected] | 9a7e150 | 2010-10-08 04:03:50 | [diff] [blame] | 25 | BrowserThread::DeleteOnIOThread> { |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 26 | public: |
27 | SSLClientAuthHandler(URLRequest* request, | ||||
[email protected] | 0d3dc8e2 | 2009-11-03 02:27:01 | [diff] [blame] | 28 | net::SSLCertRequestInfo* cert_request_info); |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 29 | |
30 | // Asks the user to select a certificate and resumes the URL request with that | ||||
31 | // certificate. | ||||
32 | // Should only be called on the IO thread. | ||||
33 | void SelectCertificate(); | ||||
34 | |||||
35 | // Invoked when the request associated with this handler is cancelled. | ||||
36 | // Should only be called on the IO thread. | ||||
37 | void OnRequestCancelled(); | ||||
38 | |||||
[email protected] | b1f18494 | 2010-03-04 01:46:57 | [diff] [blame] | 39 | // Calls DoCertificateSelected on the I/O thread. |
40 | // Called on the UI thread after the user has made a selection (which may | ||||
41 | // be long after DoSelectCertificate returns, if the UI is modeless/async.) | ||||
42 | void CertificateSelected(net::X509Certificate* cert); | ||||
43 | |||||
[email protected] | 1f18184a | 2010-07-21 19:34:49 | [diff] [blame] | 44 | // Returns the SSLCertRequestInfo for this handler. |
45 | net::SSLCertRequestInfo* cert_request_info() { return cert_request_info_; } | ||||
46 | |||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 47 | private: |
[email protected] | 092b04e | 2010-10-12 23:23:44 | [diff] [blame^] | 48 | friend class BrowserThread; |
[email protected] | 1f18184a | 2010-07-21 19:34:49 | [diff] [blame] | 49 | friend class DeleteTask<SSLClientAuthHandler>; |
[email protected] | e6e6ba4 | 2009-11-07 01:56:19 | [diff] [blame] | 50 | |
[email protected] | 02d08e0 | 2010-10-08 17:50:46 | [diff] [blame] | 51 | virtual ~SSLClientAuthHandler(); |
[email protected] | e6e6ba4 | 2009-11-07 01:56:19 | [diff] [blame] | 52 | |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 53 | // Notifies that the user has selected a cert. |
54 | // Called on the IO thread. | ||||
[email protected] | 3e1fc8e | 2010-02-18 22:45:05 | [diff] [blame] | 55 | void DoCertificateSelected(net::X509Certificate* cert); |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 56 | |
57 | // The URLRequest that triggered this client auth. | ||||
58 | URLRequest* request_; | ||||
59 | |||||
60 | // The certs to choose from. | ||||
61 | scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; | ||||
62 | |||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 63 | DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); |
64 | }; | ||||
65 | |||||
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 66 | #endif // CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |