Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: content/browser/ssl/ssl_client_auth_handler.h

Issue 596873002: Remove SSLClientAuthHandler's RDH dependency. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/callback.h"
9 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
10 #include "base/sequenced_task_runner_helpers.h" 11 #include "base/memory/weak_ptr.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 ClientCertStore;
17 class HttpNetworkSession;
18 class URLRequest; 17 class URLRequest;
19 class X509Certificate; 18 class X509Certificate;
20 } // namespace net 19 } // namespace net
21 20
22 namespace content { 21 namespace content {
23 22
24 class ResourceContext; 23 // This class handles the approval and selection of a certificate for SSL client
24 // authentication by the user. Should only be used on the IO thread. If the
25 // SSLClientAuthHandler is destroyed before the certificate is selected, the
26 // selection is canceled and the callback never called.
27 class SSLClientAuthHandler {
28 public:
29 typedef base::Callback<void(net::X509Certificate*)> CertificateCallback;
25 30
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
29 // when the net::URLRequest is cancelled.
30 class CONTENT_EXPORT SSLClientAuthHandler
31 : public base::RefCountedThreadSafe<
32 SSLClientAuthHandler, BrowserThread::DeleteOnIOThread> {
33 public:
34 SSLClientAuthHandler(scoped_ptr<net::ClientCertStore> client_cert_store, 31 SSLClientAuthHandler(scoped_ptr<net::ClientCertStore> client_cert_store,
35 net::URLRequest* request, 32 net::URLRequest* request,
36 net::SSLCertRequestInfo* cert_request_info); 33 net::SSLCertRequestInfo* cert_request_info,
34 const CertificateCallback& callback);
35 ~SSLClientAuthHandler();
37 36
38 // Selects a certificate and resumes the URL request with that certificate. 37 // Selects a certificate and resumes the URL request with that certificate.
39 // Should only be called on the IO thread.
40 void SelectCertificate(); 38 void SelectCertificate();
41 39
42 // Invoked when the request associated with this handler is cancelled.
43 // Should only be called on the IO thread.
44 void OnRequestCancelled();
45
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
51 protected:
52 virtual ~SSLClientAuthHandler();
53
54 private: 40 private:
55 friend class base::RefCountedThreadSafe<
56 SSLClientAuthHandler, BrowserThread::DeleteOnIOThread>;
57 friend class BrowserThread;
58 friend class base::DeleteHelper<SSLClientAuthHandler>;
59
60 // Called when ClientCertStore is done retrieving the cert list. 41 // Called when ClientCertStore is done retrieving the cert list.
61 void DidGetClientCerts(); 42 void DidGetClientCerts();
62 43
63 // Notifies that the user has selected a cert. 44 // Called when the user has selected a cert.
64 // Called on the IO thread. 45 void CertificateSelected(net::X509Certificate* cert);
65 void DoCertificateSelected(net::X509Certificate* cert);
66
67 // Selects a client certificate on the UI thread.
68 void DoSelectCertificate(int render_process_host_id,
69 int render_frame_host_id);
70 46
71 // The net::URLRequest that triggered this client auth. 47 // The net::URLRequest that triggered this client auth.
72 net::URLRequest* request_; 48 net::URLRequest* request_;
73 49
74 // The HttpNetworkSession |request_| is associated with.
75 const net::HttpNetworkSession* http_network_session_;
76
77 // The certs to choose from. 50 // The certs to choose from.
78 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; 51 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_;
79 52
80 scoped_ptr<net::ClientCertStore> client_cert_store_; 53 scoped_ptr<net::ClientCertStore> client_cert_store_;
81 54
55 // The callback to call when the certificate is selected.
56 CertificateCallback callback_;
57
58 base::WeakPtrFactory<SSLClientAuthHandler> weak_factory_;
59
82 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); 60 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler);
83 }; 61 };
84 62
85 } // namespace content 63 } // namespace content
86 64
87 #endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ 65 #endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/loader/resource_loader_unittest.cc ('k') | content/browser/ssl/ssl_client_auth_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698