OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/ui/android/ssl_client_certificate_request.h" | 5 #include "chrome/browser/ui/android/ssl_client_certificate_request.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 const scoped_refptr<net::X509Certificate>& client_cert, | 39 const scoped_refptr<net::X509Certificate>& client_cert, |
40 crypto::ScopedEVP_PKEY private_key) { | 40 crypto::ScopedEVP_PKEY private_key) { |
41 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 41 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
42 net::OpenSSLClientKeyStore::GetInstance()->RecordClientCertPrivateKey( | 42 net::OpenSSLClientKeyStore::GetInstance()->RecordClientCertPrivateKey( |
43 client_cert.get(), private_key.get()); | 43 client_cert.get(), private_key.get()); |
44 } | 44 } |
45 | 45 |
46 void StartClientCertificateRequest( | 46 void StartClientCertificateRequest( |
47 const net::SSLCertRequestInfo* cert_request_info, | 47 const net::SSLCertRequestInfo* cert_request_info, |
48 ui::WindowAndroid* window, | 48 ui::WindowAndroid* window, |
49 scoped_ptr<content::ClientCertificateDelegate> delegate) { | 49 std::unique_ptr<content::ClientCertificateDelegate> delegate) { |
50 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 50 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
51 | 51 |
52 // Build the |key_types| JNI parameter, as a String[] | 52 // Build the |key_types| JNI parameter, as a String[] |
53 std::vector<std::string> key_types; | 53 std::vector<std::string> key_types; |
54 for (size_t n = 0; n < cert_request_info->cert_key_types.size(); ++n) { | 54 for (size_t n = 0; n < cert_request_info->cert_key_types.size(); ++n) { |
55 switch (cert_request_info->cert_key_types[n]) { | 55 switch (cert_request_info->cert_key_types[n]) { |
56 case net::CLIENT_CERT_RSA_SIGN: | 56 case net::CLIENT_CERT_RSA_SIGN: |
57 key_types.push_back("RSA"); | 57 key_types.push_back("RSA"); |
58 break; | 58 break; |
59 case net::CLIENT_CERT_ECDSA_SIGN: | 59 case net::CLIENT_CERT_ECDSA_SIGN: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // the user didn't select a certificate. | 124 // the user didn't select a certificate. |
125 static void OnSystemRequestCompletion( | 125 static void OnSystemRequestCompletion( |
126 JNIEnv* env, | 126 JNIEnv* env, |
127 const JavaParamRef<jclass>& clazz, | 127 const JavaParamRef<jclass>& clazz, |
128 jlong request_id, | 128 jlong request_id, |
129 const JavaParamRef<jobjectArray>& encoded_chain_ref, | 129 const JavaParamRef<jobjectArray>& encoded_chain_ref, |
130 const JavaParamRef<jobject>& private_key_ref) { | 130 const JavaParamRef<jobject>& private_key_ref) { |
131 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 131 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
132 | 132 |
133 // Take back ownership of the delegate object. | 133 // Take back ownership of the delegate object. |
134 scoped_ptr<content::ClientCertificateDelegate> delegate( | 134 std::unique_ptr<content::ClientCertificateDelegate> delegate( |
135 reinterpret_cast<content::ClientCertificateDelegate*>(request_id)); | 135 reinterpret_cast<content::ClientCertificateDelegate*>(request_id)); |
136 | 136 |
137 if (encoded_chain_ref == NULL || private_key_ref == NULL) { | 137 if (encoded_chain_ref == NULL || private_key_ref == NULL) { |
138 LOG(ERROR) << "No client certificate selected"; | 138 LOG(ERROR) << "No client certificate selected"; |
139 delegate->ContinueWithCertificate(nullptr); | 139 delegate->ContinueWithCertificate(nullptr); |
140 return; | 140 return; |
141 } | 141 } |
142 | 142 |
143 // Convert the encoded chain to a vector of strings. | 143 // Convert the encoded chain to a vector of strings. |
144 std::vector<std::string> encoded_chain_strings; | 144 std::vector<std::string> encoded_chain_strings; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 198 |
199 bool RegisterSSLClientCertificateRequestAndroid(JNIEnv* env) { | 199 bool RegisterSSLClientCertificateRequestAndroid(JNIEnv* env) { |
200 return RegisterNativesImpl(env); | 200 return RegisterNativesImpl(env); |
201 } | 201 } |
202 | 202 |
203 } // namespace android | 203 } // namespace android |
204 | 204 |
205 void ShowSSLClientCertificateSelector( | 205 void ShowSSLClientCertificateSelector( |
206 content::WebContents* contents, | 206 content::WebContents* contents, |
207 net::SSLCertRequestInfo* cert_request_info, | 207 net::SSLCertRequestInfo* cert_request_info, |
208 scoped_ptr<content::ClientCertificateDelegate> delegate) { | 208 std::unique_ptr<content::ClientCertificateDelegate> delegate) { |
209 ui::WindowAndroid* window = ViewAndroidHelper::FromWebContents(contents) | 209 ui::WindowAndroid* window = ViewAndroidHelper::FromWebContents(contents) |
210 ->GetViewAndroid()->GetWindowAndroid(); | 210 ->GetViewAndroid()->GetWindowAndroid(); |
211 DCHECK(window); | 211 DCHECK(window); |
212 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 212 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
213 StartClientCertificateRequest(cert_request_info, window, std::move(delegate)); | 213 StartClientCertificateRequest(cert_request_info, window, std::move(delegate)); |
214 } | 214 } |
215 | 215 |
216 } // namespace chrome | 216 } // namespace chrome |
OLD | NEW |