| 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 "net/base/ssl_cert_request_info.h" | 10 #include "net/base/ssl_cert_request_info.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 class X509Certificate; | 13 class X509Certificate; |
| 14 } | 14 } |
| 15 class MessageLoop; | |
| 16 class URLRequest; | 15 class URLRequest; |
| 17 | 16 |
| 18 // This class handles the approval and selection of a certificate for SSL client | 17 // This class handles the approval and selection of a certificate for SSL client |
| 19 // authentication by the user. | 18 // authentication by the user. |
| 20 // It is self-owned and deletes itself when the UI reports the user selection or | 19 // It is self-owned and deletes itself when the UI reports the user selection or |
| 21 // when the URLRequest is cancelled. | 20 // when the URLRequest is cancelled. |
| 22 class SSLClientAuthHandler : | 21 class SSLClientAuthHandler : |
| 23 public base::RefCountedThreadSafe<SSLClientAuthHandler> { | 22 public base::RefCountedThreadSafe<SSLClientAuthHandler> { |
| 24 public: | 23 public: |
| 25 SSLClientAuthHandler(URLRequest* request, | 24 SSLClientAuthHandler(URLRequest* request, |
| 26 net::SSLCertRequestInfo* cert_request_info, | 25 net::SSLCertRequestInfo* cert_request_info); |
| 27 MessageLoop* io_loop, | |
| 28 MessageLoop* ui_loop); | |
| 29 ~SSLClientAuthHandler(); | 26 ~SSLClientAuthHandler(); |
| 30 | 27 |
| 31 // Asks the user to select a certificate and resumes the URL request with that | 28 // Asks the user to select a certificate and resumes the URL request with that |
| 32 // certificate. | 29 // certificate. |
| 33 // Should only be called on the IO thread. | 30 // Should only be called on the IO thread. |
| 34 void SelectCertificate(); | 31 void SelectCertificate(); |
| 35 | 32 |
| 36 // Invoked when the request associated with this handler is cancelled. | 33 // Invoked when the request associated with this handler is cancelled. |
| 37 // Should only be called on the IO thread. | 34 // Should only be called on the IO thread. |
| 38 void OnRequestCancelled(); | 35 void OnRequestCancelled(); |
| 39 | 36 |
| 40 private: | 37 private: |
| 41 // Asks the user for a cert. | 38 // Asks the user for a cert. |
| 42 // Called on the UI thread. | 39 // Called on the UI thread. |
| 43 void DoSelectCertificate(); | 40 void DoSelectCertificate(); |
| 44 | 41 |
| 45 // Notifies that the user has selected a cert. | 42 // Notifies that the user has selected a cert. |
| 46 // Called on the IO thread. | 43 // Called on the IO thread. |
| 47 void CertificateSelected(net::X509Certificate* cert); | 44 void CertificateSelected(net::X509Certificate* cert); |
| 48 | 45 |
| 49 // The URLRequest that triggered this client auth. | 46 // The URLRequest that triggered this client auth. |
| 50 URLRequest* request_; | 47 URLRequest* request_; |
| 51 | 48 |
| 52 // The certs to choose from. | 49 // The certs to choose from. |
| 53 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; | 50 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; |
| 54 | 51 |
| 55 MessageLoop* io_loop_; | |
| 56 MessageLoop* ui_loop_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); | 52 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); |
| 59 }; | 53 }; |
| 60 | 54 |
| 61 #endif // CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H | 55 #endif // CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H |
| OLD | NEW |