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