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 28 matching lines...) Expand all Loading... |
39 &render_view_host_id)) | 39 &render_view_host_id)) |
40 NOTREACHED(); | 40 NOTREACHED(); |
41 | 41 |
42 // If the RVH does not exist by the time this task gets run, then the task | 42 // If the RVH does not exist by the time this task gets run, then the task |
43 // will be dropped and the scoped_refptr to SSLClientAuthHandler will go | 43 // will be dropped and the scoped_refptr to SSLClientAuthHandler will go |
44 // away, so we do not leak anything. The destructor takes care of ensuring | 44 // away, so we do not leak anything. The destructor takes care of ensuring |
45 // the net::URLRequest always gets a response. | 45 // the net::URLRequest always gets a response. |
46 BrowserThread::PostTask( | 46 BrowserThread::PostTask( |
47 BrowserThread::UI, FROM_HERE, | 47 BrowserThread::UI, FROM_HERE, |
48 NewRunnableMethod( | 48 NewRunnableMethod( |
49 this, &SSLClientAuthHandler::ShowClientCertificateRequestDialog, | 49 this, &SSLClientAuthHandler::DoSelectCertificate, |
50 render_process_host_id, render_view_host_id)); | 50 render_process_host_id, render_view_host_id)); |
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); |
(...skipping 27 matching lines...) Expand all Loading... |
87 | 87 |
88 ResourceDispatcherHostRequestInfo* info = | 88 ResourceDispatcherHostRequestInfo* info = |
89 ResourceDispatcherHost::InfoForRequest(request_); | 89 ResourceDispatcherHost::InfoForRequest(request_); |
90 if (info) | 90 if (info) |
91 info->set_ssl_client_auth_handler(NULL); | 91 info->set_ssl_client_auth_handler(NULL); |
92 | 92 |
93 request_ = NULL; | 93 request_ = NULL; |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 void SSLClientAuthHandler::ShowClientCertificateRequestDialog( | 97 void SSLClientAuthHandler::DoSelectCertificate( |
98 int render_process_host_id, int render_view_host_id) { | 98 int render_process_host_id, int render_view_host_id) { |
99 content::GetContentClient()->browser()->ShowClientCertificateRequestDialog( | 99 content::GetContentClient()->browser()->SelectClientCertificate( |
100 render_process_host_id, render_view_host_id, this); | 100 render_process_host_id, render_view_host_id, this); |
101 } | 101 } |
102 | 102 |
103 SSLClientAuthObserver::SSLClientAuthObserver( | 103 SSLClientAuthObserver::SSLClientAuthObserver( |
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() { |
(...skipping 30 matching lines...) Expand all Loading... |
140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
141 notification_registrar_.Add( | 141 notification_registrar_.Add( |
142 this, content::NOTIFICATION_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 |