OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "net/cert/x509_util_android.h" | 5 #include "net/cert/x509_util_android.h" |
6 | 6 |
7 #include "base/android/build_info.h" | 7 #include "base/android/build_info.h" |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "jni/X509Util_jni.h" | 10 #include "jni/X509Util_jni.h" |
11 #include "net/cert/cert_database.h" | 11 #include "net/cert/cert_database.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 void NotifyKeyChainChanged(JNIEnv* env, jclass clazz) { | 15 void NotifyKeyChainChanged(JNIEnv* env, jclass clazz) { |
16 CertDatabase::GetInstance()->OnAndroidKeyChainChanged(); | 16 CertDatabase::GetInstance()->OnAndroidKeyChainChanged(); |
17 } | 17 } |
18 | 18 |
19 void RecordCertVerifyCapabilitiesHistogram(JNIEnv* env, | 19 void RecordCertVerifyCapabilitiesHistogram(JNIEnv* env, |
20 jclass clazz, | 20 jclass clazz, |
21 jboolean found_system_trust_roots) { | 21 jboolean found_system_trust_roots) { |
22 // Only record the histogram for 4.2 and up. Before 4.2, the platform doesn't | 22 // Only record the histogram for 4.2 and up. Before 4.2, the platform doesn't |
23 // return the certificate chain anyway. | 23 // return the certificate chain anyway. |
24 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 17) { | 24 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 17) { |
25 UMA_HISTOGRAM_BOOLEAN("Net.FoundSystemTrustRootsAndroid", | 25 UMA_HISTOGRAM_BOOLEAN("Net.FoundSystemTrustRootsAndroid", |
26 found_system_trust_roots); | 26 found_system_trust_roots); |
27 } | 27 } |
28 } | 28 } |
29 | 29 |
30 jobject GetApplicationContext(JNIEnv* env, jclass clazz) { | 30 ScopedJavaLocalRef<jobject> GetApplicationContext(JNIEnv* env, jclass clazz) { |
31 return base::android::GetApplicationContext(); | 31 ScopedJavaLocalRef<jobject> r; |
| 32 // Must use Reset to force creation of a new local ref, instead of trying to |
| 33 // adopt the global-ref'ed jobject as a local ref as the constructor would. |
| 34 r.Reset(env, base::android::GetApplicationContext()); |
| 35 return r; |
32 } | 36 } |
33 | 37 |
34 bool RegisterX509Util(JNIEnv* env) { | 38 bool RegisterX509Util(JNIEnv* env) { |
35 return RegisterNativesImpl(env); | 39 return RegisterNativesImpl(env); |
36 } | 40 } |
37 | 41 |
38 } // net namespace | 42 } // net namespace |
OLD | NEW |