blob: c93a55a57c68e9dc2edecccfbfde5966ab685d38 [file] [log] [blame]
[email protected]ce2b62262009-06-27 05:11:411// 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
3// found in the LICENSE file.
4
[email protected]11f4857282009-11-13 19:56:175#ifndef CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_
6#define CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]ce2b62262009-06-27 05:11:418
9#include "base/basictypes.h"
10#include "base/ref_counted.h"
[email protected]8281e48e2010-10-12 18:54:4911#include "chrome/browser/browser_thread.h"
[email protected]ce2b62262009-06-27 05:11:4112#include "net/base/ssl_cert_request_info.h"
13
14namespace net {
15class X509Certificate;
16}
[email protected]ce2b62262009-06-27 05:11:4117class URLRequest;
18
19// This class handles the approval and selection of a certificate for SSL client
20// authentication by the user.
21// It is self-owned and deletes itself when the UI reports the user selection or
22// when the URLRequest is cancelled.
[email protected]11f4857282009-11-13 19:56:1723class SSLClientAuthHandler
[email protected]1f18184a2010-07-21 19:34:4924 : public base::RefCountedThreadSafe<SSLClientAuthHandler,
[email protected]9a7e1502010-10-08 04:03:5025 BrowserThread::DeleteOnIOThread> {
[email protected]ce2b62262009-06-27 05:11:4126 public:
27 SSLClientAuthHandler(URLRequest* request,
[email protected]0d3dc8e22009-11-03 02:27:0128 net::SSLCertRequestInfo* cert_request_info);
[email protected]ce2b62262009-06-27 05:11:4129
30 // Asks the user to select a certificate and resumes the URL request with that
31 // certificate.
32 // Should only be called on the IO thread.
33 void SelectCertificate();
34
35 // Invoked when the request associated with this handler is cancelled.
36 // Should only be called on the IO thread.
37 void OnRequestCancelled();
38
[email protected]b1f184942010-03-04 01:46:5739 // Calls DoCertificateSelected on the I/O thread.
40 // Called on the UI thread after the user has made a selection (which may
41 // be long after DoSelectCertificate returns, if the UI is modeless/async.)
42 void CertificateSelected(net::X509Certificate* cert);
43
[email protected]1f18184a2010-07-21 19:34:4944 // Returns the SSLCertRequestInfo for this handler.
45 net::SSLCertRequestInfo* cert_request_info() { return cert_request_info_; }
46
[email protected]ce2b62262009-06-27 05:11:4147 private:
[email protected]092b04e2010-10-12 23:23:4448 friend class BrowserThread;
[email protected]1f18184a2010-07-21 19:34:4949 friend class DeleteTask<SSLClientAuthHandler>;
[email protected]e6e6ba42009-11-07 01:56:1950
[email protected]02d08e02010-10-08 17:50:4651 virtual ~SSLClientAuthHandler();
[email protected]e6e6ba42009-11-07 01:56:1952
[email protected]ce2b62262009-06-27 05:11:4153 // Notifies that the user has selected a cert.
54 // Called on the IO thread.
[email protected]3e1fc8e2010-02-18 22:45:0555 void DoCertificateSelected(net::X509Certificate* cert);
[email protected]ce2b62262009-06-27 05:11:4156
57 // The URLRequest that triggered this client auth.
58 URLRequest* request_;
59
60 // The certs to choose from.
61 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_;
62
[email protected]ce2b62262009-06-27 05:11:4163 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler);
64};
65
[email protected]11f4857282009-11-13 19:56:1766#endif // CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_