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 "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "chrome/browser/android/resource_mapper.h" | 11 #include "chrome/browser/android/resource_mapper.h" |
12 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 14 #include "chrome/browser/ssl/chrome_security_state_model_client.h" |
15 #include "chrome/browser/ui/website_settings/website_settings.h" | 15 #include "chrome/browser/ui/website_settings/website_settings.h" |
16 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
17 #include "components/strings/grit/components_strings.h" | 17 #include "components/strings/grit/components_strings.h" |
18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
19 #include "content/public/browser/cert_store.h" | |
20 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
21 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
22 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
23 #include "content/public/common/ssl_status.h" | 22 #include "content/public/common/ssl_status.h" |
24 #include "jni/ConnectionInfoPopup_jni.h" | 23 #include "jni/ConnectionInfoPopup_jni.h" |
25 #include "net/cert/x509_certificate.h" | 24 #include "net/cert/x509_certificate.h" |
26 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
27 | 26 |
28 using base::android::CheckException; | 27 using base::android::CheckException; |
29 using base::android::ConvertUTF8ToJavaString; | 28 using base::android::ConvertUTF8ToJavaString; |
30 using base::android::ConvertUTF16ToJavaString; | 29 using base::android::ConvertUTF16ToJavaString; |
31 using base::android::GetClass; | 30 using base::android::GetClass; |
32 using base::android::JavaParamRef; | 31 using base::android::JavaParamRef; |
33 using base::android::ScopedJavaLocalRef; | 32 using base::android::ScopedJavaLocalRef; |
34 using content::CertStore; | |
35 using content::WebContents; | 33 using content::WebContents; |
36 | 34 |
37 static ScopedJavaLocalRef<jobjectArray> GetCertificateChain( | 35 static ScopedJavaLocalRef<jobjectArray> GetCertificateChain( |
38 JNIEnv* env, | 36 JNIEnv* env, |
39 const JavaParamRef<jobject>& obj, | 37 const JavaParamRef<jobject>& obj, |
40 const JavaParamRef<jobject>& java_web_contents) { | 38 const JavaParamRef<jobject>& java_web_contents) { |
41 content::WebContents* web_contents = | 39 content::WebContents* web_contents = |
42 content::WebContents::FromJavaWebContents(java_web_contents); | 40 content::WebContents::FromJavaWebContents(java_web_contents); |
43 if (!web_contents) | 41 if (!web_contents) |
44 return ScopedJavaLocalRef<jobjectArray>(); | 42 return ScopedJavaLocalRef<jobjectArray>(); |
45 | 43 |
46 int cert_id = | 44 scoped_refptr<net::X509Certificate> cert = |
47 web_contents->GetController().GetVisibleEntry()->GetSSL().cert_id; | 45 web_contents->GetController().GetVisibleEntry()->GetSSL().certificate; |
48 scoped_refptr<net::X509Certificate> cert; | |
49 bool ok = CertStore::GetInstance()->RetrieveCert(cert_id, &cert); | |
50 CHECK(ok); | |
51 | 46 |
52 std::vector<std::string> cert_chain; | 47 std::vector<std::string> cert_chain; |
53 net::X509Certificate::OSCertHandles cert_handles = | 48 net::X509Certificate::OSCertHandles cert_handles = |
54 cert->GetIntermediateCertificates(); | 49 cert->GetIntermediateCertificates(); |
55 // 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 |
56 // already there. | 51 // already there. |
57 if (cert_handles.empty() || cert_handles[0] != cert->os_cert_handle()) | 52 if (cert_handles.empty() || cert_handles[0] != cert->os_cert_handle()) |
58 cert_handles.insert(cert_handles.begin(), cert->os_cert_handle()); | 53 cert_handles.insert(cert_handles.begin(), cert->os_cert_handle()); |
59 | 54 |
60 cert_chain.reserve(cert_handles.size()); | 55 cert_chain.reserve(cert_handles.size()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 89 |
95 popup_jobject_.Reset(env, java_website_settings_pop); | 90 popup_jobject_.Reset(env, java_website_settings_pop); |
96 | 91 |
97 ChromeSecurityStateModelClient* security_model_client = | 92 ChromeSecurityStateModelClient* security_model_client = |
98 ChromeSecurityStateModelClient::FromWebContents(web_contents); | 93 ChromeSecurityStateModelClient::FromWebContents(web_contents); |
99 DCHECK(security_model_client); | 94 DCHECK(security_model_client); |
100 | 95 |
101 presenter_.reset(new WebsiteSettings( | 96 presenter_.reset(new WebsiteSettings( |
102 this, Profile::FromBrowserContext(web_contents->GetBrowserContext()), | 97 this, Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
103 TabSpecificContentSettings::FromWebContents(web_contents), web_contents, | 98 TabSpecificContentSettings::FromWebContents(web_contents), web_contents, |
104 nav_entry->GetURL(), security_model_client->GetSecurityInfo(), | 99 nav_entry->GetURL(), security_model_client->GetSecurityInfo())); |
105 content::CertStore::GetInstance())); | |
106 } | 100 } |
107 | 101 |
108 ConnectionInfoPopupAndroid::~ConnectionInfoPopupAndroid() { | 102 ConnectionInfoPopupAndroid::~ConnectionInfoPopupAndroid() { |
109 } | 103 } |
110 | 104 |
111 void ConnectionInfoPopupAndroid::Destroy(JNIEnv* env, | 105 void ConnectionInfoPopupAndroid::Destroy(JNIEnv* env, |
112 const JavaParamRef<jobject>& obj) { | 106 const JavaParamRef<jobject>& obj) { |
113 delete this; | 107 delete this; |
114 } | 108 } |
115 | 109 |
(...skipping 11 matching lines...) Expand all Loading... |
127 { | 121 { |
128 int icon_id = ResourceMapper::MapFromChromiumId( | 122 int icon_id = ResourceMapper::MapFromChromiumId( |
129 WebsiteSettingsUI::GetIdentityIconID(identity_info.identity_status)); | 123 WebsiteSettingsUI::GetIdentityIconID(identity_info.identity_status)); |
130 | 124 |
131 // The headline and the certificate dialog link of the site's identity | 125 // The headline and the certificate dialog link of the site's identity |
132 // section is only displayed if the site's identity was verified. If the | 126 // section is only displayed if the site's identity was verified. If the |
133 // site's identity was verified, then the headline contains the organization | 127 // site's identity was verified, then the headline contains the organization |
134 // name from the provided certificate. If the organization name is not | 128 // name from the provided certificate. If the organization name is not |
135 // available than the hostname of the site is used instead. | 129 // available than the hostname of the site is used instead. |
136 std::string headline; | 130 std::string headline; |
137 if (identity_info.cert_id) { | 131 if (identity_info.certificate) { |
138 headline = identity_info.site_identity; | 132 headline = identity_info.site_identity; |
139 } | 133 } |
140 | 134 |
141 ScopedJavaLocalRef<jstring> description = | 135 ScopedJavaLocalRef<jstring> description = |
142 ConvertUTF8ToJavaString(env, identity_info.identity_status_description); | 136 ConvertUTF8ToJavaString(env, identity_info.identity_status_description); |
143 base::string16 certificate_label; | 137 base::string16 certificate_label; |
144 | 138 |
145 // Only show the certificate viewer link if the connection actually used a | 139 // Only show the certificate viewer link if the connection actually used a |
146 // certificate. | 140 // certificate. |
147 if (identity_info.identity_status != | 141 if (identity_info.identity_status != |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // There's no tab UI on Android - only connection info is shown. | 194 // There's no tab UI on Android - only connection info is shown. |
201 NOTIMPLEMENTED(); | 195 NOTIMPLEMENTED(); |
202 } | 196 } |
203 | 197 |
204 // static | 198 // static |
205 bool | 199 bool |
206 ConnectionInfoPopupAndroid::RegisterConnectionInfoPopupAndroid( | 200 ConnectionInfoPopupAndroid::RegisterConnectionInfoPopupAndroid( |
207 JNIEnv* env) { | 201 JNIEnv* env) { |
208 return RegisterNativesImpl(env); | 202 return RegisterNativesImpl(env); |
209 } | 203 } |
OLD | NEW |