Commit ff964728 authored by Jon Mann's avatar Jon Mann Committed by Commit Bot

Add a a11y focus stop to disconnect VPN button in quick settings.

Previously, when using Search + Arrow to navigate through
VPN quick settings, there was no stop on the disconnect
button for a connected VPN.  This change also updates the
a11y labels for both the VPN row and disconnect button
to identify what action is performed.

Bug: 760222
Change-Id: I0bc1ea2930c874255f9dfd9601b2741810fbc4f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1938041Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Jon Mann <jonmann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721357}
parent 2fc1cb4d
......@@ -1003,6 +1003,8 @@ component("ash") {
"system/tray/tray_utils.h",
"system/tray/tri_view.cc",
"system/tray/tri_view.h",
"system/tray/unfocusable_label.cc",
"system/tray/unfocusable_label.h",
"system/tray/view_click_listener.h",
"system/unified/collapse_button.cc",
"system/unified/collapse_button.h",
......
......@@ -910,9 +910,15 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_NETWORK_A11Y_LABEL_OPEN" desc="Accessibility label used for a network in quick settings network list that opens network settings page.">
Open settings for <ph name="NETWORK_NAME">$1<ex>Ethernet</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_NETWORK_A11Y_LABEL_OPEN_WITH_CONNECTION_STATUS" desc="Accessibility label used for a network in quick settings network list that opens network settings page.">
Open settings for <ph name="NETWORK_NAME">$1<ex>Ethernet</ex></ph>, <ph name="CONNECTION_STATUS">$2<ex>Connecting</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_NETWORK_A11Y_LABEL_CONNECT" desc="Accessibility label used for a network in quick settings network list that connects to the network.">
Connect to <ph name="NETWORK_NAME">$1<ex>Ethernet</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_NETWORK_DISCONNECT_BUTTON_A11Y_LABEL" desc="Accessibility label used for a button to disconnect from a network in quick settings network list.">
Disconnect from <ph name="NETWORK_NAME">$1<ex>Ethernet</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_ETHERNET_A11Y_DESC_MANAGED" desc="Accessibility description for an enterprise managed ethernet network in the quick settings network list.">
Managed by your Administrator
</message>
......@@ -1484,6 +1490,9 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_NETWORK_MONITORED_WARNING" desc="The label used in the tray popup to warn users their network may be monitored." >
Network may be monitored
</message>
<message name="IDS_ASH_A11Y_ROLE_BUTTON" desc="The label used to identify a button. For accessibility only." >
Button
</message>
<message name="IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME" desc="The accessible text for virtual keyboard icon in status tray.">
Show on-screen keyboard
......
......@@ -263,6 +263,8 @@ void VPNListNetworkEntry::UpdateFromNetworkState(
if (IsVpnConfigAllowed()) {
disconnect_button_ = TrayPopupUtils::CreateTrayPopupButton(
this, l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_VPN_DISCONNECT));
disconnect_button_->SetAccessibleName(l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_DISCONNECT_BUTTON_A11Y_LABEL, label));
AddRightView(disconnect_button_);
}
tri_view()->SetContainerBorder(
......@@ -270,8 +272,21 @@ void VPNListNetworkEntry::UpdateFromNetworkState(
views::CreateEmptyBorder(
0, kTrayPopupButtonEndMargin - kTrayPopupLabelHorizontalPadding, 0,
kTrayPopupButtonEndMargin));
SetAccessibleName(l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_A11Y_LABEL_OPEN_WITH_CONNECTION_STATUS,
label,
l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED)));
} else if (vpn->connection_state == ConnectionStateType::kConnecting) {
SetAccessibleName(l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_A11Y_LABEL_OPEN_WITH_CONNECTION_STATUS,
label,
l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING)));
owner_->SetupConnectingScrollListItem(this);
} else {
SetAccessibleName(l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_A11Y_LABEL_CONNECT, label));
}
Layout();
......
......@@ -4,13 +4,17 @@
#include "ash/system/tray/hover_highlight_view.h"
#include <string>
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_popup_utils.h"
#include "ash/system/tray/tri_view.h"
#include "ash/system/tray/unfocusable_label.h"
#include "ash/system/tray/view_click_listener.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/border.h"
......@@ -78,7 +82,7 @@ void HoverHighlightView::SetSubText(const base::string16& sub_text) {
DCHECK(!sub_text.empty());
if (!sub_text_label_) {
sub_text_label_ = TrayPopupUtils::CreateDefaultLabel();
sub_text_label_ = TrayPopupUtils::CreateUnfocusableLabel();
tri_view_->AddView(TriView::Container::CENTER, sub_text_label_);
}
......@@ -111,7 +115,7 @@ void HoverHighlightView::DoAddIconAndLabel(
left_icon_->SetEnabled(GetEnabled());
tri_view_->AddView(TriView::Container::START, left_icon_);
text_label_ = TrayPopupUtils::CreateDefaultLabel();
text_label_ = TrayPopupUtils::CreateUnfocusableLabel();
text_label_->SetText(text);
text_label_->SetEnabled(GetEnabled());
TrayPopupItemStyle style(font_style, use_unified_theme_);
......@@ -135,7 +139,7 @@ void HoverHighlightView::AddLabelRow(const base::string16& text) {
tri_view_ = TrayPopupUtils::CreateDefaultRowView();
AddChildView(tri_view_);
text_label_ = TrayPopupUtils::CreateDefaultLabel();
text_label_ = TrayPopupUtils::CreateUnfocusableLabel();
text_label_->SetText(text);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL,
......@@ -187,7 +191,21 @@ bool HoverHighlightView::PerformAction(const ui::Event& event) {
}
void HoverHighlightView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
ActionableView::GetAccessibleNodeData(node_data);
if (right_view_ && right_view_->GetVisible() &&
std::string(right_view_->GetClassName()).find("Button") !=
std::string::npos) {
// Allow selection of sub-components.
node_data->role = ax::mojom::Role::kGenericContainer;
// Include "press search plus space to activate" when announcing.
node_data->SetDefaultActionVerb(ax::mojom::DefaultActionVerb::kClick);
node_data->SetName(GetAccessibleName());
node_data->SetDescription(
l10n_util::GetStringUTF16(IDS_ASH_A11Y_ROLE_BUTTON));
} else {
ActionableView::GetAccessibleNodeData(node_data);
}
ax::mojom::CheckedState checked_state;
......
......@@ -18,6 +18,7 @@
#include "ash/system/tray/hover_highlight_view.h"
#include "ash/system/tray/size_range_layout.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/unfocusable_label.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/insets.h"
......@@ -215,6 +216,13 @@ views::Label* TrayPopupUtils::CreateDefaultLabel() {
return label;
}
UnfocusableLabel* TrayPopupUtils::CreateUnfocusableLabel() {
UnfocusableLabel* label = new UnfocusableLabel();
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
label->SetSubpixelRenderingEnabled(false);
return label;
}
views::ImageView* TrayPopupUtils::CreateMainImageView() {
auto* image = new views::ImageView;
image->SetPreferredSize(
......
......@@ -32,6 +32,7 @@ class ToggleButton;
namespace ash {
class HoverHighlightView;
class UnfocusableLabel;
// Factory/utility functions used by the system menu.
class TrayPopupUtils {
......@@ -93,6 +94,10 @@ class TrayPopupUtils {
// TODO(bruthig): Update all system menu rows to use this.
static views::Label* CreateDefaultLabel();
// Returns a label that has been configured for system menu layout and does
// not allow accessibility focus.
static UnfocusableLabel* CreateUnfocusableLabel();
// Returns an image view to be used in the main image region of a system menu
// row. This should be used by all rows that have a main image, i.e. both
// default and detailed rows should use this.
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/tray/unfocusable_label.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
namespace ash {
UnfocusableLabel::~UnfocusableLabel() = default;
void UnfocusableLabel::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->AddState(ax::mojom::State::kIgnored);
}
} // namespace ash
\ No newline at end of file
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_TRAY_UNFOCUSABLE_LABEL_H_
#define ASH_SYSTEM_TRAY_UNFOCUSABLE_LABEL_H_
#include "ash/ash_export.h"
#include "base/macros.h"
#include "ui/views/controls/label.h"
namespace ash {
// A label which is not focusable with ChromeVox.
class ASH_EXPORT UnfocusableLabel : public views::Label {
public:
UnfocusableLabel() = default;
~UnfocusableLabel() override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
private:
DISALLOW_COPY_AND_ASSIGN(UnfocusableLabel);
};
} // namespace ash
#endif // ASH_SYSTEM_TRAY_UNFOCUSABLE_LABEL_H_
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