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

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

Powered by Google App Engine
This is Rietveld 408576698