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

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

Issue 516703002: Replaced the current WebsiteSettings dialog with a new PageInfo dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing template files for PageInfoConnectionType enum Created 6 years, 3 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
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_legacy_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" 13 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
14 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" 14 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
15 #include "chrome/browser/ui/website_settings/website_settings.h" 15 #include "chrome/browser/ui/website_settings/website_settings.h"
16 #include "chrome/grit/generated_resources.h"
17 #include "content/public/browser/browser_context.h" 16 #include "content/public/browser/browser_context.h"
18 #include "content/public/browser/cert_store.h" 17 #include "content/public/browser/cert_store.h"
19 #include "content/public/browser/navigation_controller.h" 18 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/navigation_entry.h" 19 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/ssl_status.h" 21 #include "content/public/common/ssl_status.h"
23 #include "jni/WebsiteSettingsPopup_jni.h" 22 #include "grit/generated_resources.h"
23 #include "jni/WebsiteSettingsPopupLegacy_jni.h"
24 #include "net/cert/x509_certificate.h" 24 #include "net/cert/x509_certificate.h"
25 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
26 26
27 using base::android::CheckException; 27 using base::android::CheckException;
28 using base::android::ConvertUTF8ToJavaString; 28 using base::android::ConvertUTF8ToJavaString;
29 using base::android::ConvertUTF16ToJavaString; 29 using base::android::ConvertUTF16ToJavaString;
30 using base::android::GetClass; 30 using base::android::GetClass;
31 using base::android::ScopedJavaLocalRef; 31 using base::android::ScopedJavaLocalRef;
32 using content::CertStore; 32 using content::CertStore;
33 using content::WebContents; 33 using content::WebContents;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 // static 71 // static
72 static jlong Init(JNIEnv* env, 72 static jlong Init(JNIEnv* env,
73 jclass clazz, 73 jclass clazz,
74 jobject obj, 74 jobject obj,
75 jobject java_web_contents) { 75 jobject java_web_contents) {
76 content::WebContents* web_contents = 76 content::WebContents* web_contents =
77 content::WebContents::FromJavaWebContents(java_web_contents); 77 content::WebContents::FromJavaWebContents(java_web_contents);
78 78
79 return reinterpret_cast<intptr_t>( 79 return reinterpret_cast<intptr_t>(
80 new WebsiteSettingsPopupAndroid(env, obj, web_contents)); 80 new WebsiteSettingsPopupLegacyAndroid(env, obj, web_contents));
81 } 81 }
82 82
83 WebsiteSettingsPopupAndroid::WebsiteSettingsPopupAndroid( 83 WebsiteSettingsPopupLegacyAndroid::WebsiteSettingsPopupLegacyAndroid(
84 JNIEnv* env, 84 JNIEnv* env,
85 jobject java_website_settings_pop, 85 jobject java_website_settings_pop,
86 WebContents* web_contents) { 86 WebContents* web_contents) {
87 // Important to use GetVisibleEntry to match what's showing in the omnibox. 87 // Important to use GetVisibleEntry to match what's showing in the omnibox.
88 content::NavigationEntry* nav_entry = 88 content::NavigationEntry* nav_entry =
89 web_contents->GetController().GetVisibleEntry(); 89 web_contents->GetController().GetVisibleEntry();
90 if (nav_entry == NULL) 90 if (nav_entry == NULL)
91 return; 91 return;
92 92
93 popup_jobject_.Reset(env, java_website_settings_pop); 93 popup_jobject_.Reset(env, java_website_settings_pop);
94 94
95 presenter_.reset(new WebsiteSettings( 95 presenter_.reset(new WebsiteSettings(
96 this, 96 this,
97 Profile::FromBrowserContext(web_contents->GetBrowserContext()), 97 Profile::FromBrowserContext(web_contents->GetBrowserContext()),
98 TabSpecificContentSettings::FromWebContents(web_contents), 98 TabSpecificContentSettings::FromWebContents(web_contents),
99 InfoBarService::FromWebContents(web_contents), 99 InfoBarService::FromWebContents(web_contents),
100 nav_entry->GetURL(), 100 nav_entry->GetURL(),
101 nav_entry->GetSSL(), 101 nav_entry->GetSSL(),
102 content::CertStore::GetInstance())); 102 content::CertStore::GetInstance()));
103 } 103 }
104 104
105 WebsiteSettingsPopupAndroid::~WebsiteSettingsPopupAndroid() {} 105 WebsiteSettingsPopupLegacyAndroid::~WebsiteSettingsPopupLegacyAndroid() {
106 }
106 107
107 void WebsiteSettingsPopupAndroid::Destroy(JNIEnv* env, jobject obj) { 108 void WebsiteSettingsPopupLegacyAndroid::Destroy(JNIEnv* env, jobject obj) {
108 delete this; 109 delete this;
109 } 110 }
110 111
111 void WebsiteSettingsPopupAndroid::ResetCertDecisions( 112 void WebsiteSettingsPopupLegacyAndroid::ResetCertDecisions(
112 JNIEnv* env, 113 JNIEnv* env,
113 jobject obj, 114 jobject obj,
114 jobject java_web_contents) { 115 jobject java_web_contents) {
115 content::WebContents* web_contents = 116 content::WebContents* web_contents =
116 content::WebContents::FromJavaWebContents(java_web_contents); 117 content::WebContents::FromJavaWebContents(java_web_contents);
117 if (!web_contents) 118 if (!web_contents)
118 return; 119 return;
119 ChromeSSLHostStateDelegate* delegate = 120 ChromeSSLHostStateDelegate* delegate =
120 presenter_->chrome_ssl_host_state_delegate(); 121 presenter_->chrome_ssl_host_state_delegate();
121 DCHECK(delegate); 122 DCHECK(delegate);
122 delegate->RevokeUserDecisionsHard(presenter_->site_url().host()); 123 delegate->RevokeUserDecisionsHard(presenter_->site_url().host());
123 } 124 }
124 125
125 void WebsiteSettingsPopupAndroid::SetIdentityInfo( 126 void WebsiteSettingsPopupLegacyAndroid::SetIdentityInfo(
126 const IdentityInfo& identity_info) { 127 const IdentityInfo& identity_info) {
127 JNIEnv* env = base::android::AttachCurrentThread(); 128 JNIEnv* env = base::android::AttachCurrentThread();
128 129
129 { 130 {
130 int icon_id = ResourceMapper::MapFromChromiumId( 131 int icon_id = ResourceMapper::MapFromChromiumId(
131 WebsiteSettingsUI::GetIdentityIconID(identity_info.identity_status)); 132 WebsiteSettingsUI::GetIdentityIconID(identity_info.identity_status));
132 133
133 // The headline and the certificate dialog link of the site's identity 134 // The headline and the certificate dialog link of the site's identity
134 // section is only displayed if the site's identity was verified. If the 135 // section is only displayed if the site's identity was verified. If the
135 // site's identity was verified, then the headline contains the organization 136 // site's identity was verified, then the headline contains the organization
136 // name from the provided certificate. If the organization name is not 137 // name from the provided certificate. If the organization name is not
137 // available than the hostname of the site is used instead. 138 // available than the hostname of the site is used instead.
138 std::string headline; 139 std::string headline;
139 if (identity_info.cert_id) { 140 if (identity_info.cert_id) {
140 headline = identity_info.site_identity; 141 headline = identity_info.site_identity;
141 } 142 }
142 143
143 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( 144 ScopedJavaLocalRef<jstring> description =
144 env, identity_info.identity_status_description); 145 ConvertUTF8ToJavaString(env, identity_info.identity_status_description);
145 base::string16 certificate_label = 146 base::string16 certificate_label =
146 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON); 147 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON);
147 Java_WebsiteSettingsPopup_addCertificateSection( 148 Java_WebsiteSettingsPopupLegacy_addCertificateSection(
148 env, 149 env,
149 popup_jobject_.obj(), 150 popup_jobject_.obj(),
150 icon_id, 151 icon_id,
151 ConvertUTF8ToJavaString(env, headline).obj(), 152 ConvertUTF8ToJavaString(env, headline).obj(),
152 description.obj(), 153 description.obj(),
153 ConvertUTF16ToJavaString(env, certificate_label).obj()); 154 ConvertUTF16ToJavaString(env, certificate_label).obj());
154 155
155 if (identity_info.show_ssl_decision_revoke_button) { 156 if (identity_info.show_ssl_decision_revoke_button) {
156 base::string16 reset_button_label = l10n_util::GetStringUTF16( 157 base::string16 reset_button_label = l10n_util::GetStringUTF16(
157 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON); 158 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON);
158 Java_WebsiteSettingsPopup_addResetCertDecisionsButton( 159 Java_WebsiteSettingsPopupLegacy_addResetCertDecisionsButton(
159 env, 160 env,
160 popup_jobject_.obj(), 161 popup_jobject_.obj(),
161 ConvertUTF16ToJavaString(env, reset_button_label).obj()); 162 ConvertUTF16ToJavaString(env, reset_button_label).obj());
162 } 163 }
163 } 164 }
164 165
165 { 166 {
166 int icon_id = ResourceMapper::MapFromChromiumId( 167 int icon_id = ResourceMapper::MapFromChromiumId(
167 WebsiteSettingsUI::GetConnectionIconID( 168 WebsiteSettingsUI::GetConnectionIconID(
168 identity_info.connection_status)); 169 identity_info.connection_status));
169 170
170 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString( 171 ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString(
171 env, identity_info.connection_status_description); 172 env, identity_info.connection_status_description);
172 Java_WebsiteSettingsPopup_addDescriptionSection( 173 Java_WebsiteSettingsPopupLegacy_addDescriptionSection(
173 env, popup_jobject_.obj(), icon_id, NULL, description.obj()); 174 env, popup_jobject_.obj(), icon_id, NULL, description.obj());
174 } 175 }
175 176
176 Java_WebsiteSettingsPopup_addMoreInfoLink(env, popup_jobject_.obj(), 177 Java_WebsiteSettingsPopupLegacy_addMoreInfoLink(
178 env,
179 popup_jobject_.obj(),
177 ConvertUTF8ToJavaString( 180 ConvertUTF8ToJavaString(
178 env, l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK)).obj()); 181 env, l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK)).obj());
179 Java_WebsiteSettingsPopup_showDialog(env, popup_jobject_.obj()); 182 Java_WebsiteSettingsPopupLegacy_showDialog(env, popup_jobject_.obj());
180 } 183 }
181 184
182 void WebsiteSettingsPopupAndroid::SetCookieInfo( 185 void WebsiteSettingsPopupLegacyAndroid::SetCookieInfo(
183 const CookieInfoList& cookie_info_list) { 186 const CookieInfoList& cookie_info_list) {
184 NOTIMPLEMENTED(); 187 NOTIMPLEMENTED();
185 } 188 }
186 189
187 void WebsiteSettingsPopupAndroid::SetPermissionInfo( 190 void WebsiteSettingsPopupLegacyAndroid::SetPermissionInfo(
188 const PermissionInfoList& permission_info_list) { 191 const PermissionInfoList& permission_info_list) {
189 NOTIMPLEMENTED(); 192 NOTIMPLEMENTED();
190 } 193 }
191 194
192 void WebsiteSettingsPopupAndroid::SetSelectedTab( 195 void WebsiteSettingsPopupLegacyAndroid::SetSelectedTab(
193 WebsiteSettingsUI::TabId tab_id) { 196 WebsiteSettingsUI::TabId tab_id) {
194 // There's no tab UI on Android - only connection info is shown. 197 // There's no tab UI on Android - only connection info is shown.
195 NOTIMPLEMENTED(); 198 NOTIMPLEMENTED();
196 } 199 }
197 200
198 void WebsiteSettingsPopupAndroid::SetFirstVisit( 201 void WebsiteSettingsPopupLegacyAndroid::SetFirstVisit(
199 const base::string16& first_visit) { 202 const base::string16& first_visit) {
200 NOTIMPLEMENTED(); 203 NOTIMPLEMENTED();
201 } 204 }
202 205
203 // static 206 // static
204 bool WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid( 207 bool
208 WebsiteSettingsPopupLegacyAndroid::RegisterWebsiteSettingsPopupLegacyAndroid(
205 JNIEnv* env) { 209 JNIEnv* env) {
206 return RegisterNativesImpl(env); 210 return RegisterNativesImpl(env);
207 } 211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698