Commit 19114cb8 authored by Christopher Thompson's avatar Christopher Thompson Committed by Commit Bot

Ensure Secure status is in accessibility label

This fixes an a11y regression in the page info button label under the
experimental conditions of the HTTPS Indicator UI Study
(https://crbug.com/803501), where only the green lock icon would be
shown but no explanatory label would be included for screen readers.
This modifies the accessibility label under these conditions for both
views and cocoa UI to make sure that secure connections are always
labeled as such.

On Windows/Linux/ChromeOS (Views), this appends a new String Attribute
to the description in the AXNodeData. On Mac (Cocoa), this prepends the
"Secure" text to the beginning of the Accessibility Label.

Bug: 812034
Change-Id: I1fe2e6d1afa7110d445154da682846fd82738939
Reviewed-on: https://chromium-review.googlesource.com/917282
Commit-Queue: Christopher Thompson <cthomp@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536938}
parent 6c5021f8
......@@ -16,6 +16,8 @@
#include "chrome/browser/ui/page_info/page_info_dialog.h"
#include "chrome/grit/generated_resources.h"
#include "components/favicon/content/content_favicon_driver.h"
#include "components/strings/grit/components_strings.h"
#include "components/toolbar/toolbar_model.h"
#include "skia/ext/skia_utils_mac.h"
#import "third_party/mozilla/NSPasteboard+Utils.h"
#import "ui/base/cocoa/nsview_additions.h"
......@@ -331,10 +333,19 @@ NSString* PageInfoBubbleDecoration::GetToolTip() {
NSString* PageInfoBubbleDecoration::GetAccessibilityLabel() {
NSString* tooltip_icon_text =
l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_LOCATION_ICON);
if ([full_label_ length] == 0)
NSString* full_label = full_label_.get();
security_state::SecurityLevel security_level =
owner_->GetToolbarModel()->GetSecurityLevel(false);
if ([full_label length] == 0 &&
(security_level == security_state::EV_SECURE ||
security_level == security_state::SECURE)) {
full_label = l10n_util::GetNSStringWithFixup(IDS_SECURE_VERBOSE_STATE);
}
if ([full_label length] == 0)
return tooltip_icon_text;
return [NSString
stringWithFormat:@"%@. %@", full_label_.get(), tooltip_icon_text];
return [NSString stringWithFormat:@"%@. %@", full_label, tooltip_icon_text];
}
NSRect PageInfoBubbleDecoration::GetRealFocusRingBounds(NSRect bounds) const {
......
......@@ -10,6 +10,8 @@
#include "chrome/browser/ui/views/page_info/page_info_bubble_view.h"
#include "chrome/grit/generated_resources.h"
#include "components/omnibox/browser/omnibox_edit_model.h"
#include "components/strings/grit/components_strings.h"
#include "components/toolbar/toolbar_model.h"
#include "content/public/browser/web_contents.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -78,6 +80,15 @@ void LocationIconView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
return;
}
security_state::SecurityLevel security_level =
location_bar_->GetToolbarModel()->GetSecurityLevel(false);
if (label()->text().empty() && (security_level == security_state::EV_SECURE ||
security_level == security_state::SECURE)) {
node_data->AddStringAttribute(
ax::mojom::StringAttribute::kDescription,
l10n_util::GetStringUTF8(IDS_SECURE_VERBOSE_STATE));
}
IconLabelBubbleView::GetAccessibleNodeData(node_data);
node_data->role = ax::mojom::Role::kPopUpButton;
}
......
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