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

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

Issue 1308363003: Revert of jni_generator: Make all object-returning natives return ScopedJavaLocalRef. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
OLDNEW
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
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 jobjectArray GetCertificateChain(JNIEnv* env,
34 GetCertificateChain(JNIEnv* env, jobject obj, jobject java_web_contents) { 34 jobject obj,
35 jobject java_web_contents) {
35 content::WebContents* web_contents = 36 content::WebContents* web_contents =
36 content::WebContents::FromJavaWebContents(java_web_contents); 37 content::WebContents::FromJavaWebContents(java_web_contents);
37 if (!web_contents) 38 if (!web_contents)
38 return ScopedJavaLocalRef<jobjectArray>(); 39 return NULL;
39 40
40 int cert_id = 41 int cert_id =
41 web_contents->GetController().GetVisibleEntry()->GetSSL().cert_id; 42 web_contents->GetController().GetVisibleEntry()->GetSSL().cert_id;
42 scoped_refptr<net::X509Certificate> cert; 43 scoped_refptr<net::X509Certificate> cert;
43 bool ok = CertStore::GetInstance()->RetrieveCert(cert_id, &cert); 44 bool ok = CertStore::GetInstance()->RetrieveCert(cert_id, &cert);
44 CHECK(ok); 45 CHECK(ok);
45 46
46 std::vector<std::string> cert_chain; 47 std::vector<std::string> cert_chain;
47 net::X509Certificate::OSCertHandles cert_handles = 48 net::X509Certificate::OSCertHandles cert_handles =
48 cert->GetIntermediateCertificates(); 49 cert->GetIntermediateCertificates();
49 // Make sure the peer's own cert is the first in the chain, if it's not 50 // Make sure the peer's own cert is the first in the chain, if it's not
50 // already there. 51 // already there.
51 if (cert_handles.empty() || cert_handles[0] != cert->os_cert_handle()) 52 if (cert_handles.empty() || cert_handles[0] != cert->os_cert_handle())
52 cert_handles.insert(cert_handles.begin(), cert->os_cert_handle()); 53 cert_handles.insert(cert_handles.begin(), cert->os_cert_handle());
53 54
54 cert_chain.reserve(cert_handles.size()); 55 cert_chain.reserve(cert_handles.size());
55 for (net::X509Certificate::OSCertHandles::const_iterator it = 56 for (net::X509Certificate::OSCertHandles::const_iterator it =
56 cert_handles.begin(); 57 cert_handles.begin();
57 it != cert_handles.end(); 58 it != cert_handles.end();
58 ++it) { 59 ++it) {
59 std::string cert_bytes; 60 std::string cert_bytes;
60 net::X509Certificate::GetDEREncoded(*it, &cert_bytes); 61 net::X509Certificate::GetDEREncoded(*it, &cert_bytes);
61 cert_chain.push_back(cert_bytes); 62 cert_chain.push_back(cert_bytes);
62 } 63 }
63 64
64 return base::android::ToJavaArrayOfByteArray(env, cert_chain); 65 // OK to release, JNI binding.
66 return base::android::ToJavaArrayOfByteArray(env, cert_chain).Release();
65 } 67 }
66 68
67 // static 69 // static
68 static jlong Init(JNIEnv* env, 70 static jlong Init(JNIEnv* env,
69 jclass clazz, 71 jclass clazz,
70 jobject obj, 72 jobject obj,
71 jobject java_web_contents) { 73 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
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698