Commit d9d54248 authored by minch's avatar minch Committed by Commit bot

List all a11y features in a11y detailed view in ash system menu

1. Sticky keys
2. Tap dragging

Changes in this CL,

1. Add four functions in AccessibilityDelegate interface.
   This is used to show above two a11y features in system menu.

BUG=632107

Review-Url: https://codereview.chromium.org/2802783002
Cr-Commit-Position: refs/heads/master@{#462961}
parent b3d846d9
......@@ -342,6 +342,12 @@ Press Ctrl+Alt+Z to disable.
<message name="IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGHLIGHT_KEYBOARD_FOCUS" desc="The label used in the additional settings of accessibility menu of the system tray to toggle on/off highlight keyboard focus.">
Highlight object with keyboard focus
</message>
<message name="IDS_ASH_STATUS_TRAY_ACCESSIBILITY_STICKY_KEYS" desc="The label used in the additional settings of accessibility menu of the system tray to toggle on/off sticky keys.">
Sticky keys
</message>
<message name="IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TAP_DRAGGING" desc="The label used in the additional settings of accessibility menu of the system tray to toggle on/off tap dragging.">
Tap dragging
</message>
<message name="IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SETTINGS" desc="The label used in the accessibility menu of system tray to open accessibility setting page.">
Accessibility settings
</message>
......
......@@ -84,6 +84,18 @@ class ASH_EXPORT AccessibilityDelegate {
// Returns if focus highlighting is enabled.
virtual bool IsFocusHighlightEnabled() const = 0;
// Invoked to enable or disable sticky keys.
virtual void SetStickyKeysEnabled(bool enabled) = 0;
// Returns if sticky keys is enabled.
virtual bool IsStickyKeysEnabled() const = 0;
// Invoked to enable or disable tap dragging.
virtual void SetTapDraggingEnabled(bool enabled) = 0;
// Returns if tap dragging is enabled.
virtual bool IsTapDraggingEnabled() const = 0;
// Invoked to enable or disable select-to-speak.
virtual void SetSelectToSpeakEnabled(bool enabled) = 0;
......
......@@ -96,6 +96,22 @@ bool DefaultAccessibilityDelegate::IsFocusHighlightEnabled() const {
return focus_highligh_enabled_;
}
void DefaultAccessibilityDelegate::SetStickyKeysEnabled(bool enabled) {
sticky_keys_enabled_ = enabled;
}
bool DefaultAccessibilityDelegate::IsStickyKeysEnabled() const {
return sticky_keys_enabled_;
}
void DefaultAccessibilityDelegate::SetTapDraggingEnabled(bool enabled) {
tap_dragging_enabled_ = enabled;
}
bool DefaultAccessibilityDelegate::IsTapDraggingEnabled() const {
return tap_dragging_enabled_;
}
void DefaultAccessibilityDelegate::SetSelectToSpeakEnabled(bool enabled) {
select_to_speak_enabled_ = enabled;
}
......
......@@ -38,6 +38,10 @@ class ASH_EXPORT DefaultAccessibilityDelegate : public AccessibilityDelegate {
bool IsCursorHighlightEnabled() const override;
void SetFocusHighlightEnabled(bool enabled) override;
bool IsFocusHighlightEnabled() const override;
void SetStickyKeysEnabled(bool enabled) override;
bool IsStickyKeysEnabled() const override;
void SetTapDraggingEnabled(bool enabled) override;
bool IsTapDraggingEnabled() const override;
void SetSelectToSpeakEnabled(bool enabled) override;
bool IsSelectToSpeakEnabled() const override;
void SetSwitchAccessEnabled(bool enabled) override;
......@@ -70,6 +74,8 @@ class ASH_EXPORT DefaultAccessibilityDelegate : public AccessibilityDelegate {
bool caret_highlight_enabled_ = false;
bool cursor_highlight_enabled_ = false;
bool focus_highligh_enabled_ = false;
bool sticky_keys_enabled_ = false;
bool tap_dragging_enabled_ = false;
bool select_to_speak_enabled_ = false;
bool switch_access_enabled_ = false;
AccessibilityAlert accessibility_alert_ = A11Y_ALERT_NONE;
......
......@@ -75,6 +75,8 @@ enum UserMetricsAction {
UMA_STATUS_AREA_DISABLE_MAGNIFIER,
UMA_STATUS_AREA_DISABLE_MONO_AUDIO,
UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK,
UMA_STATUS_AREA_DISABLE_STICKY_KEYS,
UMA_STATUS_AREA_DISABLE_TAP_DRAGGING,
UMA_STATUS_AREA_DISABLE_WIFI,
UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD,
UMA_STATUS_AREA_DISPLAY_DEFAULT_SELECTED,
......@@ -93,6 +95,8 @@ enum UserMetricsAction {
UMA_STATUS_AREA_ENABLE_MAGNIFIER,
UMA_STATUS_AREA_ENABLE_MONO_AUDIO,
UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK,
UMA_STATUS_AREA_ENABLE_STICKY_KEYS,
UMA_STATUS_AREA_ENABLE_TAP_DRAGGING,
UMA_STATUS_AREA_ENABLE_WIFI,
UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD,
UMA_STATUS_AREA_IME_SHOW_DETAILED,
......
......@@ -54,6 +54,8 @@ enum AccessibilityState {
A11Y_CARET_HIGHLIGHT = 1 << 8,
A11Y_HIGHLIGHT_MOUSE_CURSOR = 1 << 9,
A11Y_HIGHLIGHT_KEYBOARD_FOCUS = 1 << 10,
A11Y_STICKY_KEYS = 1 << 11,
A11Y_TAP_DRAGGING = 1 << 12,
};
uint32_t GetAccessibilityState() {
......@@ -81,6 +83,10 @@ uint32_t GetAccessibilityState() {
state |= A11Y_HIGHLIGHT_MOUSE_CURSOR;
if (delegate->IsFocusHighlightEnabled())
state |= A11Y_HIGHLIGHT_KEYBOARD_FOCUS;
if (delegate->IsStickyKeysEnabled())
state |= A11Y_STICKY_KEYS;
if (delegate->IsTapDraggingEnabled())
state |= A11Y_TAP_DRAGGING;
return state;
}
......@@ -291,6 +297,16 @@ void AccessibilityDetailedView::AppendAccessibilityList() {
IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGHLIGHT_KEYBOARD_FOCUS),
highlight_keyboard_focus_enabled_);
}
sticky_keys_enabled_ = delegate->IsStickyKeysEnabled();
sticky_keys_view_ = AddScrollListItemWithoutIcon(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_STICKY_KEYS),
sticky_keys_enabled_);
tap_dragging_enabled_ = delegate->IsTapDraggingEnabled();
tap_dragging_view_ = AddScrollListItemWithoutIcon(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TAP_DRAGGING),
tap_dragging_enabled_);
}
HoverHighlightView* AccessibilityDetailedView::AddScrollListItem(
......@@ -386,6 +402,16 @@ void AccessibilityDetailedView::HandleViewClicked(views::View* view) {
? ash::UMA_STATUS_AREA_DISABLE_HIGHLIGHT_KEYBOARD_FOCUS
: ash::UMA_STATUS_AREA_ENABLE_HIGHLIGHT_KEYBOARD_FOCUS;
delegate->SetFocusHighlightEnabled(!delegate->IsFocusHighlightEnabled());
} else if (sticky_keys_view_ && view == sticky_keys_view_) {
user_action = delegate->IsStickyKeysEnabled()
? ash::UMA_STATUS_AREA_DISABLE_STICKY_KEYS
: ash::UMA_STATUS_AREA_ENABLE_STICKY_KEYS;
delegate->SetStickyKeysEnabled(!delegate->IsStickyKeysEnabled());
} else if (tap_dragging_view_ && view == tap_dragging_view_) {
user_action = delegate->IsTapDraggingEnabled()
? ash::UMA_STATUS_AREA_DISABLE_TAP_DRAGGING
: ash::UMA_STATUS_AREA_ENABLE_TAP_DRAGGING;
delegate->SetTapDraggingEnabled(!delegate->IsTapDraggingEnabled());
} else {
return;
}
......
......@@ -103,6 +103,8 @@ class AccessibilityDetailedView : public TrayDetailsView,
views::View* caret_highlight_view_ = nullptr;
views::View* highlight_mouse_cursor_view_ = nullptr;
views::View* highlight_keyboard_focus_view_ = nullptr;
views::View* sticky_keys_view_ = nullptr;
views::View* tap_dragging_view_ = nullptr;
bool spoken_feedback_enabled_ = false;
bool high_contrast_enabled_ = false;
......@@ -114,6 +116,8 @@ class AccessibilityDetailedView : public TrayDetailsView,
bool caret_highlight_enabled_ = false;
bool highlight_mouse_cursor_enabled_ = false;
bool highlight_keyboard_focus_enabled_ = false;
bool sticky_keys_enabled_ = false;
bool tap_dragging_enabled_ = false;
LoginStatus login_;
friend class chromeos::TrayAccessibilityTest;
......
......@@ -407,6 +407,12 @@ void UserMetricsRecorder::RecordUserMetricsAction(UserMetricsAction action) {
case UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK:
RecordAction(UserMetricsAction("StatusArea_SpokenFeedbackDisabled"));
break;
case UMA_STATUS_AREA_DISABLE_STICKY_KEYS:
RecordAction(UserMetricsAction("StatusArea_StickyKeysDisabled"));
break;
case UMA_STATUS_AREA_DISABLE_TAP_DRAGGING:
RecordAction(UserMetricsAction("StatusArea_TapDraggingDisabled"));
break;
case UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD:
RecordAction(UserMetricsAction("StatusArea_VirtualKeyboardDisabled"));
break;
......@@ -466,6 +472,12 @@ void UserMetricsRecorder::RecordUserMetricsAction(UserMetricsAction action) {
case UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK:
RecordAction(UserMetricsAction("StatusArea_SpokenFeedbackEnabled"));
break;
case UMA_STATUS_AREA_ENABLE_STICKY_KEYS:
RecordAction(UserMetricsAction("StatusArea_StickyKeysEnabled"));
break;
case UMA_STATUS_AREA_ENABLE_TAP_DRAGGING:
RecordAction(UserMetricsAction("StatusArea_TapDraggingEnabled"));
break;
case UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD:
RecordAction(UserMetricsAction("StatusArea_VirtualKeyboardEnabled"));
break;
......
......@@ -45,6 +45,7 @@
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h"
#include "chrome/browser/extensions/api/braille_display_private/stub_braille_controller.h"
#include "chrome/browser/extensions/extension_service.h"
......@@ -236,6 +237,7 @@ AccessibilityManager* AccessibilityManager::Get() {
AccessibilityManager::AccessibilityManager()
: profile_(NULL),
large_cursor_pref_handler_(prefs::kAccessibilityLargeCursorEnabled),
sticky_keys_pref_handler_(prefs::kAccessibilityStickyKeysEnabled),
spoken_feedback_pref_handler_(prefs::kAccessibilitySpokenFeedbackEnabled),
high_contrast_pref_handler_(prefs::kAccessibilityHighContrastEnabled),
autoclick_pref_handler_(prefs::kAccessibilityAutoclickEnabled),
......@@ -247,6 +249,7 @@ AccessibilityManager::AccessibilityManager()
cursor_highlight_pref_handler_(
prefs::kAccessibilityCursorHighlightEnabled),
focus_highlight_pref_handler_(prefs::kAccessibilityFocusHighlightEnabled),
tap_dragging_pref_handler_(prefs::kTapDraggingEnabled),
select_to_speak_pref_handler_(prefs::kAccessibilitySelectToSpeakEnabled),
switch_access_pref_handler_(prefs::kAccessibilitySwitchAccessEnabled),
large_cursor_enabled_(false),
......@@ -261,6 +264,7 @@ AccessibilityManager::AccessibilityManager()
caret_highlight_enabled_(false),
cursor_highlight_enabled_(false),
focus_highlight_enabled_(false),
tap_dragging_enabled_(false),
select_to_speak_enabled_(false),
switch_access_enabled_(false),
spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE),
......@@ -359,7 +363,8 @@ bool AccessibilityManager::ShouldShowAccessibilityMenu() {
pref_service->GetBoolean(prefs::kAccessibilityMonoAudioEnabled) ||
pref_service->GetBoolean(prefs::kAccessibilityCaretHighlightEnabled) ||
pref_service->GetBoolean(prefs::kAccessibilityCursorHighlightEnabled) ||
pref_service->GetBoolean(prefs::kAccessibilityFocusHighlightEnabled))
pref_service->GetBoolean(prefs::kAccessibilityFocusHighlightEnabled) ||
pref_service->GetBoolean(prefs::kTapDraggingEnabled))
return true;
}
return false;
......@@ -457,6 +462,10 @@ void AccessibilityManager::UpdateStickyKeysFromPref() {
return;
sticky_keys_enabled_ = enabled;
AccessibilityStatusEventDetails details(ACCESSIBILITY_TOGGLE_STICKY_KEYS,
enabled, ash::A11Y_NOTIFICATION_NONE);
NotifyAccessibilityStatusChanged(details);
ash::Shell::Get()->sticky_keys_controller()->Enable(enabled);
}
......@@ -902,6 +911,38 @@ void AccessibilityManager::UpdateFocusHighlightFromPref() {
UpdateAccessibilityHighlightingFromPrefs();
}
void AccessibilityManager::EnableTapDragging(bool enabled) {
if (!profile_)
return;
PrefService* pref_service = profile_->GetPrefs();
pref_service->SetBoolean(prefs::kTapDraggingEnabled, enabled);
pref_service->CommitPendingWrite();
}
bool AccessibilityManager::IsTapDraggingEnabled() {
return tap_dragging_enabled_;
}
void AccessibilityManager::UpdateTapDraggingFromPref() {
if (!profile_)
return;
const bool enabled =
profile_->GetPrefs()->GetBoolean(prefs::kTapDraggingEnabled);
if (tap_dragging_enabled_ == enabled)
return;
tap_dragging_enabled_ = enabled;
AccessibilityStatusEventDetails details(ACCESSIBILITY_TOGGLE_TAP_DRAGGING,
enabled, ash::A11Y_NOTIFICATION_NONE);
NotifyAccessibilityStatusChanged(details);
system::TouchpadSettings touchpad_settings;
touchpad_settings.SetTapDragging(enabled);
}
void AccessibilityManager::SetSelectToSpeakEnabled(bool enabled) {
if (!profile_)
return;
......@@ -1124,6 +1165,10 @@ void AccessibilityManager::SetProfile(Profile* profile) {
prefs::kAccessibilityFocusHighlightEnabled,
base::Bind(&AccessibilityManager::UpdateFocusHighlightFromPref,
base::Unretained(this)));
pref_change_registrar_->Add(
prefs::kTapDraggingEnabled,
base::Bind(&AccessibilityManager::UpdateTapDraggingFromPref,
base::Unretained(this)));
pref_change_registrar_->Add(
prefs::kAccessibilitySelectToSpeakEnabled,
base::Bind(&AccessibilityManager::UpdateSelectToSpeakFromPref,
......@@ -1154,6 +1199,7 @@ void AccessibilityManager::SetProfile(Profile* profile) {
large_cursor_pref_handler_.HandleProfileChanged(profile_, profile);
spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile);
high_contrast_pref_handler_.HandleProfileChanged(profile_, profile);
sticky_keys_pref_handler_.HandleProfileChanged(profile_, profile);
autoclick_pref_handler_.HandleProfileChanged(profile_, profile);
autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile);
virtual_keyboard_pref_handler_.HandleProfileChanged(profile_, profile);
......@@ -1161,6 +1207,7 @@ void AccessibilityManager::SetProfile(Profile* profile) {
caret_highlight_pref_handler_.HandleProfileChanged(profile_, profile);
cursor_highlight_pref_handler_.HandleProfileChanged(profile_, profile);
focus_highlight_pref_handler_.HandleProfileChanged(profile_, profile);
tap_dragging_pref_handler_.HandleProfileChanged(profile_, profile);
select_to_speak_pref_handler_.HandleProfileChanged(profile_, profile);
switch_access_pref_handler_.HandleProfileChanged(profile_, profile);
......@@ -1182,6 +1229,7 @@ void AccessibilityManager::SetProfile(Profile* profile) {
UpdateCaretHighlightFromPref();
UpdateCursorHighlightFromPref();
UpdateFocusHighlightFromPref();
UpdateTapDraggingFromPref();
UpdateSelectToSpeakFromPref();
UpdateSwitchAccessFromPref();
......
......@@ -44,6 +44,7 @@ enum AccessibilityNotificationType {
ACCESSIBILITY_MANAGER_SHUTDOWN,
ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE,
ACCESSIBILITY_TOGGLE_LARGE_CURSOR,
ACCESSIBILITY_TOGGLE_STICKY_KEYS,
ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER,
ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK,
ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD,
......@@ -51,6 +52,7 @@ enum AccessibilityNotificationType {
ACCESSIBILITY_TOGGLE_CARET_HIGHLIGHT,
ACCESSIBILITY_TOGGLE_CURSOR_HIGHLIGHT,
ACCESSIBILITY_TOGGLE_FOCUS_HIGHLIGHT,
ACCESSIBILITY_TOGGLE_TAP_DRAGGING,
ACCESSIBILITY_BRAILLE_DISPLAY_CONNECTION_STATE_CHANGED
};
......@@ -206,6 +208,12 @@ class AccessibilityManager
// Returns if focus highlighting is enabled.
bool IsFocusHighlightEnabled() const;
// Enables or disables tap dragging.
void EnableTapDragging(bool enabled);
// Returns true if the tap dragging is enabled, or false if not.
bool IsTapDraggingEnabled();
// Invoked to enable or disable select-to-speak.
void SetSelectToSpeakEnabled(bool enabled);
......@@ -316,6 +324,7 @@ class AccessibilityManager
void UpdateCaretHighlightFromPref();
void UpdateCursorHighlightFromPref();
void UpdateFocusHighlightFromPref();
void UpdateTapDraggingFromPref();
void UpdateSelectToSpeakFromPref();
void UpdateSwitchAccessFromPref();
void UpdateAccessibilityHighlightingFromPrefs();
......@@ -368,6 +377,7 @@ class AccessibilityManager
session_state_observer_;
PrefHandler large_cursor_pref_handler_;
PrefHandler sticky_keys_pref_handler_;
PrefHandler spoken_feedback_pref_handler_;
PrefHandler high_contrast_pref_handler_;
PrefHandler autoclick_pref_handler_;
......@@ -377,6 +387,7 @@ class AccessibilityManager
PrefHandler caret_highlight_pref_handler_;
PrefHandler cursor_highlight_pref_handler_;
PrefHandler focus_highlight_pref_handler_;
PrefHandler tap_dragging_pref_handler_;
PrefHandler select_to_speak_pref_handler_;
PrefHandler switch_access_pref_handler_;
......@@ -392,6 +403,7 @@ class AccessibilityManager
bool caret_highlight_enabled_;
bool cursor_highlight_enabled_;
bool focus_highlight_enabled_;
bool tap_dragging_enabled_;
bool select_to_speak_enabled_;
bool switch_access_enabled_;
......
......@@ -221,6 +221,26 @@ class AccessibilityDelegateImpl : public ash::AccessibilityDelegate {
return AccessibilityManager::Get()->IsFocusHighlightEnabled();
}
void SetStickyKeysEnabled(bool enabled) override {
DCHECK(AccessibilityManager::Get());
return AccessibilityManager::Get()->EnableStickyKeys(enabled);
}
bool IsStickyKeysEnabled() const override {
DCHECK(AccessibilityManager::Get());
return AccessibilityManager::Get()->IsStickyKeysEnabled();
}
void SetTapDraggingEnabled(bool enabled) override {
DCHECK(AccessibilityManager::Get());
return AccessibilityManager::Get()->EnableTapDragging(enabled);
}
bool IsTapDraggingEnabled() const override {
DCHECK(AccessibilityManager::Get());
return AccessibilityManager::Get()->IsTapDraggingEnabled();
}
void SetSelectToSpeakEnabled(bool enabled) override {
DCHECK(AccessibilityManager::Get());
AccessibilityManager::Get()->SetSelectToSpeakEnabled(enabled);
......
......@@ -15628,6 +15628,28 @@ should be able to be added at any place in this file.
<description>Please enter the description of this user action.</description>
</action>
<action name="StatusArea_StickyKeysDisabled">
<owner>minch@chromium.org</owner>
<description>Ash system menu: Accessibility: Disable sticky keys</description>
</action>
<action name="StatusArea_StickyKeysEnabled">
<owner>minch@chromium.org</owner>
<description>Ash system menu: Accessibility: Enable sticky keys</description>
</action>
<action name="StatusArea_TapDraggingDisabled">
<owner>minch@chromium.org</owner>
<description>
Ash system menu: Accessibility: Disable tap dragging
</description>
</action>
<action name="StatusArea_TapDraggingEnabled">
<owner>minch@chromium.org</owner>
<description>Ash system menu: Accessibility: Enable tap dragging</description>
</action>
<action name="StatusArea_Tracing_Default_Selected">
<owner>bruthig@chromium.org</owner>
<owner>tbuckley@chromium.org</owner>
......
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