Index: content/browser/ssl/ssl_client_auth_handler.h |
diff --git a/content/browser/ssl/ssl_client_auth_handler.h b/content/browser/ssl/ssl_client_auth_handler.h |
index b848d54d7ffff4d31544f114cba1d3f2b517c142..f95e65d71bbfb35faacad9d33bc3d19784988af2 100644 |
--- a/content/browser/ssl/ssl_client_auth_handler.h |
+++ b/content/browser/ssl/ssl_client_auth_handler.h |
@@ -6,79 +6,57 @@ |
#define CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
#include "base/basictypes.h" |
+#include "base/callback.h" |
#include "base/memory/ref_counted.h" |
-#include "base/sequenced_task_runner_helpers.h" |
-#include "content/common/content_export.h" |
+#include "base/memory/weak_ptr.h" |
#include "content/public/browser/browser_thread.h" |
#include "net/ssl/ssl_cert_request_info.h" |
namespace net { |
class ClientCertStore; |
-class HttpNetworkSession; |
class URLRequest; |
class X509Certificate; |
} // namespace net |
namespace content { |
-class ResourceContext; |
- |
// This class handles the approval and selection of a certificate for SSL client |
-// authentication by the user. |
-// It is self-owned and deletes itself when the UI reports the user selection or |
-// when the net::URLRequest is cancelled. |
-class CONTENT_EXPORT SSLClientAuthHandler |
- : public base::RefCountedThreadSafe< |
- SSLClientAuthHandler, BrowserThread::DeleteOnIOThread> { |
+// authentication by the user. Should only be used on the IO thread. If the |
+// SSLClientAuthHandler is destroyed before the certificate is selected, the |
+// selection is canceled and the callback never called. |
+class SSLClientAuthHandler { |
public: |
+ typedef base::Callback<void(net::X509Certificate*)> CertificateCallback; |
+ |
SSLClientAuthHandler(scoped_ptr<net::ClientCertStore> client_cert_store, |
net::URLRequest* request, |
- net::SSLCertRequestInfo* cert_request_info); |
+ net::SSLCertRequestInfo* cert_request_info, |
+ const CertificateCallback& callback); |
+ ~SSLClientAuthHandler(); |
// Selects a certificate and resumes the URL request with that certificate. |
- // Should only be called on the IO thread. |
void SelectCertificate(); |
- // Invoked when the request associated with this handler is cancelled. |
- // Should only be called on the IO thread. |
- void OnRequestCancelled(); |
- |
- // Calls DoCertificateSelected on the I/O thread. |
- // Called on the UI thread after the user has made a selection (which may |
- // be long after DoSelectCertificate returns, if the UI is modeless/async.) |
- void CertificateSelected(net::X509Certificate* cert); |
- |
- protected: |
- virtual ~SSLClientAuthHandler(); |
- |
private: |
- friend class base::RefCountedThreadSafe< |
- SSLClientAuthHandler, BrowserThread::DeleteOnIOThread>; |
- friend class BrowserThread; |
- friend class base::DeleteHelper<SSLClientAuthHandler>; |
- |
// Called when ClientCertStore is done retrieving the cert list. |
void DidGetClientCerts(); |
- // Notifies that the user has selected a cert. |
- // Called on the IO thread. |
- void DoCertificateSelected(net::X509Certificate* cert); |
- |
- // Selects a client certificate on the UI thread. |
- void DoSelectCertificate(int render_process_host_id, |
- int render_frame_host_id); |
+ // Called when the user has selected a cert. |
+ void CertificateSelected(net::X509Certificate* cert); |
// The net::URLRequest that triggered this client auth. |
net::URLRequest* request_; |
- // The HttpNetworkSession |request_| is associated with. |
- const net::HttpNetworkSession* http_network_session_; |
- |
// The certs to choose from. |
scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; |
scoped_ptr<net::ClientCertStore> client_cert_store_; |
+ // The callback to call when the certificate is selected. |
+ CertificateCallback callback_; |
+ |
+ base::WeakPtrFactory<SSLClientAuthHandler> weak_factory_; |
+ |
DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); |
}; |