OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
6 #define CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | 6 #define CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "chrome/browser/chrome_thread.h" |
10 #include "net/base/ssl_cert_request_info.h" | 11 #include "net/base/ssl_cert_request_info.h" |
11 | 12 |
12 namespace net { | 13 namespace net { |
13 class X509Certificate; | 14 class X509Certificate; |
14 } | 15 } |
15 class URLRequest; | 16 class URLRequest; |
16 | 17 |
17 // This class handles the approval and selection of a certificate for SSL client | 18 // This class handles the approval and selection of a certificate for SSL client |
18 // authentication by the user. | 19 // authentication by the user. |
19 // It is self-owned and deletes itself when the UI reports the user selection or | 20 // It is self-owned and deletes itself when the UI reports the user selection or |
20 // when the URLRequest is cancelled. | 21 // when the URLRequest is cancelled. |
21 class SSLClientAuthHandler | 22 class SSLClientAuthHandler |
22 : public base::RefCountedThreadSafe<SSLClientAuthHandler> { | 23 : public base::RefCountedThreadSafe<SSLClientAuthHandler, |
| 24 ChromeThread::DeleteOnIOThread> { |
23 public: | 25 public: |
24 SSLClientAuthHandler(URLRequest* request, | 26 SSLClientAuthHandler(URLRequest* request, |
25 net::SSLCertRequestInfo* cert_request_info); | 27 net::SSLCertRequestInfo* cert_request_info); |
26 | 28 |
27 // Asks the user to select a certificate and resumes the URL request with that | 29 // Asks the user to select a certificate and resumes the URL request with that |
28 // certificate. | 30 // certificate. |
29 // Should only be called on the IO thread. | 31 // Should only be called on the IO thread. |
30 void SelectCertificate(); | 32 void SelectCertificate(); |
31 | 33 |
32 // Invoked when the request associated with this handler is cancelled. | 34 // Invoked when the request associated with this handler is cancelled. |
33 // Should only be called on the IO thread. | 35 // Should only be called on the IO thread. |
34 void OnRequestCancelled(); | 36 void OnRequestCancelled(); |
35 | 37 |
36 // Calls DoCertificateSelected on the I/O thread. | 38 // Calls DoCertificateSelected on the I/O thread. |
37 // Called on the UI thread after the user has made a selection (which may | 39 // Called on the UI thread after the user has made a selection (which may |
38 // be long after DoSelectCertificate returns, if the UI is modeless/async.) | 40 // be long after DoSelectCertificate returns, if the UI is modeless/async.) |
39 void CertificateSelected(net::X509Certificate* cert); | 41 void CertificateSelected(net::X509Certificate* cert); |
40 | 42 |
| 43 // Returns the SSLCertRequestInfo for this handler. |
| 44 net::SSLCertRequestInfo* cert_request_info() { return cert_request_info_; } |
| 45 |
41 private: | 46 private: |
42 friend class base::RefCountedThreadSafe<SSLClientAuthHandler>; | 47 friend class ChromeThread; |
| 48 friend class DeleteTask<SSLClientAuthHandler>; |
43 | 49 |
44 ~SSLClientAuthHandler(); | 50 ~SSLClientAuthHandler(); |
45 | 51 |
46 // Asks the user for a cert. | |
47 // Called on the UI thread. | |
48 void DoSelectCertificate(); | |
49 | |
50 // Notifies that the user has selected a cert. | 52 // Notifies that the user has selected a cert. |
51 // Called on the IO thread. | 53 // Called on the IO thread. |
52 void DoCertificateSelected(net::X509Certificate* cert); | 54 void DoCertificateSelected(net::X509Certificate* cert); |
53 | 55 |
54 // The URLRequest that triggered this client auth. | 56 // The URLRequest that triggered this client auth. |
55 URLRequest* request_; | 57 URLRequest* request_; |
56 | 58 |
57 // The certs to choose from. | 59 // The certs to choose from. |
58 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; | 60 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; |
59 | 61 |
60 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); | 62 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); |
61 }; | 63 }; |
62 | 64 |
63 #endif // CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | 65 #endif // CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
OLD | NEW |