Commit e0a1dc44 authored by Livvie Lin's avatar Livvie Lin Committed by Commit Bot

Use grey triangle icon for HTTP when experiment enabled (iOS)

Bug: 1008219
Change-Id: I7517202a58ab3d363d9f8f6ba354f7c2a6dd08e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1884428Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Livvie Lin <livvielin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711711}
parent 338ed667
...@@ -79,6 +79,7 @@ source_set("location_bar") { ...@@ -79,6 +79,7 @@ source_set("location_bar") {
"//ios/public/provider/chrome/browser/voice", "//ios/public/provider/chrome/browser/voice",
"//ios/third_party/material_components_ios", "//ios/third_party/material_components_ios",
"//ios/third_party/material_roboto_font_loader_ios", "//ios/third_party/material_roboto_font_loader_ios",
"//ios/web/common",
"//ios/web/public:public", "//ios/web/public:public",
"//ios/web/public/security", "//ios/web/public/security",
"//skia", "//skia",
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h" #import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h"
#import "ios/chrome/grit/ios_strings.h" #import "ios/chrome/grit/ios_strings.h"
#include "ios/chrome/grit/ios_theme_resources.h" #include "ios/chrome/grit/ios_theme_resources.h"
#import "ios/web/common/origin_util.h"
#include "ios/web/public/navigation/navigation_item.h" #include "ios/web/public/navigation/navigation_item.h"
#import "ios/web/public/navigation/navigation_manager.h" #import "ios/web/public/navigation/navigation_manager.h"
#include "ios/web/public/security/ssl_status.h" #include "ios/web/public/security/ssl_status.h"
...@@ -320,8 +321,15 @@ ...@@ -320,8 +321,15 @@
return [self imageForOfflinePage]; return [self imageForOfflinePage];
} }
return GetLocationBarSecurityIconForSecurityState( security_state::SecurityLevel securityLevel =
self.locationBarModel->GetSecurityLevel()); self.locationBarModel->GetSecurityLevel();
bool shouldDowngrade = security_state::ShouldDowngradeNeutralStyling(
securityLevel, self.locationBarModel->GetURL(),
base::BindRepeating(&web::IsOriginSecure));
return GetLocationBarSecurityIconForSecurityState(securityLevel,
shouldDowngrade);
} }
// Returns a location icon for offline pages. // Returns a location icon for offline pages.
......
...@@ -31,14 +31,19 @@ UIImage* GetOmniboxSuggestionIconForAutocompleteMatchType( ...@@ -31,14 +31,19 @@ UIImage* GetOmniboxSuggestionIconForAutocompleteMatchType(
// Returns the asset with "always template" rendering mode. // Returns the asset with "always template" rendering mode.
UIImage* GetLocationBarSecurityIcon(LocationBarSecurityIconType icon); UIImage* GetLocationBarSecurityIcon(LocationBarSecurityIconType icon);
// Converts the |security_level| to an appropriate security icon type. // Converts the |security_level| to an appropriate security icon type. If
// |should_downgrade| is true, the info icon should be downgraded to a
// grey triangle for non-secure connections.
LocationBarSecurityIconType GetLocationBarSecurityIconTypeForSecurityState( LocationBarSecurityIconType GetLocationBarSecurityIconTypeForSecurityState(
security_state::SecurityLevel security_level); security_state::SecurityLevel security_level,
bool should_downgrade);
// Converts the |security_level| to an appropriate icon in "always template" // Converts the |security_level| to an appropriate icon in "always template"
// rendering mode. // rendering mode. If |should_downgrade| is true, the info icon should be
// downgraded to a grey triangle for non-secure connections.
UIImage* GetLocationBarSecurityIconForSecurityState( UIImage* GetLocationBarSecurityIconForSecurityState(
security_state::SecurityLevel security_level); security_state::SecurityLevel security_level,
bool should_downgrade);
#pragma mark - Legacy utils. #pragma mark - Legacy utils.
......
...@@ -87,10 +87,13 @@ UIImage* GetLocationBarSecurityIcon(LocationBarSecurityIconType iconType) { ...@@ -87,10 +87,13 @@ UIImage* GetLocationBarSecurityIcon(LocationBarSecurityIconType iconType) {
// Converts the |security_level| to an appropriate security icon type. // Converts the |security_level| to an appropriate security icon type.
LocationBarSecurityIconType GetLocationBarSecurityIconTypeForSecurityState( LocationBarSecurityIconType GetLocationBarSecurityIconTypeForSecurityState(
security_state::SecurityLevel security_level) { security_state::SecurityLevel security_level,
bool should_downgrade) {
switch (security_level) { switch (security_level) {
case security_state::NONE: case security_state::NONE:
case security_state::WARNING: case security_state::WARNING:
if (should_downgrade)
return NOT_SECURE_WARNING;
return INFO; return INFO;
case security_state::EV_SECURE: case security_state::EV_SECURE:
case security_state::SECURE: case security_state::SECURE:
...@@ -107,9 +110,11 @@ LocationBarSecurityIconType GetLocationBarSecurityIconTypeForSecurityState( ...@@ -107,9 +110,11 @@ LocationBarSecurityIconType GetLocationBarSecurityIconTypeForSecurityState(
// Converts the |security_level| to an appropriate icon in "always template" // Converts the |security_level| to an appropriate icon in "always template"
// rendering mode. // rendering mode.
UIImage* GetLocationBarSecurityIconForSecurityState( UIImage* GetLocationBarSecurityIconForSecurityState(
security_state::SecurityLevel security_level) { security_state::SecurityLevel security_level,
bool should_downgrade) {
LocationBarSecurityIconType iconType = LocationBarSecurityIconType iconType =
GetLocationBarSecurityIconTypeForSecurityState(security_level); GetLocationBarSecurityIconTypeForSecurityState(security_level,
should_downgrade);
return GetLocationBarSecurityIcon(iconType); return GetLocationBarSecurityIcon(iconType);
} }
......
...@@ -15,6 +15,7 @@ source_set("page_info") { ...@@ -15,6 +15,7 @@ source_set("page_info") {
"//base", "//base",
"//base:i18n", "//base:i18n",
"//components/keyed_service/core", "//components/keyed_service/core",
"//components/security_state/core",
"//components/ssl_errors", "//components/ssl_errors",
"//components/strings", "//components/strings",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
...@@ -29,6 +30,7 @@ source_set("page_info") { ...@@ -29,6 +30,7 @@ source_set("page_info") {
"//ios/chrome/common", "//ios/chrome/common",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
"//ios/web", "//ios/web",
"//ios/web/common",
"//ios/web/public/security", "//ios/web/public/security",
"//ui/base", "//ui/base",
"//ui/gfx", "//ui/gfx",
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "components/keyed_service/core/service_access_type.h" #include "components/keyed_service/core/service_access_type.h"
#include "components/security_state/core/security_state.h"
#include "components/ssl_errors/error_info.h" #include "components/ssl_errors/error_info.h"
#include "components/strings/grit/components_chromium_strings.h" #include "components/strings/grit/components_chromium_strings.h"
#include "components/strings/grit/components_google_chrome_strings.h" #include "components/strings/grit/components_google_chrome_strings.h"
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
#include "ios/chrome/grit/ios_chromium_strings.h" #include "ios/chrome/grit/ios_chromium_strings.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#include "ios/chrome/grit/ios_theme_resources.h" #include "ios/chrome/grit/ios_theme_resources.h"
#import "ios/web/common/origin_util.h"
#include "ios/web/public/security/ssl_status.h" #include "ios/web/public/security/ssl_status.h"
#include "net/cert/cert_status_flags.h" #include "net/cert/cert_status_flags.h"
#include "net/cert/x509_certificate.h" #include "net/cert/x509_certificate.h"
...@@ -70,8 +72,16 @@ PageInfoModel::PageInfoModel(ios::ChromeBrowserState* browser_state, ...@@ -70,8 +72,16 @@ PageInfoModel::PageInfoModel(ios::ChromeBrowserState* browser_state,
// Summary and details. // Summary and details.
SectionStateIcon icon_id = ICON_NONE; SectionStateIcon icon_id = ICON_NONE;
if (!ssl.certificate) { if (!ssl.certificate) {
// Not HTTPS. // Not HTTPS. This maps to the WARNING security level. Show the grey
icon_id = ICON_STATE_INFO; // triangle icon in page info based on the same logic used to determine
// the iconography in the omnibox.
if (security_state::ShouldDowngradeNeutralStyling(
security_state::SecurityLevel::WARNING, url,
base::BindRepeating(&web::IsOriginSecure))) {
icon_id = ICON_STATE_ERROR;
} else {
icon_id = ICON_STATE_INFO;
}
summary.assign(l10n_util::GetStringUTF16(IDS_PAGE_INFO_NOT_SECURE_SUMMARY)); summary.assign(l10n_util::GetStringUTF16(IDS_PAGE_INFO_NOT_SECURE_SUMMARY));
details.assign(l10n_util::GetStringUTF16(IDS_PAGE_INFO_NOT_SECURE_DETAILS)); details.assign(l10n_util::GetStringUTF16(IDS_PAGE_INFO_NOT_SECURE_DETAILS));
} else { } else {
...@@ -111,8 +121,16 @@ PageInfoModel::PageInfoModel(ios::ChromeBrowserState* browser_state, ...@@ -111,8 +121,16 @@ PageInfoModel::PageInfoModel(ios::ChromeBrowserState* browser_state,
IDS_IOS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name)); IDS_IOS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name));
} }
if (ssl.content_status == web::SSLStatus::DISPLAYED_INSECURE_CONTENT) { if (ssl.content_status == web::SSLStatus::DISPLAYED_INSECURE_CONTENT) {
// HTTPS with mixed content. // HTTPS with mixed content. This maps to the NONE security level. Show
icon_id = ICON_STATE_INFO; // the grey triangle icon in page info based on the same logic used to
// determine the iconography in the omnibox.
if (security_state::ShouldDowngradeNeutralStyling(
security_state::SecurityLevel::NONE, url,
base::BindRepeating(&web::IsOriginSecure))) {
icon_id = ICON_STATE_ERROR;
} else {
icon_id = ICON_STATE_INFO;
}
summary.assign( summary.assign(
l10n_util::GetStringUTF16(IDS_PAGE_INFO_MIXED_CONTENT_SUMMARY)); l10n_util::GetStringUTF16(IDS_PAGE_INFO_MIXED_CONTENT_SUMMARY));
details.assign( details.assign(
......
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