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

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

Issue 2567673002: Factor getCertificateChain out of ConnectionPopupInfo (Closed)
Patch Set: Address review comments Created 4 years 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
« no previous file with comments | « chrome/browser/ui/android/page_info/certificate_chain_helper.cc ('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 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/page_info/connection_info_popup_android.h" 5 #include "chrome/browser/ui/android/page_info/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 14 matching lines...) Expand all
25 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
26 26
27 using base::android::CheckException; 27 using base::android::CheckException;
28 using base::android::ConvertUTF8ToJavaString; 28 using base::android::ConvertUTF8ToJavaString;
29 using base::android::ConvertUTF16ToJavaString; 29 using base::android::ConvertUTF16ToJavaString;
30 using base::android::GetClass; 30 using base::android::GetClass;
31 using base::android::JavaParamRef; 31 using base::android::JavaParamRef;
32 using base::android::ScopedJavaLocalRef; 32 using base::android::ScopedJavaLocalRef;
33 using content::WebContents; 33 using content::WebContents;
34 34
35 static ScopedJavaLocalRef<jobjectArray> GetCertificateChain(
36 JNIEnv* env,
37 const JavaParamRef<jobject>& obj,
38 const JavaParamRef<jobject>& java_web_contents) {
39 content::WebContents* web_contents =
40 content::WebContents::FromJavaWebContents(java_web_contents);
41 if (!web_contents)
42 return ScopedJavaLocalRef<jobjectArray>();
43
44 scoped_refptr<net::X509Certificate> cert =
45 web_contents->GetController().GetVisibleEntry()->GetSSL().certificate;
46
47 std::vector<std::string> cert_chain;
48 net::X509Certificate::OSCertHandles cert_handles =
49 cert->GetIntermediateCertificates();
50 // Make sure the peer's own cert is the first in the chain, if it's not
51 // already there.
52 if (cert_handles.empty() || cert_handles[0] != cert->os_cert_handle())
53 cert_handles.insert(cert_handles.begin(), cert->os_cert_handle());
54
55 cert_chain.reserve(cert_handles.size());
56 for (net::X509Certificate::OSCertHandles::const_iterator it =
57 cert_handles.begin();
58 it != cert_handles.end();
59 ++it) {
60 std::string cert_bytes;
61 net::X509Certificate::GetDEREncoded(*it, &cert_bytes);
62 cert_chain.push_back(cert_bytes);
63 }
64
65 return base::android::ToJavaArrayOfByteArray(env, cert_chain);
66 }
67
68 // static 35 // static
69 static jlong Init(JNIEnv* env, 36 static jlong Init(JNIEnv* env,
70 const JavaParamRef<jclass>& clazz, 37 const JavaParamRef<jclass>& clazz,
71 const JavaParamRef<jobject>& obj, 38 const JavaParamRef<jobject>& obj,
72 const JavaParamRef<jobject>& java_web_contents) { 39 const JavaParamRef<jobject>& java_web_contents) {
73 content::WebContents* web_contents = 40 content::WebContents* web_contents =
74 content::WebContents::FromJavaWebContents(java_web_contents); 41 content::WebContents::FromJavaWebContents(java_web_contents);
75 42
76 return reinterpret_cast<intptr_t>( 43 return reinterpret_cast<intptr_t>(
77 new ConnectionInfoPopupAndroid(env, obj, web_contents)); 44 new ConnectionInfoPopupAndroid(env, obj, web_contents));
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // There's no tab UI on Android - only connection info is shown. 161 // There's no tab UI on Android - only connection info is shown.
195 NOTIMPLEMENTED(); 162 NOTIMPLEMENTED();
196 } 163 }
197 164
198 // static 165 // static
199 bool 166 bool
200 ConnectionInfoPopupAndroid::RegisterConnectionInfoPopupAndroid( 167 ConnectionInfoPopupAndroid::RegisterConnectionInfoPopupAndroid(
201 JNIEnv* env) { 168 JNIEnv* env) {
202 return RegisterNativesImpl(env); 169 return RegisterNativesImpl(env);
203 } 170 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/page_info/certificate_chain_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698