OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 ~ClientCertificateDelegateImpl() override { | 32 ~ClientCertificateDelegateImpl() override { |
33 if (!continue_called_) { | 33 if (!continue_called_) { |
34 BrowserThread::PostTask( | 34 BrowserThread::PostTask( |
35 BrowserThread::IO, FROM_HERE, | 35 BrowserThread::IO, FROM_HERE, |
36 base::Bind(&SSLClientAuthHandler::CancelCertificateSelection, | 36 base::Bind(&SSLClientAuthHandler::CancelCertificateSelection, |
37 handler_)); | 37 handler_)); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 // ClientCertificateDelegate implementation: | 41 // ClientCertificateDelegate implementation: |
42 void ContinueWithCertificate(net::X509Certificate* cert) override { | 42 void ContinueWithCertificate(net::X509Certificate* cert, |
| 43 net::SSLPrivateKey* private_key) override { |
43 DCHECK(!continue_called_); | 44 DCHECK(!continue_called_); |
44 continue_called_ = true; | 45 continue_called_ = true; |
45 BrowserThread::PostTask( | 46 BrowserThread::PostTask( |
46 BrowserThread::IO, FROM_HERE, | 47 BrowserThread::IO, FROM_HERE, |
47 base::Bind(&SSLClientAuthHandler::ContinueWithCertificate, handler_, | 48 base::Bind(&SSLClientAuthHandler::ContinueWithCertificate, handler_, |
48 make_scoped_refptr(cert))); | 49 make_scoped_refptr(cert), make_scoped_refptr(private_key))); |
49 } | 50 } |
50 | 51 |
51 private: | 52 private: |
52 base::WeakPtr<SSLClientAuthHandler> handler_; | 53 base::WeakPtr<SSLClientAuthHandler> handler_; |
53 bool continue_called_; | 54 bool continue_called_; |
54 | 55 |
55 DISALLOW_COPY_AND_ASSIGN(ClientCertificateDelegateImpl); | 56 DISALLOW_COPY_AND_ASSIGN(ClientCertificateDelegateImpl); |
56 }; | 57 }; |
57 | 58 |
58 void SelectCertificateOnUIThread( | 59 void SelectCertificateOnUIThread( |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 void SSLClientAuthHandler::SelectCertificate() { | 142 void SSLClientAuthHandler::SelectCertificate() { |
142 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 143 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
143 | 144 |
144 // |core_| will call DidGetClientCerts when done. | 145 // |core_| will call DidGetClientCerts when done. |
145 core_->GetClientCerts(); | 146 core_->GetClientCerts(); |
146 } | 147 } |
147 | 148 |
148 // static | 149 // static |
149 void SSLClientAuthHandler::ContinueWithCertificate( | 150 void SSLClientAuthHandler::ContinueWithCertificate( |
150 const base::WeakPtr<SSLClientAuthHandler>& handler, | 151 const base::WeakPtr<SSLClientAuthHandler>& handler, |
151 net::X509Certificate* cert) { | 152 net::X509Certificate* cert, |
| 153 net::SSLPrivateKey* private_key) { |
152 if (handler) | 154 if (handler) |
153 handler->delegate_->ContinueWithCertificate(cert); | 155 handler->delegate_->ContinueWithCertificate(cert, private_key); |
154 } | 156 } |
155 | 157 |
156 // static | 158 // static |
157 void SSLClientAuthHandler::CancelCertificateSelection( | 159 void SSLClientAuthHandler::CancelCertificateSelection( |
158 const base::WeakPtr<SSLClientAuthHandler>& handler) { | 160 const base::WeakPtr<SSLClientAuthHandler>& handler) { |
159 if (handler) | 161 if (handler) |
160 handler->delegate_->CancelCertificateSelection(); | 162 handler->delegate_->CancelCertificateSelection(); |
161 } | 163 } |
162 | 164 |
163 void SSLClientAuthHandler::DidGetClientCerts() { | 165 void SSLClientAuthHandler::DidGetClientCerts() { |
164 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 166 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
165 | 167 |
166 // Note that if |client_cert_store_| is NULL, we intentionally fall through to | 168 // Note that if |client_cert_store_| is NULL, we intentionally fall through to |
167 // SelectCertificateOnUIThread. This is for platforms where the client cert | 169 // SelectCertificateOnUIThread. This is for platforms where the client cert |
168 // matching is not performed by Chrome. Those platforms handle the cert | 170 // matching is not performed by Chrome. Those platforms handle the cert |
169 // matching before showing the dialog. | 171 // matching before showing the dialog. |
170 if (core_->has_client_cert_store() && | 172 if (core_->has_client_cert_store() && |
171 cert_request_info_->client_certs.empty()) { | 173 cert_request_info_->client_certs.empty()) { |
172 // No need to query the user if there are no certs to choose from. | 174 // No need to query the user if there are no certs to choose from. |
173 // | 175 // |
174 // TODO(davidben): The WebContents-less check on the UI thread should come | 176 // TODO(davidben): The WebContents-less check on the UI thread should come |
175 // before checking ClientCertStore; ClientCertStore itself should probably | 177 // before checking ClientCertStore; ClientCertStore itself should probably |
176 // be handled by the embedder (https://crbug.com/394131), especially since | 178 // be handled by the embedder (https://crbug.com/394131), especially since |
177 // this doesn't work on Android (https://crbug.com/345641). | 179 // this doesn't work on Android (https://crbug.com/345641). |
178 BrowserThread::PostTask( | 180 BrowserThread::PostTask( |
179 BrowserThread::IO, FROM_HERE, | 181 BrowserThread::IO, FROM_HERE, |
180 base::Bind(&SSLClientAuthHandler::ContinueWithCertificate, | 182 base::Bind(&SSLClientAuthHandler::ContinueWithCertificate, |
181 weak_factory_.GetWeakPtr(), | 183 weak_factory_.GetWeakPtr(), |
182 scoped_refptr<net::X509Certificate>())); | 184 scoped_refptr<net::X509Certificate>(), |
| 185 scoped_refptr<net::SSLPrivateKey>())); |
183 return; | 186 return; |
184 } | 187 } |
185 | 188 |
186 int render_process_host_id; | 189 int render_process_host_id; |
187 int render_frame_host_id; | 190 int render_frame_host_id; |
188 if (!ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderFrame( | 191 if (!ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderFrame( |
189 &render_process_host_id, &render_frame_host_id)) { | 192 &render_process_host_id, &render_frame_host_id)) { |
190 NOTREACHED(); | 193 NOTREACHED(); |
191 BrowserThread::PostTask( | 194 BrowserThread::PostTask( |
192 BrowserThread::IO, FROM_HERE, | 195 BrowserThread::IO, FROM_HERE, |
193 base::Bind(&SSLClientAuthHandler::CancelCertificateSelection, | 196 base::Bind(&SSLClientAuthHandler::CancelCertificateSelection, |
194 weak_factory_.GetWeakPtr())); | 197 weak_factory_.GetWeakPtr())); |
195 return; | 198 return; |
196 } | 199 } |
197 | 200 |
198 BrowserThread::PostTask( | 201 BrowserThread::PostTask( |
199 BrowserThread::UI, FROM_HERE, | 202 BrowserThread::UI, FROM_HERE, |
200 base::Bind(&SelectCertificateOnUIThread, render_process_host_id, | 203 base::Bind(&SelectCertificateOnUIThread, render_process_host_id, |
201 render_frame_host_id, cert_request_info_, | 204 render_frame_host_id, cert_request_info_, |
202 weak_factory_.GetWeakPtr())); | 205 weak_factory_.GetWeakPtr())); |
203 } | 206 } |
204 | 207 |
205 } // namespace content | 208 } // namespace content |
OLD | NEW |