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

[a11y] Announce visible details of networks in tray.

When navigating over the network list in the system tray, announce all
visible details including: name, connection status, signal strength,
managed by administrator, secured, etc.

Fixes: 1006390, 1006019
Change-Id: I8b37d4711a329df94c6f16f17e378c3e3de66f5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1899068Reviewed-by: default avatarSamuel Huang <huangs@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Jon Mann <jonmann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713924}
parent 9723628c
......@@ -877,8 +877,44 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_NETWORK" desc="The label used in the network dialog header.">
Network
</message>
<message name="IDS_ASH_STATUS_TRAY_NETWORK_ACCESSIBILITY_LABEL" desc="Accessibility label for a network in the quick settings network list, to be read outloud by a screenreader or braile console.">
<ph name="NETWORK_NAME">$1<ex>GuestNetwork</ex></ph> - <ph name="CONNECTION_STATUS">$2<ex>Connecting</ex></ph>
<message name="IDS_ASH_STATUS_TRAY_ETHERNET_A11Y_LABEL_WITH_CONNECTION_STATUS" desc="Accessibility label for an ethernet network in the quick settings network list.">
<ph name="NETWORK_NAME">$1<ex>Ethernet</ex></ph>, <ph name="CONNECTION_STATUS">$2<ex>Connected</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_ETHERNET_A11Y_LABEL_MANAGED" desc="Accessibility label for an enterprise managed ethernet network in the quick settings network list.">
<ph name="NETWORK_NAME">$1<ex>Ethernet</ex></ph>, Managed by your Administrator
</message>
<message name="IDS_ASH_STATUS_TRAY_ETHERNET_A11Y_LABEL_MANAGED_WITH_CONNECTION_STATUS" desc="Accessibility label for an enterprise managed ethernet network in the quick settings network list. Includes connection status.">
<ph name="NETWORK_NAME">$1<ex>Ethernet</ex></ph>, <ph name="CONNECTION_STATUS">$2<ex>Connected</ex></ph>, Managed by your Administrator
</message>
<message name="IDS_ASH_STATUS_TRAY_CELLULAR_NETWORK_A11Y_LABEL" desc="Accessibility label for a cellular network in the quick settings network list.">
<ph name="NETWORK_NAME">$1<ex>Verizon Wireless</ex></ph>, Signal Strength <ph name="SIGNAL_STRENGTH">$2<ex>80%</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_CELLULAR_NETWORK_A11Y_LABEL_WITH_CONNECTION_STATUS" desc="Accessibility label for a cellular network in the quick settings network list . Includes connection status.">
<ph name="NETWORK_NAME">$1<ex>Verizon Wireless</ex></ph>, <ph name="CONNECTION_STATUS">$2<ex>Connecting...</ex></ph>, Signal Strength <ph name="SIGNAL_STRENGTH">$3<ex>80%</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_CELLULAR_NETWORK_A11Y_LABEL_MANAGED" desc="Accessibility label for an enterprise managed cellular network in the quick settings network list.">
<ph name="NETWORK_NAME">$1<ex>Verizon Wireless</ex></ph>, Signal Strength <ph name="SIGNAL_STRENGTH">$2<ex>80%</ex></ph>, Managed by your Administrator
</message>
<message name="IDS_ASH_STATUS_TRAY_CELLULAR_NETWORK_A11Y_LABEL_MANAGED_WITH_CONNECTION_STATUS" desc="Accessibility label for an enterprise managed cellular network in the quick settings network list. Includes connection status.">
<ph name="NETWORK_NAME">$1<ex>Verizon Wireless</ex></ph>, <ph name="CONNECTION_STATUS">$2<ex>Connecting...</ex></ph>, Signal Strength <ph name="SIGNAL_STRENGTH">$3<ex>80%</ex></ph>, Managed by your Administrator
</message>
<message name="IDS_ASH_STATUS_TRAY_WIFI_NETWORK_A11Y_LABEL" desc="Accessibility label for a Wi-Fi network in the quick settings network list.">
<ph name="NETWORK_NAME">$1<ex>GuestNetwork</ex></ph>, <ph name="SECURITY_STATUS">$2<ex>Unsecured</ex></ph>, Signal Strength <ph name="SIGNAL_STRENGTH">$3<ex>80%</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_WIFI_NETWORK_A11Y_LABEL_WITH_CONNECTION_STATUS" desc="Accessibility label for a Wi-Fi network in the quick settings network list. Includes connection status.">
<ph name="NETWORK_NAME">$1<ex>GuestNetwork</ex></ph>, <ph name="SECURITY_STATUS">$2<ex>Unsecured</ex></ph>, <ph name="CONNECTION_STATUS">$3<ex>Connecting</ex></ph>, Signal Strength <ph name="SIGNAL_STRENGTH">$4<ex>80%</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_WIFI_NETWORK_A11Y_LABEL_MANAGED" desc="Accessibility label for an enterprise managed Wi-Fi network in the quick settings network list.">
<ph name="NETWORK_NAME">$1<ex>GuestNetwork</ex></ph>, <ph name="SECURITY_STATUS">$2<ex>Unsecured</ex></ph>, Signal Strength <ph name="SIGNAL_STRENGTH">$3<ex>80%</ex></ph>, Managed by your Administrator
</message>
<message name="IDS_ASH_STATUS_TRAY_WIFI_NETWORK_A11Y_LABEL_MANAGED_WITH_CONNECTION_STATUS" desc="Accessibility label for an enterprise managed Wi-Fi network in the quick settings network list. Incldues connection status.">
<ph name="NETWORK_NAME">$1<ex>GuestNetwork</ex></ph>, <ph name="SECURITY_STATUS">$2<ex>Unsecured</ex></ph>, <ph name="CONNECTION_STATUS">$3<ex>Connecting</ex></ph>, Signal Strength <ph name="SIGNAL_STRENGTH">$4<ex>80%</ex></ph>, Managed by your Administrator
</message>
<message name="IDS_ASH_STATUS_TRAY_TETHER_NETWORK_A11Y_LABEL" desc="Accessibility label for a phone tether network in the quick settings network list.">
<ph name="PHONE_NAME">$1<ex>Pixel 4</ex></ph>, Signal Strength <ph name="SIGNAL_STRENGTH">$2<ex>80%</ex></ph>, Phone Battery <ph name="BATTERY_STATUS">$3<ex>80%</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_TETHER_NETWORK_A11Y_LABEL_WITH_CONNECTION_STATUS" desc="Accessibility label for a phone tether network in the quick settings network list. Includes connection status.">
<ph name="PHONE_NAME">$1<ex>Pixel 4</ex></ph>, <ph name="CONNECTION_STATUS">$2<ex>Connecting...</ex></ph>, Signal Strength <ph name="SIGNAL_STRENGTH">$3<ex>80%</ex></ph>, Phone Battery <ph name="BATTERY_STATUS">$4<ex>80%</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED" desc="The label used when a network connection is connected.">
Connected
......@@ -886,6 +922,12 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING" desc="The label used when a network connection is connecting.">
Connecting...
</message>
<message name="IDS_ASH_STATUS_TRAY_NETWORK_STATUS_SECURED" desc="a11y label used when a Wi-Fi network is secured.">
Secured
</message>
<message name="IDS_ASH_STATUS_TRAY_NETWORK_STATUS_UNSECURED" desc="a11y label used when a Wi-Fi network connection is not secured.">
Unsecured
</message>
<message name="IDS_ASH_STATUS_TRAY_VPN" desc="The label used in the VPN detailed view header.">
Private network
</message>
......
......@@ -32,11 +32,13 @@ struct NetworkInfo {
base::string16 tooltip;
gfx::ImageSkia image;
bool disable = false;
bool secured = false;
// Initialized in .cc file because full (non-forward) mojom headers are large.
chromeos::network_config::mojom::ConnectionStateType connection_state;
chromeos::network_config::mojom::NetworkType type;
chromeos::network_config::mojom::OncSource source;
int battery_percentage = 0;
int signal_strength = 0;
std::string captive_portal_provider_name;
};
......
......@@ -76,6 +76,11 @@ SkColor GetIconColor() {
AshColorProvider::AshColorMode::kDark);
}
bool IsManagedByPolicy(const NetworkInfo& info) {
return info.source == OncSource::kDevicePolicy ||
info.source == OncSource::kUserPolicy;
}
} // namespace
// NetworkListView:
......@@ -151,6 +156,8 @@ void NetworkListView::OnGetNetworkStateList(
break;
case NetworkType::kWiFi:
wifi_has_networks_ = true;
info->secured = network->type_state->get_wifi()->security !=
chromeos::network_config::mojom::SecurityType::kNone;
break;
case NetworkType::kTether:
mobile_has_networks_ = true;
......@@ -175,6 +182,9 @@ void NetworkListView::OnGetNetworkStateList(
info->connection_state = connection_state;
info->signal_strength =
chromeos::network_config::GetWirelessSignalStrength(network.get());
if (network->captive_portal_provider) {
info->captive_portal_provider_name =
network->captive_portal_provider->name;
......@@ -379,9 +389,103 @@ void NetworkListView::UpdateViewForNetwork(HoverHighlightView* view,
view->AddRightView(icon);
}
view->SetAccessibleName(GenerateAccessibilityLabel(info));
needs_relayout_ = true;
}
base::string16 NetworkListView::GenerateAccessibilityLabel(
const NetworkInfo& info) {
base::string16 connection_status;
if (StateIsConnected(info.connection_state) ||
info.connection_state == ConnectionStateType::kConnecting) {
connection_status = l10n_util::GetStringUTF16(
StateIsConnected(info.connection_state)
? IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED
: IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING);
}
switch (info.type) {
case NetworkType::kEthernet:
if (!connection_status.empty()) {
if (IsManagedByPolicy(info)) {
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_ETHERNET_A11Y_LABEL_MANAGED_WITH_CONNECTION_STATUS,
info.label, connection_status);
}
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_ETHERNET_A11Y_LABEL_WITH_CONNECTION_STATUS,
info.label, connection_status);
}
if (IsManagedByPolicy(info)) {
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_ETHERNET_A11Y_LABEL_MANAGED, info.label,
connection_status);
}
return info.label;
case NetworkType::kWiFi: {
base::string16 security_label = l10n_util::GetStringUTF16(
info.secured ? IDS_ASH_STATUS_TRAY_NETWORK_STATUS_SECURED
: IDS_ASH_STATUS_TRAY_NETWORK_STATUS_UNSECURED);
if (!connection_status.empty()) {
if (IsManagedByPolicy(info)) {
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_WIFI_NETWORK_A11Y_LABEL_MANAGED_WITH_CONNECTION_STATUS,
info.label, security_label, connection_status,
base::FormatPercent(info.signal_strength));
}
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_WIFI_NETWORK_A11Y_LABEL_WITH_CONNECTION_STATUS,
info.label, security_label, connection_status,
base::FormatPercent(info.signal_strength));
}
if (IsManagedByPolicy(info)) {
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_WIFI_NETWORK_A11Y_LABEL_MANAGED, info.label,
security_label, base::FormatPercent(info.signal_strength));
}
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_WIFI_NETWORK_A11Y_LABEL, info.label,
security_label, base::FormatPercent(info.signal_strength));
}
case NetworkType::kCellular:
if (!connection_status.empty()) {
if (IsManagedByPolicy(info)) {
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_CELLULAR_NETWORK_A11Y_LABEL_MANAGED_WITH_CONNECTION_STATUS,
info.label, connection_status,
base::FormatPercent(info.signal_strength));
}
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_CELLULAR_NETWORK_A11Y_LABEL_WITH_CONNECTION_STATUS,
info.label, connection_status,
base::FormatPercent(info.signal_strength));
}
if (IsManagedByPolicy(info)) {
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_CELLULAR_NETWORK_A11Y_LABEL_MANAGED, info.label,
base::FormatPercent(info.signal_strength));
}
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_CELLULAR_NETWORK_A11Y_LABEL, info.label,
base::FormatPercent(info.signal_strength));
case NetworkType::kTether:
if (!connection_status.empty()) {
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_TETHER_NETWORK_A11Y_LABEL_WITH_CONNECTION_STATUS,
info.label, connection_status,
base::FormatPercent(info.signal_strength),
base::FormatPercent(info.battery_percentage));
}
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_TETHER_NETWORK_A11Y_LABEL, info.label,
base::FormatPercent(info.signal_strength),
base::FormatPercent(info.battery_percentage));
default:
return info.label;
}
} // namespace tray
views::View* NetworkListView::CreatePowerStatusView(const NetworkInfo& info) {
// Mobile can be Cellular or Tether.
if (!NetworkTypeMatchesType(info.type, NetworkType::kMobile))
......
......@@ -128,6 +128,10 @@ class NetworkListView : public NetworkStateListDetailedView,
// otherwise false.
bool NeedUpdateViewForNetwork(const NetworkInfo& info) const;
// Creates a label for the given network which includes all information
// that is shown in the ui.
base::string16 GenerateAccessibilityLabel(const NetworkInfo& info);
bool needs_relayout_ = false;
// Owned by the views heirarchy.
......
......@@ -365,34 +365,24 @@ void TrayDetailedView::SetupConnectedScrollListItem(
base::string16 status;
if (battery_percentage) {
status = l10n_util::GetStringFUTF16(
view->SetSubText(l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_BLUETOOTH_DEVICE_CONNECTED_WITH_BATTERY_LABEL,
base::NumberToString16(battery_percentage.value()));
base::NumberToString16(battery_percentage.value())));
} else {
status =
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED);
view->SetSubText(l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED));
}
view->SetSubText(status);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::CAPTION);
style.set_color_style(TrayPopupItemStyle::ColorStyle::CONNECTED);
style.SetupLabel(view->sub_text_label());
view->SetAccessibleName(l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_ACCESSIBILITY_LABEL,
view->text_label()->GetText(), status));
}
void TrayDetailedView::SetupConnectingScrollListItem(HoverHighlightView* view) {
DCHECK(view->is_populated());
base::string16 status =
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING);
view->SetSubText(status);
view->SetAccessibleName(l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_ACCESSIBILITY_LABEL,
view->text_label()->GetText(), status));
view->SetSubText(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING));
}
TriView* TrayDetailedView::AddScrollListSubHeader(const gfx::VectorIcon& icon,
......
......@@ -348,7 +348,7 @@
"messages": [23125],
},
"ash/components/ash_components_strings.grd": {
"messages": [23740],
"messages": [23800],
},
"ash/keyboard/ui/keyboard_resources.grd": {
"includes": [23960],
......
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