[email protected] | f786717 | 2012-07-11 07:04:07 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 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] | 74b962a | 2011-06-03 21:22:54 | [diff] [blame] | 5 | #ifndef CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
6 | #define CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | ||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 7 | |
8 | #include "base/basictypes.h" | ||||
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 9 | #include "base/memory/ref_counted.h" |
[email protected] | fb44196 | 2013-05-08 05:35:24 | [diff] [blame] | 10 | #include "base/sequenced_task_runner_helpers.h" |
[email protected] | 8d128d6 | 2011-09-13 22:11:57 | [diff] [blame] | 11 | #include "content/common/content_export.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 12 | #include "content/public/browser/browser_thread.h" |
[email protected] | 536fd0b | 2013-03-14 17:41:57 | [diff] [blame] | 13 | #include "net/ssl/ssl_cert_request_info.h" |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 14 | |
15 | namespace net { | ||||
[email protected] | 1ccb699 | 2013-10-30 04:46:20 | [diff] [blame^] | 16 | class ClientCertStore; |
[email protected] | fe4fb43 | 2011-10-20 22:43:42 | [diff] [blame] | 17 | class HttpNetworkSession; |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 18 | class URLRequest; |
[email protected] | edfe7fab | 2010-11-28 13:11:52 | [diff] [blame] | 19 | class X509Certificate; |
20 | } // namespace net | ||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 21 | |
[email protected] | 89f23a3 | 2012-10-24 22:31:24 | [diff] [blame] | 22 | namespace content { |
23 | |||||
[email protected] | 1ccb699 | 2013-10-30 04:46:20 | [diff] [blame^] | 24 | class ResourceContext; |
25 | |||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 26 | // This class handles the approval and selection of a certificate for SSL client |
27 | // authentication by the user. | ||||
28 | // It is self-owned and deletes itself when the UI reports the user selection or | ||||
[email protected] | 6981d963 | 2010-11-30 21:34:02 | [diff] [blame] | 29 | // when the net::URLRequest is cancelled. |
[email protected] | 8d128d6 | 2011-09-13 22:11:57 | [diff] [blame] | 30 | class CONTENT_EXPORT SSLClientAuthHandler |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 31 | : public base::RefCountedThreadSafe< |
[email protected] | 89f23a3 | 2012-10-24 22:31:24 | [diff] [blame] | 32 | SSLClientAuthHandler, BrowserThread::DeleteOnIOThread> { |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 33 | public: |
[email protected] | 1ccb699 | 2013-10-30 04:46:20 | [diff] [blame^] | 34 | SSLClientAuthHandler(scoped_ptr<net::ClientCertStore> client_cert_store, |
35 | net::URLRequest* request, | ||||
[email protected] | 0d3dc8e2 | 2009-11-03 02:27:01 | [diff] [blame] | 36 | net::SSLCertRequestInfo* cert_request_info); |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 37 | |
[email protected] | c99c442e | 2011-08-24 11:37:30 | [diff] [blame] | 38 | // Selects a certificate and resumes the URL request with that certificate. |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 39 | // Should only be called on the IO thread. |
40 | void SelectCertificate(); | ||||
41 | |||||
42 | // Invoked when the request associated with this handler is cancelled. | ||||
43 | // Should only be called on the IO thread. | ||||
44 | void OnRequestCancelled(); | ||||
45 | |||||
[email protected] | b1f18494 | 2010-03-04 01:46:57 | [diff] [blame] | 46 | // Calls DoCertificateSelected on the I/O thread. |
47 | // Called on the UI thread after the user has made a selection (which may | ||||
48 | // be long after DoSelectCertificate returns, if the UI is modeless/async.) | ||||
49 | void CertificateSelected(net::X509Certificate* cert); | ||||
50 | |||||
[email protected] | f245542 | 2011-07-21 02:56:58 | [diff] [blame] | 51 | protected: |
52 | virtual ~SSLClientAuthHandler(); | ||||
53 | |||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 54 | private: |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 55 | friend class base::RefCountedThreadSafe< |
[email protected] | 89f23a3 | 2012-10-24 22:31:24 | [diff] [blame] | 56 | SSLClientAuthHandler, BrowserThread::DeleteOnIOThread>; |
57 | friend class BrowserThread; | ||||
[email protected] | cff06c57 | 2012-01-02 20:03:05 | [diff] [blame] | 58 | friend class base::DeleteHelper<SSLClientAuthHandler>; |
[email protected] | e6e6ba4 | 2009-11-07 01:56:19 | [diff] [blame] | 59 | |
[email protected] | 1ccb699 | 2013-10-30 04:46:20 | [diff] [blame^] | 60 | // Called when ClientCertStore is done retrieving the cert list. |
61 | void DidGetClientCerts(); | ||||
62 | |||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 63 | // Notifies that the user has selected a cert. |
64 | // Called on the IO thread. | ||||
[email protected] | 3e1fc8e | 2010-02-18 22:45:05 | [diff] [blame] | 65 | void DoCertificateSelected(net::X509Certificate* cert); |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 66 | |
[email protected] | c99c442e | 2011-08-24 11:37:30 | [diff] [blame] | 67 | // Selects a client certificate on the UI thread. |
68 | void DoSelectCertificate(int render_process_host_id, | ||||
69 | int render_view_host_id); | ||||
[email protected] | c6176905 | 2011-05-18 18:38:35 | [diff] [blame] | 70 | |
[email protected] | 6981d963 | 2010-11-30 21:34:02 | [diff] [blame] | 71 | // The net::URLRequest that triggered this client auth. |
[email protected] | edfe7fab | 2010-11-28 13:11:52 | [diff] [blame] | 72 | net::URLRequest* request_; |
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 73 | |
[email protected] | fe4fb43 | 2011-10-20 22:43:42 | [diff] [blame] | 74 | // The HttpNetworkSession |request_| is associated with. |
75 | const net::HttpNetworkSession* http_network_session_; | ||||
76 | |||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 77 | // The certs to choose from. |
78 | scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; | ||||
79 | |||||
[email protected] | 1ccb699 | 2013-10-30 04:46:20 | [diff] [blame^] | 80 | scoped_ptr<net::ClientCertStore> client_cert_store_; |
81 | |||||
[email protected] | ce2b6226 | 2009-06-27 05:11:41 | [diff] [blame] | 82 | DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); |
83 | }; | ||||
84 | |||||
[email protected] | 89f23a3 | 2012-10-24 22:31:24 | [diff] [blame] | 85 | } // namespace content |
86 | |||||
[email protected] | 74b962a | 2011-06-03 21:22:54 | [diff] [blame] | 87 | #endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |