Commit 89c85f7c authored by Elodie Banel's avatar Elodie Banel Committed by Commit Bot

Add function for a11y omnibox security state and fix ios

After https://chromium-review.googlesource.com/c/chromium/src/+/1140674
the GetSecureVerboseText function doesn't return text anymore. This
function is used for visual display. In order to continue getting data
for accessibility purposes, duplicate the function with modifications
to continue returning relevant info.
Additionally, fix iOS omnibox accessibility to 1) use this new function
and 2) update a11y when label (generally site url) changes even if
security state does not.

Bug: 869398
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ibf60a354d5f81b9a5d52aaec10d3ef5277be93bd
Reviewed-on: https://chromium-review.googlesource.com/1161913
Commit-Queue: Elodie Banel <lod@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582165}
parent 765dd5f6
......@@ -43,6 +43,10 @@ base::string16 TestToolbarModel::GetSecureVerboseText() const {
return base::string16();
}
base::string16 TestToolbarModel::GetSecureAccessibilityText() const {
return base::string16();
}
base::string16 TestToolbarModel::GetEVCertName() const {
return (security_level_ == security_state::EV_SECURE) ? ev_cert_name_
: base::string16();
......
......@@ -30,6 +30,7 @@ class TestToolbarModel : public ToolbarModel {
bool ignore_editing) const override;
const gfx::VectorIcon& GetVectorIcon() const override;
base::string16 GetSecureVerboseText() const override;
base::string16 GetSecureAccessibilityText() const override;
base::string16 GetEVCertName() const override;
bool ShouldDisplayURL() const override;
bool IsOfflinePage() const override;
......
......@@ -54,9 +54,13 @@ class ToolbarModel {
// OmniboxView::GetIcon().
virtual const gfx::VectorIcon& GetVectorIcon() const = 0;
// Returns text for the omnibox secure verbose chip.
// Returns text for the omnibox secure verbose chip, displayed next to the
// security icon on certain platforms.
virtual base::string16 GetSecureVerboseText() const = 0;
// Returns text describing the security state for accessibility.
virtual base::string16 GetSecureAccessibilityText() const = 0;
// Returns the name of the EV cert holder. This returns an empty string if
// the security level is not EV_SECURE.
virtual base::string16 GetEVCertName() const = 0;
......
......@@ -137,6 +137,23 @@ base::string16 ToolbarModelImpl::GetEVCertName() const {
base::UTF8ToUTF16(cert->subject().country_name));
}
base::string16 ToolbarModelImpl::GetSecureText() const {
switch (GetSecurityLevel(false)) {
case security_state::HTTP_SHOW_WARNING:
return l10n_util::GetStringUTF16(IDS_NOT_SECURE_VERBOSE_STATE);
case security_state::EV_SECURE:
return GetEVCertName();
case security_state::SECURE:
return l10n_util::GetStringUTF16(IDS_SECURE_VERBOSE_STATE);
case security_state::DANGEROUS:
return l10n_util::GetStringUTF16(delegate_->FailsMalwareCheck()
? IDS_DANGEROUS_VERBOSE_STATE
: IDS_NOT_SECURE_VERBOSE_STATE);
default:
return base::string16();
}
}
base::string16 ToolbarModelImpl::GetSecureVerboseText() const {
if (IsOfflinePage())
return l10n_util::GetStringUTF16(IDS_OFFLINE_VERBOSE_STATE);
......@@ -148,32 +165,32 @@ base::string16 ToolbarModelImpl::GetSecureVerboseText() const {
toolbar::features::kSimplifyHttpsIndicator,
toolbar::features::kSimplifyHttpsIndicatorParameterName)
: std::string();
switch (GetSecurityLevel(false)) {
case security_state::HTTP_SHOW_WARNING:
return l10n_util::GetStringUTF16(IDS_NOT_SECURE_VERBOSE_STATE);
case security_state::EV_SECURE:
if (parameter ==
toolbar::features::kSimplifyHttpsIndicatorParameterEvToSecure) {
return l10n_util::GetStringUTF16(IDS_SECURE_VERBOSE_STATE);
}
if (parameter ==
toolbar::features::kSimplifyHttpsIndicatorParameterBothToLock) {
return base::string16();
}
return GetEVCertName();
case security_state::SECURE:
if (parameter ==
toolbar::features::kSimplifyHttpsIndicatorParameterKeepSecureChip) {
return l10n_util::GetStringUTF16(IDS_SECURE_VERBOSE_STATE);
}
auto security_level = GetSecurityLevel(false);
if (security_level == security_state::EV_SECURE) {
if (parameter ==
toolbar::features::kSimplifyHttpsIndicatorParameterEvToSecure) {
return l10n_util::GetStringUTF16(IDS_SECURE_VERBOSE_STATE);
}
if (parameter ==
toolbar::features::kSimplifyHttpsIndicatorParameterBothToLock) {
return base::string16();
case security_state::DANGEROUS:
return l10n_util::GetStringUTF16(delegate_->FailsMalwareCheck()
? IDS_DANGEROUS_VERBOSE_STATE
: IDS_NOT_SECURE_VERBOSE_STATE);
default:
}
}
if (security_level == security_state::SECURE) {
if (parameter !=
toolbar::features::kSimplifyHttpsIndicatorParameterKeepSecureChip) {
return base::string16();
}
}
return GetSecureText();
}
base::string16 ToolbarModelImpl::GetSecureAccessibilityText() const {
if (IsOfflinePage())
return l10n_util::GetStringUTF16(IDS_OFFLINE_VERBOSE_STATE);
return GetSecureText();
}
bool ToolbarModelImpl::ShouldDisplayURL() const {
......
......@@ -35,11 +35,14 @@ class ToolbarModelImpl : public ToolbarModel {
bool ignore_editing) const override;
const gfx::VectorIcon& GetVectorIcon() const override;
base::string16 GetSecureVerboseText() const override;
base::string16 GetSecureAccessibilityText() const override;
base::string16 GetEVCertName() const override;
bool ShouldDisplayURL() const override;
bool IsOfflinePage() const override;
private:
// Get the security text describing the current security state.
base::string16 GetSecureText() const;
base::string16 GetFormattedURL(
url_formatter::FormatUrlTypes format_types) const;
......
......@@ -195,7 +195,7 @@
[self.consumer
updateLocationIcon:[self currentLocationIcon]
securityStatusText:base::SysUTF16ToNSString(
self.toolbarModel->GetSecureVerboseText())];
self.toolbarModel->GetSecureAccessibilityText())];
}
#pragma mark Location helpers
......
......@@ -34,6 +34,9 @@
// Sets the location image. If |locationImage| is nil, hides the image view.
- (void)setLocationImage:(UIImage*)locationImage;
// Sets the location label's text.
- (void)setLocationLabelText:(NSString*)string;
// The tappable button representing the location bar.
@property(nonatomic, strong) UIButton* locationButton;
// The label displaying the current location URL.
......
......@@ -275,6 +275,14 @@ const CGFloat kButtonTrailingSpacing = 10;
}
}
- (void)setLocationLabelText:(NSString*)string {
if ([self.locationLabel.text isEqualToString:string]) {
return;
}
self.locationLabel.text = string;
[self updateAccessibility];
}
- (void)setSecurityLevelAccessibilityString:(NSString*)string {
if ([_securityLevelAccessibilityString isEqualToString:string]) {
return;
......
......@@ -212,7 +212,7 @@ typedef NS_ENUM(int, TrailingButtonState) {
#pragma mark - LocationBarConsumer
- (void)updateLocationText:(NSString*)text {
self.locationBarSteadyView.locationLabel.text = text;
[self.locationBarSteadyView setLocationLabelText:text];
}
- (void)updateLocationIcon:(UIImage*)icon
......
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