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 "content/browser/browser_thread.h" | 7 #include "content/browser/browser_thread.h" |
8 #include "content/browser/content_browser_client.h" | 8 #include "content/browser/content_browser_client.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" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } | 51 } |
52 | 52 |
53 // Sends an SSL_CLIENT_AUTH_CERT_SELECTED notification and notifies the IO | 53 // Sends an SSL_CLIENT_AUTH_CERT_SELECTED notification and notifies the IO |
54 // thread that we have selected a cert. | 54 // thread that we have selected a cert. |
55 void SSLClientAuthHandler::CertificateSelected(net::X509Certificate* cert) { | 55 void SSLClientAuthHandler::CertificateSelected(net::X509Certificate* cert) { |
56 VLOG(1) << this << " CertificateSelected " << cert; | 56 VLOG(1) << this << " CertificateSelected " << cert; |
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
58 | 58 |
59 SSLClientAuthNotificationDetails details(cert_request_info_, cert); | 59 SSLClientAuthNotificationDetails details(cert_request_info_, cert); |
60 NotificationService* service = NotificationService::current(); | 60 NotificationService* service = NotificationService::current(); |
61 service->Notify(NotificationType::SSL_CLIENT_AUTH_CERT_SELECTED, | 61 service->Notify(content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, |
62 Source<SSLClientAuthHandler>(this), | 62 Source<SSLClientAuthHandler>(this), |
63 Details<SSLClientAuthNotificationDetails>(&details)); | 63 Details<SSLClientAuthNotificationDetails>(&details)); |
64 | 64 |
65 CertificateSelectedNoNotify(cert); | 65 CertificateSelectedNoNotify(cert); |
66 } | 66 } |
67 | 67 |
68 // Notifies the IO thread that we have selected a cert. | 68 // Notifies the IO thread that we have selected a cert. |
69 void SSLClientAuthHandler::CertificateSelectedNoNotify( | 69 void SSLClientAuthHandler::CertificateSelectedNoNotify( |
70 net::X509Certificate* cert) { | 70 net::X509Certificate* cert) { |
71 VLOG(1) << this << " CertificateSelectedNoNotify " << cert; | 71 VLOG(1) << this << " CertificateSelectedNoNotify " << cert; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 net::SSLCertRequestInfo* cert_request_info, | 104 net::SSLCertRequestInfo* cert_request_info, |
105 SSLClientAuthHandler* handler) | 105 SSLClientAuthHandler* handler) |
106 : cert_request_info_(cert_request_info), handler_(handler) { | 106 : cert_request_info_(cert_request_info), handler_(handler) { |
107 } | 107 } |
108 | 108 |
109 SSLClientAuthObserver::~SSLClientAuthObserver() { | 109 SSLClientAuthObserver::~SSLClientAuthObserver() { |
110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
111 } | 111 } |
112 | 112 |
113 void SSLClientAuthObserver::Observe( | 113 void SSLClientAuthObserver::Observe( |
114 NotificationType type, | 114 int type, |
115 const NotificationSource& source, | 115 const NotificationSource& source, |
116 const NotificationDetails& details) { | 116 const NotificationDetails& details) { |
117 VLOG(1) << "SSLClientAuthObserver::Observe " << this << " " << handler_.get(); | 117 VLOG(1) << "SSLClientAuthObserver::Observe " << this << " " << handler_.get(); |
118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
119 DCHECK(type == NotificationType::SSL_CLIENT_AUTH_CERT_SELECTED); | 119 DCHECK(type == content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED); |
120 | 120 |
121 if (Source<SSLClientAuthHandler>(source).ptr() == handler_.get()) { | 121 if (Source<SSLClientAuthHandler>(source).ptr() == handler_.get()) { |
122 VLOG(1) << "got notification from ourself " << handler_.get(); | 122 VLOG(1) << "got notification from ourself " << handler_.get(); |
123 return; | 123 return; |
124 } | 124 } |
125 | 125 |
126 SSLClientAuthNotificationDetails* auth_details = | 126 SSLClientAuthNotificationDetails* auth_details = |
127 Details<SSLClientAuthNotificationDetails>(details).ptr(); | 127 Details<SSLClientAuthNotificationDetails>(details).ptr(); |
128 if (!auth_details->IsSameHost(cert_request_info_)) | 128 if (!auth_details->IsSameHost(cert_request_info_)) |
129 return; | 129 return; |
130 | 130 |
131 VLOG(1) << this << " got matching notification for " | 131 VLOG(1) << this << " got matching notification for " |
132 << handler_.get() << ", selecting cert " | 132 << handler_.get() << ", selecting cert " |
133 << auth_details->selected_cert(); | 133 << auth_details->selected_cert(); |
134 StopObserving(); | 134 StopObserving(); |
135 handler_->CertificateSelectedNoNotify(auth_details->selected_cert()); | 135 handler_->CertificateSelectedNoNotify(auth_details->selected_cert()); |
136 OnCertSelectedByNotification(); | 136 OnCertSelectedByNotification(); |
137 } | 137 } |
138 | 138 |
139 void SSLClientAuthObserver::StartObserving() { | 139 void SSLClientAuthObserver::StartObserving() { |
140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
141 notification_registrar_.Add(this, | 141 notification_registrar_.Add( |
142 NotificationType::SSL_CLIENT_AUTH_CERT_SELECTED, | 142 this, content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, |
143 NotificationService::AllSources()); | 143 NotificationService::AllSources()); |
144 } | 144 } |
145 | 145 |
146 void SSLClientAuthObserver::StopObserving() { | 146 void SSLClientAuthObserver::StopObserving() { |
147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
148 notification_registrar_.RemoveAll(); | 148 notification_registrar_.RemoveAll(); |
149 } | 149 } |
OLD | NEW |