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 #include "content/browser/ssl/ssl_client_auth_handler.h" | 5 #include "content/browser/ssl/ssl_client_auth_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
9 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 9 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
10 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 10 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
11 #include "content/browser/ssl/ssl_client_auth_notification_details.h" | 11 #include "content/browser/ssl/ssl_client_auth_notification_details.h" |
12 #include "content/common/notification_service.h" | |
13 #include "content/public/browser/content_browser_client.h" | 12 #include "content/public/browser/content_browser_client.h" |
| 13 #include "content/public/browser/notification_service.h" |
14 #include "net/base/x509_certificate.h" | 14 #include "net/base/x509_certificate.h" |
15 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
16 | 16 |
17 SSLClientAuthHandler::SSLClientAuthHandler( | 17 SSLClientAuthHandler::SSLClientAuthHandler( |
18 net::URLRequest* request, | 18 net::URLRequest* request, |
19 net::SSLCertRequestInfo* cert_request_info) | 19 net::SSLCertRequestInfo* cert_request_info) |
20 : request_(request), | 20 : request_(request), |
21 cert_request_info_(cert_request_info) { | 21 cert_request_info_(cert_request_info) { |
22 } | 22 } |
23 | 23 |
(...skipping 27 matching lines...) Expand all Loading... |
51 render_process_host_id, render_view_host_id)); | 51 render_process_host_id, render_view_host_id)); |
52 } | 52 } |
53 | 53 |
54 // Sends an SSL_CLIENT_AUTH_CERT_SELECTED notification and notifies the IO | 54 // Sends an SSL_CLIENT_AUTH_CERT_SELECTED notification and notifies the IO |
55 // thread that we have selected a cert. | 55 // thread that we have selected a cert. |
56 void SSLClientAuthHandler::CertificateSelected(net::X509Certificate* cert) { | 56 void SSLClientAuthHandler::CertificateSelected(net::X509Certificate* cert) { |
57 VLOG(1) << this << " CertificateSelected " << cert; | 57 VLOG(1) << this << " CertificateSelected " << cert; |
58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
59 | 59 |
60 SSLClientAuthNotificationDetails details(cert_request_info_, cert); | 60 SSLClientAuthNotificationDetails details(cert_request_info_, cert); |
61 NotificationService* service = NotificationService::current(); | 61 content::NotificationService* service = |
| 62 content::NotificationService::current(); |
62 service->Notify(content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, | 63 service->Notify(content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, |
63 content::Source<SSLClientAuthHandler>(this), | 64 content::Source<SSLClientAuthHandler>(this), |
64 content::Details<SSLClientAuthNotificationDetails>(&details)); | 65 content::Details<SSLClientAuthNotificationDetails>(&details)); |
65 | 66 |
66 CertificateSelectedNoNotify(cert); | 67 CertificateSelectedNoNotify(cert); |
67 } | 68 } |
68 | 69 |
69 // Notifies the IO thread that we have selected a cert. | 70 // Notifies the IO thread that we have selected a cert. |
70 void SSLClientAuthHandler::CertificateSelectedNoNotify( | 71 void SSLClientAuthHandler::CertificateSelectedNoNotify( |
71 net::X509Certificate* cert) { | 72 net::X509Certificate* cert) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 << auth_details->selected_cert(); | 135 << auth_details->selected_cert(); |
135 StopObserving(); | 136 StopObserving(); |
136 handler_->CertificateSelectedNoNotify(auth_details->selected_cert()); | 137 handler_->CertificateSelectedNoNotify(auth_details->selected_cert()); |
137 OnCertSelectedByNotification(); | 138 OnCertSelectedByNotification(); |
138 } | 139 } |
139 | 140 |
140 void SSLClientAuthObserver::StartObserving() { | 141 void SSLClientAuthObserver::StartObserving() { |
141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
142 notification_registrar_.Add( | 143 notification_registrar_.Add( |
143 this, content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, | 144 this, content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, |
144 NotificationService::AllSources()); | 145 content::NotificationService::AllSources()); |
145 } | 146 } |
146 | 147 |
147 void SSLClientAuthObserver::StopObserving() { | 148 void SSLClientAuthObserver::StopObserving() { |
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
149 notification_registrar_.RemoveAll(); | 150 notification_registrar_.RemoveAll(); |
150 } | 151 } |
OLD | NEW |