| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "content/browser/browser_thread.h" | 11 #include "content/browser/browser_thread.h" |
| 12 #include "content/common/content_export.h" |
| 12 #include "content/common/notification_observer.h" | 13 #include "content/common/notification_observer.h" |
| 13 #include "content/common/notification_registrar.h" | 14 #include "content/common/notification_registrar.h" |
| 14 #include "net/base/ssl_cert_request_info.h" | 15 #include "net/base/ssl_cert_request_info.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 class URLRequest; | 18 class URLRequest; |
| 18 class X509Certificate; | 19 class X509Certificate; |
| 19 } // namespace net | 20 } // namespace net |
| 20 | 21 |
| 21 // This class handles the approval and selection of a certificate for SSL client | 22 // This class handles the approval and selection of a certificate for SSL client |
| 22 // authentication by the user. | 23 // authentication by the user. |
| 23 // It is self-owned and deletes itself when the UI reports the user selection or | 24 // It is self-owned and deletes itself when the UI reports the user selection or |
| 24 // when the net::URLRequest is cancelled. | 25 // when the net::URLRequest is cancelled. |
| 25 class SSLClientAuthHandler | 26 class CONTENT_EXPORT SSLClientAuthHandler |
| 26 : public base::RefCountedThreadSafe<SSLClientAuthHandler, | 27 : public base::RefCountedThreadSafe<SSLClientAuthHandler, |
| 27 BrowserThread::DeleteOnIOThread> { | 28 BrowserThread::DeleteOnIOThread> { |
| 28 public: | 29 public: |
| 29 SSLClientAuthHandler(net::URLRequest* request, | 30 SSLClientAuthHandler(net::URLRequest* request, |
| 30 net::SSLCertRequestInfo* cert_request_info); | 31 net::SSLCertRequestInfo* cert_request_info); |
| 31 | 32 |
| 32 // Selects a certificate and resumes the URL request with that certificate. | 33 // Selects a certificate and resumes the URL request with that certificate. |
| 33 // Should only be called on the IO thread. | 34 // Should only be called on the IO thread. |
| 34 void SelectCertificate(); | 35 void SelectCertificate(); |
| 35 | 36 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 47 // certificate selectors act on a notification matching the same host. | 48 // certificate selectors act on a notification matching the same host. |
| 48 virtual void CertificateSelectedNoNotify(net::X509Certificate* cert); | 49 virtual void CertificateSelectedNoNotify(net::X509Certificate* cert); |
| 49 | 50 |
| 50 // Returns the SSLCertRequestInfo for this handler. | 51 // Returns the SSLCertRequestInfo for this handler. |
| 51 net::SSLCertRequestInfo* cert_request_info() { return cert_request_info_; } | 52 net::SSLCertRequestInfo* cert_request_info() { return cert_request_info_; } |
| 52 | 53 |
| 53 protected: | 54 protected: |
| 54 virtual ~SSLClientAuthHandler(); | 55 virtual ~SSLClientAuthHandler(); |
| 55 | 56 |
| 56 private: | 57 private: |
| 58 friend base::RefCountedThreadSafe<SSLClientAuthHandler, |
| 59 BrowserThread::DeleteOnIOThread>; |
| 57 friend class BrowserThread; | 60 friend class BrowserThread; |
| 58 friend class DeleteTask<SSLClientAuthHandler>; | 61 friend class DeleteTask<SSLClientAuthHandler>; |
| 59 | 62 |
| 60 // Notifies that the user has selected a cert. | 63 // Notifies that the user has selected a cert. |
| 61 // Called on the IO thread. | 64 // Called on the IO thread. |
| 62 void DoCertificateSelected(net::X509Certificate* cert); | 65 void DoCertificateSelected(net::X509Certificate* cert); |
| 63 | 66 |
| 64 // Selects a client certificate on the UI thread. | 67 // Selects a client certificate on the UI thread. |
| 65 void DoSelectCertificate(int render_process_host_id, | 68 void DoSelectCertificate(int render_process_host_id, |
| 66 int render_view_host_id); | 69 int render_view_host_id); |
| 67 | 70 |
| 68 // The net::URLRequest that triggered this client auth. | 71 // The net::URLRequest that triggered this client auth. |
| 69 net::URLRequest* request_; | 72 net::URLRequest* request_; |
| 70 | 73 |
| 71 // The certs to choose from. | 74 // The certs to choose from. |
| 72 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; | 75 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; |
| 73 | 76 |
| 74 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); | 77 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler); |
| 75 }; | 78 }; |
| 76 | 79 |
| 77 class SSLClientAuthObserver : public NotificationObserver { | 80 class CONTENT_EXPORT SSLClientAuthObserver : public NotificationObserver { |
| 78 public: | 81 public: |
| 79 SSLClientAuthObserver(net::SSLCertRequestInfo* cert_request_info, | 82 SSLClientAuthObserver(net::SSLCertRequestInfo* cert_request_info, |
| 80 SSLClientAuthHandler* handler); | 83 SSLClientAuthHandler* handler); |
| 81 virtual ~SSLClientAuthObserver(); | 84 virtual ~SSLClientAuthObserver(); |
| 82 | 85 |
| 83 // UI should implement this to close the dialog. | 86 // UI should implement this to close the dialog. |
| 84 virtual void OnCertSelectedByNotification() = 0; | 87 virtual void OnCertSelectedByNotification() = 0; |
| 85 | 88 |
| 86 // NotificationObserver implementation: | 89 // NotificationObserver implementation: |
| 87 virtual void Observe(int type, | 90 virtual void Observe(int type, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 102 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; | 105 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; |
| 103 | 106 |
| 104 scoped_refptr<SSLClientAuthHandler> handler_; | 107 scoped_refptr<SSLClientAuthHandler> handler_; |
| 105 | 108 |
| 106 NotificationRegistrar notification_registrar_; | 109 NotificationRegistrar notification_registrar_; |
| 107 | 110 |
| 108 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthObserver); | 111 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthObserver); |
| 109 }; | 112 }; |
| 110 | 113 |
| 111 #endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ | 114 #endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ |
| OLD | NEW |