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> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/client_certificate_delegate.h" | 13 #include "content/public/browser/client_certificate_delegate.h" |
12 #include "content/public/browser/content_browser_client.h" | 14 #include "content/public/browser/content_browser_client.h" |
13 #include "content/public/browser/render_frame_host.h" | 15 #include "content/public/browser/render_frame_host.h" |
14 #include "content/public/browser/resource_request_info.h" | 16 #include "content/public/browser/resource_request_info.h" |
15 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
16 #include "net/cert/x509_certificate.h" | 18 #include "net/cert/x509_certificate.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 scoped_ptr<ClientCertificateDelegate> delegate( | 65 scoped_ptr<ClientCertificateDelegate> delegate( |
64 new ClientCertificateDelegateImpl(handler)); | 66 new ClientCertificateDelegateImpl(handler)); |
65 | 67 |
66 RenderFrameHost* rfh = | 68 RenderFrameHost* rfh = |
67 RenderFrameHost::FromID(render_process_host_id, render_frame_host_id); | 69 RenderFrameHost::FromID(render_process_host_id, render_frame_host_id); |
68 WebContents* web_contents = WebContents::FromRenderFrameHost(rfh); | 70 WebContents* web_contents = WebContents::FromRenderFrameHost(rfh); |
69 if (!web_contents) | 71 if (!web_contents) |
70 return; | 72 return; |
71 | 73 |
72 GetContentClient()->browser()->SelectClientCertificate( | 74 GetContentClient()->browser()->SelectClientCertificate( |
73 web_contents, cert_request_info, delegate.Pass()); | 75 web_contents, cert_request_info, std::move(delegate)); |
74 } | 76 } |
75 | 77 |
76 } // namespace | 78 } // namespace |
77 | 79 |
78 // A reference-counted core to allow the ClientCertStore and SSLCertRequestInfo | 80 // A reference-counted core to allow the ClientCertStore and SSLCertRequestInfo |
79 // to outlive SSLClientAuthHandler if needbe. | 81 // to outlive SSLClientAuthHandler if needbe. |
80 class SSLClientAuthHandler::Core : public base::RefCountedThreadSafe<Core> { | 82 class SSLClientAuthHandler::Core : public base::RefCountedThreadSafe<Core> { |
81 public: | 83 public: |
82 Core(const base::WeakPtr<SSLClientAuthHandler>& handler, | 84 Core(const base::WeakPtr<SSLClientAuthHandler>& handler, |
83 scoped_ptr<net::ClientCertStore> client_cert_store, | 85 scoped_ptr<net::ClientCertStore> client_cert_store, |
84 net::SSLCertRequestInfo* cert_request_info) | 86 net::SSLCertRequestInfo* cert_request_info) |
85 : handler_(handler), | 87 : handler_(handler), |
86 client_cert_store_(client_cert_store.Pass()), | 88 client_cert_store_(std::move(client_cert_store)), |
87 cert_request_info_(cert_request_info) {} | 89 cert_request_info_(cert_request_info) {} |
88 | 90 |
89 bool has_client_cert_store() const { return client_cert_store_; } | 91 bool has_client_cert_store() const { return client_cert_store_; } |
90 | 92 |
91 void GetClientCerts() { | 93 void GetClientCerts() { |
92 if (client_cert_store_) { | 94 if (client_cert_store_) { |
93 // TODO(davidben): This is still a cyclical ownership where | 95 // TODO(davidben): This is still a cyclical ownership where |
94 // GetClientCerts' requirement that |client_cert_store_| remains alive | 96 // GetClientCerts' requirement that |client_cert_store_| remains alive |
95 // until the call completes is maintained by the reference held in the | 97 // until the call completes is maintained by the reference held in the |
96 // callback. | 98 // callback. |
(...skipping 25 matching lines...) Expand all Loading... |
122 scoped_ptr<net::ClientCertStore> client_cert_store, | 124 scoped_ptr<net::ClientCertStore> client_cert_store, |
123 net::URLRequest* request, | 125 net::URLRequest* request, |
124 net::SSLCertRequestInfo* cert_request_info, | 126 net::SSLCertRequestInfo* cert_request_info, |
125 SSLClientAuthHandler::Delegate* delegate) | 127 SSLClientAuthHandler::Delegate* delegate) |
126 : request_(request), | 128 : request_(request), |
127 cert_request_info_(cert_request_info), | 129 cert_request_info_(cert_request_info), |
128 delegate_(delegate), | 130 delegate_(delegate), |
129 weak_factory_(this) { | 131 weak_factory_(this) { |
130 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 132 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
131 | 133 |
132 core_ = new Core(weak_factory_.GetWeakPtr(), client_cert_store.Pass(), | 134 core_ = new Core(weak_factory_.GetWeakPtr(), std::move(client_cert_store), |
133 cert_request_info_.get()); | 135 cert_request_info_.get()); |
134 } | 136 } |
135 | 137 |
136 SSLClientAuthHandler::~SSLClientAuthHandler() { | 138 SSLClientAuthHandler::~SSLClientAuthHandler() { |
137 } | 139 } |
138 | 140 |
139 void SSLClientAuthHandler::SelectCertificate() { | 141 void SSLClientAuthHandler::SelectCertificate() { |
140 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 142 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
141 | 143 |
142 // |core_| will call DidGetClientCerts when done. | 144 // |core_| will call DidGetClientCerts when done. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 196 } |
195 | 197 |
196 BrowserThread::PostTask( | 198 BrowserThread::PostTask( |
197 BrowserThread::UI, FROM_HERE, | 199 BrowserThread::UI, FROM_HERE, |
198 base::Bind(&SelectCertificateOnUIThread, render_process_host_id, | 200 base::Bind(&SelectCertificateOnUIThread, render_process_host_id, |
199 render_frame_host_id, cert_request_info_, | 201 render_frame_host_id, cert_request_info_, |
200 weak_factory_.GetWeakPtr())); | 202 weak_factory_.GetWeakPtr())); |
201 } | 203 } |
202 | 204 |
203 } // namespace content | 205 } // namespace content |
OLD | NEW |