Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: content/browser/ssl/ssl_client_auth_handler.cc

Issue 596873002: Remove SSLClientAuthHandler's RDH dependency. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/loader/resource_dispatcher_host_impl.h" 8 #include "base/callback_helpers.h"
9 #include "content/browser/loader/resource_request_info_impl.h" 9 #include "content/browser/loader/resource_request_info_impl.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/content_browser_client.h" 11 #include "content/public/browser/content_browser_client.h"
12 #include "net/cert/x509_certificate.h" 12 #include "net/cert/x509_certificate.h"
13 #include "net/http/http_transaction_factory.h" 13 #include "net/http/http_transaction_factory.h"
14 #include "net/ssl/client_cert_store.h" 14 #include "net/ssl/client_cert_store.h"
15 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
16 #include "net/url_request/url_request_context.h" 16 #include "net/url_request/url_request_context.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 SSLClientAuthHandler::SSLClientAuthHandler( 20 SSLClientAuthHandler::SSLClientAuthHandler(
21 scoped_ptr<net::ClientCertStore> client_cert_store, 21 scoped_ptr<net::ClientCertStore> client_cert_store,
22 net::URLRequest* request, 22 net::URLRequest* request,
23 net::SSLCertRequestInfo* cert_request_info) 23 net::SSLCertRequestInfo* cert_request_info,
24 const SSLClientAuthHandler::CertificateCallback& callback)
24 : request_(request), 25 : request_(request),
25 http_network_session_( 26 http_network_session_(
26 request_->context()->http_transaction_factory()->GetSession()), 27 request_->context()->http_transaction_factory()->GetSession()),
27 cert_request_info_(cert_request_info), 28 cert_request_info_(cert_request_info),
28 client_cert_store_(client_cert_store.Pass()) { 29 client_cert_store_(client_cert_store.Pass()),
30 callback_(callback) {
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
30 } 32 }
31 33
32 SSLClientAuthHandler::~SSLClientAuthHandler() { 34 SSLClientAuthHandler::~SSLClientAuthHandler() {
33 // If we were simply dropped, then act as if we selected no certificate. 35 // If we were simply dropped, then act as if we selected no certificate.
34 DoCertificateSelected(NULL); 36 DoCertificateSelected(NULL);
35 } 37 }
36 38
37 void SSLClientAuthHandler::OnRequestCancelled() { 39 void SSLClientAuthHandler::OnRequestCancelled() {
38 request_ = NULL; 40 request_ = NULL;
41 callback_.Reset();
39 } 42 }
40 43
41 void SSLClientAuthHandler::SelectCertificate() { 44 void SSLClientAuthHandler::SelectCertificate() {
42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
43 DCHECK(request_); 46 DCHECK(request_);
44 47
45 if (client_cert_store_) { 48 if (client_cert_store_) {
46 client_cert_store_->GetClientCerts( 49 client_cert_store_->GetClientCerts(
47 *cert_request_info_, 50 *cert_request_info_,
48 &cert_request_info_->client_certs, 51 &cert_request_info_->client_certs,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 render_process_host_id, render_frame_host_id)); 100 render_process_host_id, render_frame_host_id));
98 } 101 }
99 102
100 void SSLClientAuthHandler::DoCertificateSelected(net::X509Certificate* cert) { 103 void SSLClientAuthHandler::DoCertificateSelected(net::X509Certificate* cert) {
101 VLOG(1) << this << " DoCertificateSelected " << cert; 104 VLOG(1) << this << " DoCertificateSelected " << cert;
102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
103 // request_ could have been NULLed if the request was cancelled while the 106 // request_ could have been NULLed if the request was cancelled while the
104 // user was choosing a cert, or because we have already responded to the 107 // user was choosing a cert, or because we have already responded to the
105 // certificate. 108 // certificate.
106 if (request_) { 109 if (request_) {
107 request_->ContinueWithCertificate(cert); 110 DCHECK(!callback_.is_null());
108 111 base::ResetAndReturn(&callback_).Run(cert);
109 ResourceDispatcherHostImpl::Get()->
110 ClearSSLClientAuthHandlerForRequest(request_);
111 request_ = NULL; 112 request_ = NULL;
mmenke 2014/09/23 19:24:23 Should we clear request_ first? If the ResetAndRe
davidben 2014/09/23 21:22:02 No longer relevant.
112 } 113 }
113 } 114 }
114 115
115 void SSLClientAuthHandler::DoSelectCertificate( 116 void SSLClientAuthHandler::DoSelectCertificate(
116 int render_process_host_id, int render_frame_host_id) { 117 int render_process_host_id, int render_frame_host_id) {
117 GetContentClient()->browser()->SelectClientCertificate( 118 GetContentClient()->browser()->SelectClientCertificate(
118 render_process_host_id, 119 render_process_host_id,
119 render_frame_host_id, 120 render_frame_host_id,
120 http_network_session_, 121 http_network_session_,
121 cert_request_info_.get(), 122 cert_request_info_.get(),
122 base::Bind(&SSLClientAuthHandler::CertificateSelected, this)); 123 base::Bind(&SSLClientAuthHandler::CertificateSelected, this));
123 } 124 }
124 125
125 } // namespace content 126 } // namespace content
OLDNEW
« content/browser/loader/resource_loader.cc ('K') | « content/browser/ssl/ssl_client_auth_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698