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

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: Nits from pkasting and rsesek 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::GetFor(context)
120 ->RevokeAllowAndDenyPreferences(presenter_->GetSiteURL().host());
Ted C 2014/07/28 20:15:50 same line wrapping nit as the other files
jww 2014/08/06 00:51:47 Done.
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);
152 if (!certificate_label.empty()) {
153 Java_WebsiteSettingsPopup_addCertificateSection(
154 env,
155 popup_jobject_.obj(),
156 icon_id,
157 ConvertUTF8ToJavaString(env, headline).obj(),
158 description.obj(),
159 ConvertUTF16ToJavaString(env, certificate_label).obj());
160 }
161
162 if (identity_info.certificate_decision_made) {
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
130 Java_WebsiteSettingsPopup_addCertificateSection( 171 Java_WebsiteSettingsPopup_addCertificateSection(
131 env, 172 env,
132 popup_jobject_.obj(), 173 popup_jobject_.obj(),
133 icon_id, 174 icon_id,
134 ConvertUTF8ToJavaString(env, headline).obj(), 175 ConvertUTF8ToJavaString(env, headline).obj(),
135 description.obj(), 176 description.obj(),
136 ConvertUTF16ToJavaString(env, certificate_label).obj()); 177 ConvertUTF16ToJavaString(env, certificate_label).obj());
137 } 178 }
138 179
139 { 180 {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 void WebsiteSettingsPopupAndroid::SetFirstVisit( 213 void WebsiteSettingsPopupAndroid::SetFirstVisit(
173 const base::string16& first_visit) { 214 const base::string16& first_visit) {
174 NOTIMPLEMENTED(); 215 NOTIMPLEMENTED();
175 } 216 }
176 217
177 // static 218 // static
178 bool WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid( 219 bool WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid(
179 JNIEnv* env) { 220 JNIEnv* env) {
180 return RegisterNativesImpl(env); 221 return RegisterNativesImpl(env);
181 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698