OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/ui/android/website_settings_popup_android.h" | 5 #include "chrome/browser/ui/android/website_settings_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" |
11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" | |
14 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" | |
15 #include "chrome/browser/ui/website_settings/website_settings.h" | 13 #include "chrome/browser/ui/website_settings/website_settings.h" |
16 #include "content/public/browser/browser_context.h" | |
17 #include "content/public/browser/cert_store.h" | 14 #include "content/public/browser/cert_store.h" |
18 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
19 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
20 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
21 #include "content/public/common/ssl_status.h" | 18 #include "content/public/common/ssl_status.h" |
22 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
23 #include "jni/WebsiteSettingsPopup_jni.h" | 20 #include "jni/WebsiteSettingsPopup_jni.h" |
24 #include "net/cert/x509_certificate.h" | 21 #include "net/cert/x509_certificate.h" |
25 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
26 | 23 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 nav_entry->GetSSL(), | 98 nav_entry->GetSSL(), |
102 content::CertStore::GetInstance())); | 99 content::CertStore::GetInstance())); |
103 } | 100 } |
104 | 101 |
105 WebsiteSettingsPopupAndroid::~WebsiteSettingsPopupAndroid() {} | 102 WebsiteSettingsPopupAndroid::~WebsiteSettingsPopupAndroid() {} |
106 | 103 |
107 void WebsiteSettingsPopupAndroid::Destroy(JNIEnv* env, jobject obj) { | 104 void WebsiteSettingsPopupAndroid::Destroy(JNIEnv* env, jobject obj) { |
108 delete this; | 105 delete this; |
109 } | 106 } |
110 | 107 |
111 void WebsiteSettingsPopupAndroid::ResetCertDecisions( | |
112 JNIEnv* env, | |
113 jobject obj, | |
114 jobject java_web_contents) { | |
115 content::WebContents* web_contents = | |
116 content::WebContents::FromJavaWebContents(java_web_contents); | |
117 if (!web_contents) | |
118 return; | |
119 ChromeSSLHostStateDelegate* delegate = | |
120 presenter_->chrome_ssl_host_state_delegate(); | |
121 DCHECK(delegate); | |
122 delegate->RevokeUserDecisionsHard(presenter_->site_url().host()); | |
123 } | |
124 | |
125 void WebsiteSettingsPopupAndroid::SetIdentityInfo( | 108 void WebsiteSettingsPopupAndroid::SetIdentityInfo( |
126 const IdentityInfo& identity_info) { | 109 const IdentityInfo& identity_info) { |
127 JNIEnv* env = base::android::AttachCurrentThread(); | 110 JNIEnv* env = base::android::AttachCurrentThread(); |
128 | 111 |
129 { | 112 { |
130 int icon_id = ResourceMapper::MapFromChromiumId( | 113 int icon_id = ResourceMapper::MapFromChromiumId( |
131 WebsiteSettingsUI::GetIdentityIconID(identity_info.identity_status)); | 114 WebsiteSettingsUI::GetIdentityIconID(identity_info.identity_status)); |
132 | 115 |
133 // The headline and the certificate dialog link of the site's identity | 116 // The headline and the certificate dialog link of the site's identity |
134 // section is only displayed if the site's identity was verified. If the | 117 // section is only displayed if the site's identity was verified. If the |
135 // site's identity was verified, then the headline contains the organization | 118 // site's identity was verified, then the headline contains the organization |
136 // name from the provided certificate. If the organization name is not | 119 // name from the provided certificate. If the organization name is not |
137 // available than the hostname of the site is used instead. | 120 // available than the hostname of the site is used instead. |
138 std::string headline; | 121 std::string headline; |
139 if (identity_info.cert_id) { | 122 if (identity_info.cert_id) { |
140 headline = identity_info.site_identity; | 123 headline = identity_info.site_identity; |
141 } | 124 } |
142 | 125 |
143 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( | 126 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( |
144 env, identity_info.identity_status_description); | 127 env, identity_info.identity_status_description); |
145 Java_WebsiteSettingsPopup_addDescriptionSection( | |
146 env, | |
147 popup_jobject_.obj(), | |
148 icon_id, | |
149 ConvertUTF8ToJavaString(env, headline).obj(), | |
150 description.obj()); | |
151 | |
152 base::string16 certificate_label = | 128 base::string16 certificate_label = |
153 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON); | 129 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON); |
154 Java_WebsiteSettingsPopup_addCertificateSection( | 130 Java_WebsiteSettingsPopup_addCertificateSection( |
155 env, | 131 env, |
156 popup_jobject_.obj(), | 132 popup_jobject_.obj(), |
157 icon_id, | 133 icon_id, |
158 ConvertUTF8ToJavaString(env, headline).obj(), | 134 ConvertUTF8ToJavaString(env, headline).obj(), |
159 description.obj(), | 135 description.obj(), |
160 ConvertUTF16ToJavaString(env, certificate_label).obj()); | 136 ConvertUTF16ToJavaString(env, certificate_label).obj()); |
161 | |
162 if (identity_info.show_ssl_decision_revoke_button) { | |
163 base::string16 reset_button_label = l10n_util::GetStringUTF16( | |
164 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON); | |
165 Java_WebsiteSettingsPopup_addResetCertDecisionsButton( | |
166 env, | |
167 popup_jobject_.obj(), | |
168 ConvertUTF16ToJavaString(env, reset_button_label).obj()); | |
169 } | |
170 } | 137 } |
171 | 138 |
172 { | 139 { |
173 int icon_id = ResourceMapper::MapFromChromiumId( | 140 int icon_id = ResourceMapper::MapFromChromiumId( |
174 WebsiteSettingsUI::GetConnectionIconID( | 141 WebsiteSettingsUI::GetConnectionIconID( |
175 identity_info.connection_status)); | 142 identity_info.connection_status)); |
176 | 143 |
177 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( | 144 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( |
178 env, identity_info.connection_status_description); | 145 env, identity_info.connection_status_description); |
179 Java_WebsiteSettingsPopup_addDescriptionSection( | 146 Java_WebsiteSettingsPopup_addDescriptionSection( |
(...skipping 25 matching lines...) Expand all Loading... |
205 void WebsiteSettingsPopupAndroid::SetFirstVisit( | 172 void WebsiteSettingsPopupAndroid::SetFirstVisit( |
206 const base::string16& first_visit) { | 173 const base::string16& first_visit) { |
207 NOTIMPLEMENTED(); | 174 NOTIMPLEMENTED(); |
208 } | 175 } |
209 | 176 |
210 // static | 177 // static |
211 bool WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid( | 178 bool WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid( |
212 JNIEnv* env) { | 179 JNIEnv* env) { |
213 return RegisterNativesImpl(env); | 180 return RegisterNativesImpl(env); |
214 } | 181 } |
OLD | NEW |