Commit 8aad81e1 authored by Tatsuhisa Yamaguchi's avatar Tatsuhisa Yamaguchi Committed by Commit Bot

Add tooltip and accessible name for status tray network icon.

Test: Manually verified on device, and with ChromeVox
Bug: 888072
Change-Id: I770d7bc1ec207a2052c3f7e5956e212930719e12
Reviewed-on: https://chromium-review.googlesource.com/c/1317112
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606727}
parent ba0104a1
......@@ -790,6 +790,9 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_NETWORK_DISCONNECTED_TOOLTIP" desc="The tooltip text used when network is not connected.">
Disconnected
</message>
<message name="IDS_ASH_STATUS_TRAY_NETWORK_NOT_CONNECTED_A11Y" desc="The message used by accessibility for telling that currently the device is not connected to a network.">
Not connected to netowrk
</message>
<message name="IDS_ASH_STATUS_TRAY_NETWORK_CONNECTING_TOOLTIP" desc="The tooltip text used when network is connecting.">
Connecting to <ph name="NETWORK_NAME">$1<ex>public wifi</ex></ph>
</message>
......
4ec02c891501aa2b8bb43175f33c13e7846078dd
\ No newline at end of file
......@@ -43,6 +43,19 @@ const char* NetworkTrayView::GetClassName() const {
return "NetworkTrayView";
}
views::View* NetworkTrayView::GetTooltipHandlerForPoint(
const gfx::Point& point) {
return GetLocalBounds().Contains(point) ? this : nullptr;
}
bool NetworkTrayView::GetTooltipText(const gfx::Point& p,
base::string16* tooltip) const {
if (connection_status_tooltip_.empty())
return false;
*tooltip = connection_status_tooltip_;
return true;
}
void NetworkTrayView::UpdateNetworkStateHandlerIcon() {
gfx::ImageSkia image;
base::string16 name;
......@@ -115,11 +128,21 @@ void NetworkTrayView::UpdateConnectionStatus(
IDS_ASH_STATUS_TRAY_NETWORK_CONNECTED_ACCESSIBLE,
base::UTF8ToUTF16(connected_network->name()), signal_strength_string);
}
connection_status_tooltip_ = new_connection_status_string;
} else {
new_connection_status_string = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_NOT_CONNECTED_A11Y);
// Use shorter desription like "Disconnected" instead of "disconnected from
// netrowk" for the tooltip, because the visual icon tells that this is
// about the network status.
connection_status_tooltip_ = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_DISCONNECTED_TOOLTIP);
}
if (new_connection_status_string != connection_status_string_) {
connection_status_string_ = new_connection_status_string;
if (notify_a11y && !connection_status_string_.empty())
NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
image_view()->SetAccessibleName(connection_status_string_);
}
}
......
......@@ -34,6 +34,9 @@ class NetworkTrayView : public TrayItemView,
// views::View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override;
bool GetTooltipText(const gfx::Point& p,
base::string16* tooltip) const override;
// network_icon::AnimationObserver:
void NetworkIconChanged() override;
......@@ -49,6 +52,7 @@ class NetworkTrayView : public TrayItemView,
void UpdateIcon(bool tray_icon_visible, const gfx::ImageSkia& image);
base::string16 connection_status_string_;
base::string16 connection_status_tooltip_;
DISALLOW_COPY_AND_ASSIGN(NetworkTrayView);
};
......
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