OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/connection_info_popup_android.h" | 5 #include "chrome/browser/ui/android/connection_info_popup_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "chrome/browser/android/resource_mapper.h" | 10 #include "chrome/browser/android/resource_mapper.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 | 24 |
25 using base::android::CheckException; | 25 using base::android::CheckException; |
26 using base::android::ConvertUTF8ToJavaString; | 26 using base::android::ConvertUTF8ToJavaString; |
27 using base::android::ConvertUTF16ToJavaString; | 27 using base::android::ConvertUTF16ToJavaString; |
28 using base::android::GetClass; | 28 using base::android::GetClass; |
29 using base::android::ScopedJavaLocalRef; | 29 using base::android::ScopedJavaLocalRef; |
30 using content::CertStore; | 30 using content::CertStore; |
31 using content::WebContents; | 31 using content::WebContents; |
32 | 32 |
33 static ScopedJavaLocalRef<jobjectArray> | 33 static ScopedJavaLocalRef<jobjectArray> GetCertificateChain( |
34 GetCertificateChain(JNIEnv* env, jobject obj, jobject java_web_contents) { | 34 JNIEnv* env, |
| 35 const JavaParamRef<jobject>& obj, |
| 36 const JavaParamRef<jobject>& java_web_contents) { |
35 content::WebContents* web_contents = | 37 content::WebContents* web_contents = |
36 content::WebContents::FromJavaWebContents(java_web_contents); | 38 content::WebContents::FromJavaWebContents(java_web_contents); |
37 if (!web_contents) | 39 if (!web_contents) |
38 return ScopedJavaLocalRef<jobjectArray>(); | 40 return ScopedJavaLocalRef<jobjectArray>(); |
39 | 41 |
40 int cert_id = | 42 int cert_id = |
41 web_contents->GetController().GetVisibleEntry()->GetSSL().cert_id; | 43 web_contents->GetController().GetVisibleEntry()->GetSSL().cert_id; |
42 scoped_refptr<net::X509Certificate> cert; | 44 scoped_refptr<net::X509Certificate> cert; |
43 bool ok = CertStore::GetInstance()->RetrieveCert(cert_id, &cert); | 45 bool ok = CertStore::GetInstance()->RetrieveCert(cert_id, &cert); |
44 CHECK(ok); | 46 CHECK(ok); |
(...skipping 14 matching lines...) Expand all Loading... |
59 std::string cert_bytes; | 61 std::string cert_bytes; |
60 net::X509Certificate::GetDEREncoded(*it, &cert_bytes); | 62 net::X509Certificate::GetDEREncoded(*it, &cert_bytes); |
61 cert_chain.push_back(cert_bytes); | 63 cert_chain.push_back(cert_bytes); |
62 } | 64 } |
63 | 65 |
64 return base::android::ToJavaArrayOfByteArray(env, cert_chain); | 66 return base::android::ToJavaArrayOfByteArray(env, cert_chain); |
65 } | 67 } |
66 | 68 |
67 // static | 69 // static |
68 static jlong Init(JNIEnv* env, | 70 static jlong Init(JNIEnv* env, |
69 jclass clazz, | 71 const JavaParamRef<jclass>& clazz, |
70 jobject obj, | 72 const JavaParamRef<jobject>& obj, |
71 jobject java_web_contents) { | 73 const JavaParamRef<jobject>& java_web_contents) { |
72 content::WebContents* web_contents = | 74 content::WebContents* web_contents = |
73 content::WebContents::FromJavaWebContents(java_web_contents); | 75 content::WebContents::FromJavaWebContents(java_web_contents); |
74 | 76 |
75 return reinterpret_cast<intptr_t>( | 77 return reinterpret_cast<intptr_t>( |
76 new ConnectionInfoPopupAndroid(env, obj, web_contents)); | 78 new ConnectionInfoPopupAndroid(env, obj, web_contents)); |
77 } | 79 } |
78 | 80 |
79 ConnectionInfoPopupAndroid::ConnectionInfoPopupAndroid( | 81 ConnectionInfoPopupAndroid::ConnectionInfoPopupAndroid( |
80 JNIEnv* env, | 82 JNIEnv* env, |
81 jobject java_website_settings_pop, | 83 jobject java_website_settings_pop, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // There's no tab UI on Android - only connection info is shown. | 188 // There's no tab UI on Android - only connection info is shown. |
187 NOTIMPLEMENTED(); | 189 NOTIMPLEMENTED(); |
188 } | 190 } |
189 | 191 |
190 // static | 192 // static |
191 bool | 193 bool |
192 ConnectionInfoPopupAndroid::RegisterConnectionInfoPopupAndroid( | 194 ConnectionInfoPopupAndroid::RegisterConnectionInfoPopupAndroid( |
193 JNIEnv* env) { | 195 JNIEnv* env) { |
194 return RegisterNativesImpl(env); | 196 return RegisterNativesImpl(env); |
195 } | 197 } |
OLD | NEW |