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.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::SSLHostState(web_contents->GetBrowserContext()). |
| 119 RevokeAllowAndDenyPreferencesHard(presenter_->site_url().host()); |
| 120 } |
| 121 |
108 void WebsiteSettingsPopupAndroid::SetIdentityInfo( | 122 void WebsiteSettingsPopupAndroid::SetIdentityInfo( |
109 const IdentityInfo& identity_info) { | 123 const IdentityInfo& identity_info) { |
110 JNIEnv* env = base::android::AttachCurrentThread(); | 124 JNIEnv* env = base::android::AttachCurrentThread(); |
111 | 125 |
112 { | 126 { |
113 int icon_id = ResourceMapper::MapFromChromiumId( | 127 int icon_id = ResourceMapper::MapFromChromiumId( |
114 WebsiteSettingsUI::GetIdentityIconID(identity_info.identity_status)); | 128 WebsiteSettingsUI::GetIdentityIconID(identity_info.identity_status)); |
115 | 129 |
116 // The headline and the certificate dialog link of the site's identity | 130 // 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 | 131 // 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 | 132 // site's identity was verified, then the headline contains the organization |
119 // name from the provided certificate. If the organization name is not | 133 // name from the provided certificate. If the organization name is not |
120 // available than the hostname of the site is used instead. | 134 // available than the hostname of the site is used instead. |
121 std::string headline; | 135 std::string headline; |
122 if (identity_info.cert_id) { | 136 if (identity_info.cert_id) { |
123 headline = identity_info.site_identity; | 137 headline = identity_info.site_identity; |
124 } | 138 } |
125 | 139 |
126 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( | 140 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( |
127 env, identity_info.identity_status_description); | 141 env, identity_info.identity_status_description); |
| 142 Java_WebsiteSettingsPopup_addDescriptionSection( |
| 143 env, |
| 144 popup_jobject_.obj(), |
| 145 icon_id, |
| 146 ConvertUTF8ToJavaString(env, headline).obj(), |
| 147 description.obj()); |
| 148 |
128 base::string16 certificate_label = | 149 base::string16 certificate_label = |
129 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON); | 150 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON); |
130 Java_WebsiteSettingsPopup_addCertificateSection( | 151 Java_WebsiteSettingsPopup_addCertificateSection( |
131 env, | 152 env, |
132 popup_jobject_.obj(), | 153 popup_jobject_.obj(), |
133 icon_id, | 154 icon_id, |
134 ConvertUTF8ToJavaString(env, headline).obj(), | 155 ConvertUTF8ToJavaString(env, headline).obj(), |
135 description.obj(), | 156 description.obj(), |
136 ConvertUTF16ToJavaString(env, certificate_label).obj()); | 157 ConvertUTF16ToJavaString(env, certificate_label).obj()); |
| 158 |
| 159 if (identity_info.certificate_decision_made) { |
| 160 base::string16 reset_button_label = l10n_util::GetStringUTF16( |
| 161 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON); |
| 162 Java_WebsiteSettingsPopup_addResetCertDecisionsButton( |
| 163 env, |
| 164 popup_jobject_.obj(), |
| 165 ConvertUTF16ToJavaString(env, reset_button_label).obj()); |
| 166 } |
137 } | 167 } |
138 | 168 |
139 { | 169 { |
140 int icon_id = ResourceMapper::MapFromChromiumId( | 170 int icon_id = ResourceMapper::MapFromChromiumId( |
141 WebsiteSettingsUI::GetConnectionIconID( | 171 WebsiteSettingsUI::GetConnectionIconID( |
142 identity_info.connection_status)); | 172 identity_info.connection_status)); |
143 | 173 |
144 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( | 174 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( |
145 env, identity_info.connection_status_description); | 175 env, identity_info.connection_status_description); |
146 Java_WebsiteSettingsPopup_addDescriptionSection( | 176 Java_WebsiteSettingsPopup_addDescriptionSection( |
(...skipping 25 matching lines...) Expand all Loading... |
172 void WebsiteSettingsPopupAndroid::SetFirstVisit( | 202 void WebsiteSettingsPopupAndroid::SetFirstVisit( |
173 const base::string16& first_visit) { | 203 const base::string16& first_visit) { |
174 NOTIMPLEMENTED(); | 204 NOTIMPLEMENTED(); |
175 } | 205 } |
176 | 206 |
177 // static | 207 // static |
178 bool WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid( | 208 bool WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid( |
179 JNIEnv* env) { | 209 JNIEnv* env) { |
180 return RegisterNativesImpl(env); | 210 return RegisterNativesImpl(env); |
181 } | 211 } |
OLD | NEW |