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

Side by Side Diff: chrome/browser/ui/android/ssl_client_certificate_request.cc

Issue 168313002: Fix threading of certificate cache clearing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/SSLClientCertificateRequest.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/android/jni_array.h" 7 #include "base/android/jni_array.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/android/scoped_java_ref.h" 9 #include "base/android/scoped_java_ref.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "chrome/browser/ssl/ssl_client_certificate_selector.h" 15 #include "chrome/browser/ssl/ssl_client_certificate_selector.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "jni/SSLClientCertificateRequest_jni.h" 17 #include "jni/SSLClientCertificateRequest_jni.h"
18 #include "net/android/keystore_openssl.h" 18 #include "net/android/keystore_openssl.h"
19 #include "net/base/host_port_pair.h" 19 #include "net/base/host_port_pair.h"
20 #include "net/cert/cert_database.h"
20 #include "net/cert/x509_certificate.h" 21 #include "net/cert/x509_certificate.h"
21 #include "net/ssl/openssl_client_key_store.h" 22 #include "net/ssl/openssl_client_key_store.h"
22 #include "net/ssl/ssl_cert_request_info.h" 23 #include "net/ssl/ssl_cert_request_info.h"
23 #include "net/ssl/ssl_client_cert_type.h" 24 #include "net/ssl/ssl_client_cert_type.h"
24 25
26
25 namespace chrome { 27 namespace chrome {
26 28
27 namespace { 29 namespace {
28 30
29 typedef net::OpenSSLClientKeyStore::ScopedEVP_PKEY ScopedEVP_PKEY; 31 typedef net::OpenSSLClientKeyStore::ScopedEVP_PKEY ScopedEVP_PKEY;
30 32
31 // Must be called on the I/O thread to record a client certificate 33 // Must be called on the I/O thread to record a client certificate
32 // and its private key in the OpenSSLClientKeyStore. 34 // and its private key in the OpenSSLClientKeyStore.
33 void RecordClientCertificateKey( 35 void RecordClientCertificateKey(
34 const scoped_refptr<net::X509Certificate>& client_cert, 36 const scoped_refptr<net::X509Certificate>& client_cert,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // the UI thread. 190 // the UI thread.
189 content::BrowserThread::PostTaskAndReply( 191 content::BrowserThread::PostTaskAndReply(
190 content::BrowserThread::IO, 192 content::BrowserThread::IO,
191 FROM_HERE, 193 FROM_HERE,
192 base::Bind(&RecordClientCertificateKey, 194 base::Bind(&RecordClientCertificateKey,
193 client_cert, 195 client_cert,
194 base::Passed(&private_key)), 196 base::Passed(&private_key)),
195 base::Bind(*callback, client_cert)); 197 base::Bind(*callback, client_cert));
196 } 198 }
197 199
200 static void NotifyClientCertificatesChanged() {
201 net::CertDatabase::GetInstance()->OnAndroidKeyStoreChanged();
202 }
203
204 static void NotifyClientCertificatesChangedOnIOThread(JNIEnv* env, jclass) {
205 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
206 NotifyClientCertificatesChanged();
207 } else {
208 content::BrowserThread::PostTask(
209 content::BrowserThread::IO,
210 FROM_HERE,
211 base::Bind(&NotifyClientCertificatesChanged));
212 }
213 }
214
198 bool RegisterSSLClientCertificateRequestAndroid(JNIEnv* env) { 215 bool RegisterSSLClientCertificateRequestAndroid(JNIEnv* env) {
199 return RegisterNativesImpl(env); 216 return RegisterNativesImpl(env);
200 } 217 }
201 218
202 } // namespace android 219 } // namespace android
203 220
204 void ShowSSLClientCertificateSelector( 221 void ShowSSLClientCertificateSelector(
205 content::WebContents* contents, 222 content::WebContents* contents,
206 const net::HttpNetworkSession* network_session, 223 const net::HttpNetworkSession* network_session,
207 net::SSLCertRequestInfo* cert_request_info, 224 net::SSLCertRequestInfo* cert_request_info,
208 const chrome::SelectCertificateCallback& callback) { 225 const chrome::SelectCertificateCallback& callback) {
209 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 226 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
210 StartClientCertificateRequest(cert_request_info, callback); 227 StartClientCertificateRequest(cert_request_info, callback);
211 } 228 }
212 229
213 } // namespace chrome 230 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/SSLClientCertificateRequest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698