Commit ac98af14 authored by meacer's avatar meacer Committed by Commit Bot

Clean up page info and rename site_details_message

site_details_message_ is only used in Android, so rename it and ifdef
to Android only.

Change-Id: I94563bc1c4ea8df1ffab903ac193944fa4a199a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1737045
Auto-Submit: Mustafa Emre Acer <meacer@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Reviewed-by: default avatarChristopher Thompson <cthomp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709623}
parent 62b9fa13
......@@ -99,8 +99,8 @@ void ConnectionInfoPopupAndroid::SetIdentityInfo(
headline = identity_info.site_identity;
}
ScopedJavaLocalRef<jstring> description =
ConvertUTF8ToJavaString(env, identity_info.identity_status_description);
ScopedJavaLocalRef<jstring> description = ConvertUTF8ToJavaString(
env, identity_info.identity_status_description_android);
base::string16 certificate_label;
// Only show the certificate viewer link if the connection actually used a
......
......@@ -674,8 +674,10 @@ void PageInfo::ComputeUIInputs(
// All about: URLs except about:blank are redirected.
DCHECK_EQ(url::kAboutBlankURL, url.spec());
site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
site_details_message_ =
#if defined(OS_ANDROID)
identity_status_description_android_ =
l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
#endif
site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
site_connection_details_ = l10n_util::GetStringFUTF16(
IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
......@@ -685,8 +687,10 @@ void PageInfo::ComputeUIInputs(
if (url.SchemeIs(content::kChromeUIScheme) || is_chrome_ui_native_scheme) {
site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
site_details_message_ =
#if defined(OS_ANDROID)
identity_status_description_android_ =
l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
#endif
site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
return;
}
......@@ -700,8 +704,6 @@ void PageInfo::ComputeUIInputs(
if (security_level == security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
#if defined(OS_CHROMEOS)
site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
site_details_message_ = l10n_util::GetStringFUTF16(
IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
#else
DCHECK(false) << "Policy certificates exist only on ChromeOS";
#endif
......@@ -720,51 +722,65 @@ void PageInfo::ComputeUIInputs(
IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
}
site_details_message_.assign(l10n_util::GetStringFUTF16(
IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
#if defined(OS_ANDROID)
// This string is shown on all non-error HTTPS sites on Android when
// the user taps "Details" link on page info.
identity_status_description_android_.assign(l10n_util::GetStringFUTF16(
IDS_PAGE_INFO_SECURE_IDENTITY_VERIFIED, issuer_name));
#endif
}
if (security_state::IsSHA1InChain(visible_security_state)) {
site_identity_status_ =
SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
site_details_message_ +=
#if defined(OS_ANDROID)
identity_status_description_android_ +=
UTF8ToUTF16("\n\n") +
l10n_util::GetStringUTF16(
IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
#endif
}
}
} else {
// HTTP or HTTPS with errors (not warnings).
site_details_message_.assign(l10n_util::GetStringUTF16(
IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
if (!security_state::IsSchemeCryptographic(visible_security_state.url) ||
!visible_security_state.certificate) {
site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
} else {
site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
}
#if defined(OS_ANDROID)
const base::string16 bullet = UTF8ToUTF16("\n • ");
std::vector<ssl_errors::ErrorInfo> errors;
ssl_errors::ErrorInfo::GetErrorsForCertStatus(
certificate_, visible_security_state.cert_status, url, &errors);
for (size_t i = 0; i < errors.size(); ++i) {
site_details_message_ += bullet;
site_details_message_ += errors[i].short_description();
identity_status_description_android_.assign(l10n_util::GetStringUTF16(
IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
for (const ssl_errors::ErrorInfo& error : errors) {
identity_status_description_android_ += bullet;
identity_status_description_android_ += error.short_description();
}
if (visible_security_state.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
site_details_message_ += ASCIIToUTF16("\n\n");
site_details_message_ +=
identity_status_description_android_ += ASCIIToUTF16("\n\n");
identity_status_description_android_ +=
l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
}
#endif
}
if (visible_security_state.malicious_content_status !=
security_state::MALICIOUS_CONTENT_STATUS_NONE) {
// The site has been flagged by Safe Browsing. Takes precedence over TLS.
base::string16 safe_browsing_details;
GetSafeBrowsingStatusByMaliciousContentStatus(
visible_security_state.malicious_content_status, &safe_browsing_status_,
&site_details_message_);
&safe_browsing_details);
#if defined(OS_ANDROID)
identity_status_description_android_ = safe_browsing_details;
#endif
#if BUILDFLAG(FULL_SAFE_BROWSING)
bool old_show_change_pw_buttons = show_change_password_buttons_;
#endif
......@@ -787,15 +803,18 @@ void PageInfo::ComputeUIInputs(
}
safety_tip_info_ = visible_security_state.safety_tip_info;
#if defined(OS_ANDROID)
if (base::FeatureList::IsEnabled(security_state::features::kSafetyTipUI)) {
// site_details_message_ is only displayed on Android when the user taps
// "Details" link on the page info. Reuse the description from page info UI.
// identity_status_description_android_ is only displayed on Android when
// the user taps "Details" link on the page info. Reuse the description from
// page info UI.
std::unique_ptr<PageInfoUI::SecurityDescription> security_description =
PageInfoUI::CreateSafetyTipSecurityDescription(safety_tip_info_);
if (security_description) {
site_details_message_ = security_description->details;
identity_status_description_android_ = security_description->details;
}
}
#endif
// Site Connection
// We consider anything less than 80 bits encryption to be weak encryption.
......@@ -1012,7 +1031,11 @@ void PageInfo::PresentSiteIdentity() {
if (base::FeatureList::IsEnabled(security_state::features::kSafetyTipUI)) {
info.safety_tip_info = safety_tip_info_;
}
info.identity_status_description = UTF16ToUTF8(site_details_message_);
#if defined(OS_ANDROID)
info.identity_status_description_android =
UTF16ToUTF8(identity_status_description_android_);
#endif
info.certificate = certificate_;
info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
info.show_change_password_buttons = show_change_password_buttons_;
......
......@@ -204,10 +204,6 @@ class PageInfo : public content::WebContentsObserver {
return safe_browsing_status_;
}
const base::string16& site_details_message() const {
return site_details_message_;
}
private:
FRIEND_TEST_ALL_PREFIXES(PageInfoTest,
NonFactoryDefaultAndRecentlyChangedPermissionsShown);
......@@ -285,10 +281,12 @@ class PageInfo : public content::WebContentsObserver {
// strings below to the corresponding UI code, in order to prevent
// unnecessary UTF-8 string conversions.
#if defined(OS_ANDROID)
// Details about the website's identity. If the website's identity has been
// verified then |site_details_message_| contains who verified the identity.
// This string will be displayed in the UI.
base::string16 site_details_message_;
// verified then |identity_status_description_android_| contains who verified
// the identity. This string will be displayed in the UI.
base::string16 identity_status_description_android_;
#endif
// Set when the user has explicitly bypassed an SSL error for this host or
// explicitly denied it (the latter of which is not currently possible in the
......
......@@ -131,9 +131,13 @@ class PageInfoUI {
// Site's safety tip info. Only set if the feature is enabled to show the
// Safety Tip UI.
security_state::SafetyTipInfo safety_tip_info;
#if defined(OS_ANDROID)
// Textual description of the site's identity status that is displayed to
// the user.
std::string identity_status_description;
std::string identity_status_description_android;
#endif
// The server certificate if a secure connection.
scoped_refptr<net::X509Certificate> certificate;
// Status of the site's connection.
......
......@@ -224,9 +224,13 @@
<message name="IDS_PAGE_INFO_INTERNAL_PAGE" desc="Message to display in the page info bubble when the page you are on is a chrome:// page or about:something.">
You're viewing a secure Chromium page
</message>
<message name="IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED" desc="The text of the identity section when the page is secure and uses a valid certificate">
<if expr="is_android">
<!-- Only used in the dialog shown after tapping "Details" in page info -->
<message name="IDS_PAGE_INFO_SECURE_IDENTITY_VERIFIED" desc="The text of the identity section when the page is secure and uses a valid certificate">
Chromium verified that <ph name="ISSUER">$1<ex>VeriSign</ex></ph> issued this website's certificate.
</message>
</if>
<!-- Session Crash -->
<message name="IDS_SESSION_CRASHED_VIEW_MESSAGE" desc="Message shown when the last session didn't exit cleanly.">
......
......@@ -224,9 +224,13 @@
<message name="IDS_PAGE_INFO_INTERNAL_PAGE" desc="Message to display in the page info bubble when the page you are on is a chrome:// page or about:something.">
You're viewing a secure Google Chrome page
</message>
<message name="IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED" desc="The text of the identity section when the page is secure and uses a valid certificate.">
<if expr="is_android">
<!-- Only used in the dialog shown after tapping "Details" in page info -->
<message name="IDS_PAGE_INFO_SECURE_IDENTITY_VERIFIED" desc="The text of the identity section when the page is secure and uses a valid certificate.">
Chrome verified that <ph name="ISSUER">$1<ex>VeriSign</ex></ph> issued this website's certificate.
</message>
</if>
<!-- Session Crash -->
<message name="IDS_SESSION_CRASHED_VIEW_MESSAGE" desc="Message shown when the last session didn't exit cleanly.">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment