Commit 55e112b5 authored by afakhry's avatar afakhry Committed by Commit Bot

[Night Light] Accessibility: Make ChromeVox speak button status on toggles

Make ChromeVox speak the status of the Night Light system tray button when
the button is pressed and the status is toggled.

BUG=706067

Review-Url: https://codereview.chromium.org/2965163002
Cr-Commit-Position: refs/heads/master@{#484948}
parent e61c23ac
......@@ -9,6 +9,7 @@
#include "ash/system/night_light/night_light_controller.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_popup_item_style.h"
#include "ui/accessibility/ax_enums.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h"
......@@ -54,6 +55,13 @@ NightLightToggleButton::NightLightToggleButton(views::ButtonListener* listener)
Update();
}
void NightLightToggleButton::Toggle() {
DCHECK(NightLightController::IsFeatureEnabled());
Shell::Get()->night_light_controller()->Toggle();
Update();
NotifyAccessibilityEvent(ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED, true);
}
void NightLightToggleButton::Update() {
const bool night_light_enabled =
Shell::Get()->night_light_controller()->GetEnabled();
......
......@@ -16,10 +16,13 @@ class NightLightToggleButton : public SystemMenuButton {
explicit NightLightToggleButton(views::ButtonListener* listener);
~NightLightToggleButton() override = default;
// Toggles the status of NightLight.
void Toggle();
private:
// Updates the icon and its style based on the status of NightLight.
void Update();
private:
// views::View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
......
......@@ -126,8 +126,7 @@ void TilesDefaultView::ButtonPressed(views::Button* sender,
} else if (NightLightController::IsFeatureEnabled() &&
sender == night_light_button_) {
Shell::Get()->metrics()->RecordUserMetricsAction(UMA_TRAY_NIGHT_LIGHT);
Shell::Get()->night_light_controller()->Toggle();
night_light_button_->Update();
night_light_button_->Toggle();
} else if (sender == lock_button_) {
Shell::Get()->metrics()->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN);
chromeos::DBusThreadManager::Get()
......
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