OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
6 #define CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | 6 #define CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/sequenced_task_runner_helpers.h" | 10 #include "base/sequenced_task_runner_helpers.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "net/ssl/ssl_cert_request_info.h" | 13 #include "net/ssl/ssl_cert_request_info.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 class ClientCertStore; | |
16 class HttpNetworkSession; | 17 class HttpNetworkSession; |
17 class URLRequest; | 18 class URLRequest; |
18 class X509Certificate; | 19 class X509Certificate; |
19 } // namespace net | 20 } // namespace net |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
24 class ResourceContext; | |
25 | |
23 // This class handles the approval and selection of a certificate for SSL client | 26 // This class handles the approval and selection of a certificate for SSL client |
24 // authentication by the user. | 27 // authentication by the user. |
25 // It is self-owned and deletes itself when the UI reports the user selection or | 28 // It is self-owned and deletes itself when the UI reports the user selection or |
26 // when the net::URLRequest is cancelled. | 29 // when the net::URLRequest is cancelled. |
27 class CONTENT_EXPORT SSLClientAuthHandler | 30 class CONTENT_EXPORT SSLClientAuthHandler |
28 : public base::RefCountedThreadSafe< | 31 : public base::RefCountedThreadSafe< |
29 SSLClientAuthHandler, BrowserThread::DeleteOnIOThread> { | 32 SSLClientAuthHandler, BrowserThread::DeleteOnIOThread> { |
30 public: | 33 public: |
31 SSLClientAuthHandler(net::URLRequest* request, | 34 SSLClientAuthHandler(ResourceContext* context, |
wtc
2013/10/28 19:41:12
It may be better to just pass the ClientCertStore
mattm
2013/10/28 23:56:16
Done.
| |
35 net::URLRequest* request, | |
32 net::SSLCertRequestInfo* cert_request_info); | 36 net::SSLCertRequestInfo* cert_request_info); |
33 | 37 |
34 // Selects a certificate and resumes the URL request with that certificate. | 38 // Selects a certificate and resumes the URL request with that certificate. |
35 // Should only be called on the IO thread. | 39 // Should only be called on the IO thread. |
36 void SelectCertificate(); | 40 void SelectCertificate(); |
37 | 41 |
38 // Invoked when the request associated with this handler is cancelled. | 42 // Invoked when the request associated with this handler is cancelled. |
39 // Should only be called on the IO thread. | 43 // Should only be called on the IO thread. |
40 void OnRequestCancelled(); | 44 void OnRequestCancelled(); |
41 | 45 |
42 // Calls DoCertificateSelected on the I/O thread. | 46 // Calls DoCertificateSelected on the I/O thread. |
43 // Called on the UI thread after the user has made a selection (which may | 47 // Called on the UI thread after the user has made a selection (which may |
44 // be long after DoSelectCertificate returns, if the UI is modeless/async.) | 48 // be long after DoSelectCertificate returns, if the UI is modeless/async.) |
45 void CertificateSelected(net::X509Certificate* cert); | 49 void CertificateSelected(net::X509Certificate* cert); |
46 | 50 |
47 protected: | 51 protected: |
48 virtual ~SSLClientAuthHandler(); | 52 virtual ~SSLClientAuthHandler(); |
49 | 53 |
50 private: | 54 private: |
51 friend class base::RefCountedThreadSafe< | 55 friend class base::RefCountedThreadSafe< |
52 SSLClientAuthHandler, BrowserThread::DeleteOnIOThread>; | 56 SSLClientAuthHandler, BrowserThread::DeleteOnIOThread>; |
53 friend class BrowserThread; | 57 friend class BrowserThread; |
54 friend class base::DeleteHelper<SSLClientAuthHandler>; | 58 friend class base::DeleteHelper<SSLClientAuthHandler>; |
55 | 59 |
60 // Called when ClientCertStore is done retrieving the cert list. | |
61 void GotClientCerts(); | |
wtc
2013/10/28 19:41:12
Nit: our naming convention for this kind of functi
mattm
2013/10/28 23:56:16
Done.
| |
62 | |
56 // Notifies that the user has selected a cert. | 63 // Notifies that the user has selected a cert. |
57 // Called on the IO thread. | 64 // Called on the IO thread. |
58 void DoCertificateSelected(net::X509Certificate* cert); | 65 void DoCertificateSelected(net::X509Certificate* cert); |
59 | 66 |
60 // Selects a client certificate on the UI thread. | 67 // Selects a client certificate on the UI thread. |
61 void DoSelectCertificate(int render_process_host_id, | 68 void DoSelectCertificate(int render_process_host_id, |
62 int render_view_host_id); | 69 int render_view_host_id); |
63 | 70 |
64 // The net::URLRequest that triggered this client auth. | 71 // The net::URLRequest that triggered this client auth. |
65 net::URLRequest* request_; | 72 net::URLRequest* request_; |
66 | 73 |
67 // The HttpNetworkSession |request_| is associated with. | 74 // The HttpNetworkSession |request_| is associated with. |
68 const net::HttpNetworkSession* http_network_session_; | 75 const net::HttpNetworkSession* http_network_session_; |
69 | 76 |
70 // The certs to choose from. | 77 // The certs to choose from. |
71 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; | 78 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; |
72 | 79 |
80 scoped_ptr<net::ClientCertStore> client_cert_store_; | |
81 | |
73 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); | 82 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); |
74 }; | 83 }; |
75 | 84 |
76 } // namespace content | 85 } // namespace content |
77 | 86 |
78 #endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | 87 #endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
OLD | NEW |