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 <[email protected]>
Commit-Queue: Jochen Eisinger <[email protected]>
Reviewed-by: Jochen Eisinger <[email protected]>
Reviewed-by: Yaron Friedman <[email protected]>
Reviewed-by: Christopher Thompson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#709623}
diff --git a/chrome/browser/ui/android/page_info/connection_info_popup_android.cc b/chrome/browser/ui/android/page_info/connection_info_popup_android.cc
index 9182a23..ebc513881 100644
--- a/chrome/browser/ui/android/page_info/connection_info_popup_android.cc
+++ b/chrome/browser/ui/android/page_info/connection_info_popup_android.cc
@@ -99,8 +99,8 @@
       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
diff --git a/chrome/browser/ui/page_info/page_info.cc b/chrome/browser/ui/page_info/page_info.cc
index 44b18cf..283a630 100644
--- a/chrome/browser/ui/page_info/page_info.cc
+++ b/chrome/browser/ui/page_info/page_info.cc
@@ -674,8 +674,10 @@
     // 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 @@
 
   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 @@
     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 @@
               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 @@
   }
 
   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 @@
   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_;
diff --git a/chrome/browser/ui/page_info/page_info.h b/chrome/browser/ui/page_info/page_info.h
index 2cafe15..465d401 100644
--- a/chrome/browser/ui/page_info/page_info.h
+++ b/chrome/browser/ui/page_info/page_info.h
@@ -204,10 +204,6 @@
     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 @@
   // 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
diff --git a/chrome/browser/ui/page_info/page_info_ui.h b/chrome/browser/ui/page_info/page_info_ui.h
index c17978b..8c55c7f 100644
--- a/chrome/browser/ui/page_info/page_info_ui.h
+++ b/chrome/browser/ui/page_info/page_info_ui.h
@@ -131,9 +131,13 @@
     // 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.
diff --git a/components/components_chromium_strings.grd b/components/components_chromium_strings.grd
index 17658371..ec407f5 100644
--- a/components/components_chromium_strings.grd
+++ b/components/components_chromium_strings.grd
@@ -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.">
diff --git a/components/components_google_chrome_strings.grd b/components/components_google_chrome_strings.grd
index a590332..e1b6d53 100644
--- a/components/components_google_chrome_strings.grd
+++ b/components/components_google_chrome_strings.grd
@@ -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.">