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

Side by Side Diff: chrome/browser/ui/android/website_settings_popup_android.cc

Issue 418133012: Add button to page info to revoke user certificate decisions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on ToT Created 6 years, 4 months 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 | Annotate | Revision Log
OLDNEW
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"
13 #include "chrome/browser/ui/website_settings/website_settings.h" 15 #include "chrome/browser/ui/website_settings/website_settings.h"
16 #include "content/public/browser/browser_context.h"
14 #include "content/public/browser/cert_store.h" 17 #include "content/public/browser/cert_store.h"
15 #include "content/public/browser/navigation_controller.h" 18 #include "content/public/browser/navigation_controller.h"
16 #include "content/public/browser/navigation_entry.h" 19 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
18 #include "content/public/common/ssl_status.h" 21 #include "content/public/common/ssl_status.h"
19 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
20 #include "jni/WebsiteSettingsPopup_jni.h" 23 #include "jni/WebsiteSettingsPopup_jni.h"
21 #include "net/cert/x509_certificate.h" 24 #include "net/cert/x509_certificate.h"
22 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
23 26
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 nav_entry->GetSSL(), 101 nav_entry->GetSSL(),
99 content::CertStore::GetInstance())); 102 content::CertStore::GetInstance()));
100 } 103 }
101 104
102 WebsiteSettingsPopupAndroid::~WebsiteSettingsPopupAndroid() {} 105 WebsiteSettingsPopupAndroid::~WebsiteSettingsPopupAndroid() {}
103 106
104 void WebsiteSettingsPopupAndroid::Destroy(JNIEnv* env, jobject obj) { 107 void WebsiteSettingsPopupAndroid::Destroy(JNIEnv* env, jobject obj) {
105 delete this; 108 delete this;
106 } 109 }
107 110
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
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.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 }
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698