Commit dfdf5750 authored by Amr Aboelkher's avatar Amr Aboelkher Committed by Commit Bot

Manage the visibility of cursor highlight accessibility feature on accessibility tray menu

Show the cursor highlight accessibility feature only if one of the following conditions have meet :
-Its not being controlled by any policy
-Its being controlled by a policy and the value of the policy is force on

Bug: 552439
Change-Id: I48823a53cb0ebbaf2edc732de56452871ee08eba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1725915
Commit-Queue: Amr Aboelkher <amraboelkher@google.com>
Reviewed-by: default avatarAlice Boxhall <aboxhall@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684344}
parent 5915dae5
...@@ -466,6 +466,11 @@ void AccessibilityControllerImpl::SetCursorHighlightEnabled(bool enabled) { ...@@ -466,6 +466,11 @@ void AccessibilityControllerImpl::SetCursorHighlightEnabled(bool enabled) {
active_user_prefs_->CommitPendingWrite(); active_user_prefs_->CommitPendingWrite();
} }
bool AccessibilityControllerImpl::GetTrayVisiblityOfCursorHighlightSetting() {
return IsAccessibilityFeatureVisibleInTrayMenu(
prefs::kAccessibilityCursorHighlightEnabled);
}
void AccessibilityControllerImpl::SetDictationEnabled(bool enabled) { void AccessibilityControllerImpl::SetDictationEnabled(bool enabled) {
if (!active_user_prefs_) if (!active_user_prefs_)
return; return;
......
...@@ -91,6 +91,10 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController, ...@@ -91,6 +91,10 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,
void SetCursorHighlightEnabled(bool enabled); void SetCursorHighlightEnabled(bool enabled);
bool cursor_highlight_enabled() const { return cursor_highlight_enabled_; } bool cursor_highlight_enabled() const { return cursor_highlight_enabled_; }
// Returns true if the cursor highlight is being controlled by a policy
// which enforces turning it on or its not being controlled by any type of
// policy and false otherwise.
bool GetTrayVisiblityOfCursorHighlightSetting();
void SetDictationEnabled(bool enabled); void SetDictationEnabled(bool enabled);
bool dictation_enabled() const { return dictation_enabled_; } bool dictation_enabled() const { return dictation_enabled_; }
......
...@@ -352,6 +352,45 @@ TEST_F(AccessibilityControllerTest, DictationTrayMenuVisibility) { ...@@ -352,6 +352,45 @@ TEST_F(AccessibilityControllerTest, DictationTrayMenuVisibility) {
EXPECT_FALSE(controller->GetTrayVisiblityOfDictationSetting()); EXPECT_FALSE(controller->GetTrayVisiblityOfDictationSetting());
} }
TEST_F(AccessibilityControllerTest, CursorHighlightTrayMenuVisibility) {
// Check that when the pref isn't being controlled by any policy will be
// visible in the accessibility tray menu despite its value.
PrefService* prefs =
Shell::Get()->session_controller()->GetLastActiveUserPrefService();
AccessibilityControllerImpl* controller =
Shell::Get()->accessibility_controller();
// Check when the value is true and not being controlled by any policy.
controller->SetCursorHighlightEnabled(true);
EXPECT_FALSE(
prefs->IsManagedPreference(prefs::kAccessibilityCursorHighlightEnabled));
EXPECT_TRUE(controller->cursor_highlight_enabled());
EXPECT_TRUE(controller->GetTrayVisiblityOfCursorHighlightSetting());
// Check when the value is false and not being controlled by any policy.
controller->SetCursorHighlightEnabled(false);
EXPECT_FALSE(
prefs->IsManagedPreference(prefs::kAccessibilityCursorHighlightEnabled));
EXPECT_FALSE(controller->cursor_highlight_enabled());
EXPECT_TRUE(controller->GetTrayVisiblityOfCursorHighlightSetting());
// Check that when the pref is managed and being forced on then it will be
// visible.
static_cast<TestingPrefServiceSimple*>(prefs)->SetManagedPref(
prefs::kAccessibilityCursorHighlightEnabled,
std::make_unique<base::Value>(true));
EXPECT_TRUE(
prefs->IsManagedPreference(prefs::kAccessibilityCursorHighlightEnabled));
EXPECT_TRUE(controller->GetTrayVisiblityOfCursorHighlightSetting());
// Check that when the pref is managed and only being forced off then it will
// be invisible.
static_cast<TestingPrefServiceSimple*>(prefs)->SetManagedPref(
prefs::kAccessibilityCursorHighlightEnabled,
std::make_unique<base::Value>(false));
EXPECT_TRUE(
prefs->IsManagedPreference(prefs::kAccessibilityCursorHighlightEnabled));
EXPECT_FALSE(controller->cursor_highlight_enabled());
EXPECT_FALSE(controller->GetTrayVisiblityOfCursorHighlightSetting());
}
TEST_F(AccessibilityControllerTest, DisableLargeCursorResetsSize) { TEST_F(AccessibilityControllerTest, DisableLargeCursorResetsSize) {
PrefService* prefs = PrefService* prefs =
Shell::Get()->session_controller()->GetLastActiveUserPrefService(); Shell::Get()->session_controller()->GetLastActiveUserPrefService();
......
...@@ -133,9 +133,12 @@ void AccessibilityDetailedView::OnAccessibilityStatusChanged() { ...@@ -133,9 +133,12 @@ void AccessibilityDetailedView::OnAccessibilityStatusChanged() {
TrayPopupUtils::UpdateCheckMarkVisibility(caret_highlight_view_, TrayPopupUtils::UpdateCheckMarkVisibility(caret_highlight_view_,
caret_highlight_enabled_); caret_highlight_enabled_);
highlight_mouse_cursor_enabled_ = controller->cursor_highlight_enabled(); if (highlight_mouse_cursor_view_ &&
TrayPopupUtils::UpdateCheckMarkVisibility(highlight_mouse_cursor_view_, controller->GetTrayVisiblityOfCursorHighlightSetting()) {
highlight_mouse_cursor_enabled_); highlight_mouse_cursor_enabled_ = controller->cursor_highlight_enabled();
TrayPopupUtils::UpdateCheckMarkVisibility(highlight_mouse_cursor_view_,
highlight_mouse_cursor_enabled_);
}
if (highlight_keyboard_focus_view_) { if (highlight_keyboard_focus_view_) {
highlight_keyboard_focus_enabled_ = controller->focus_highlight_enabled(); highlight_keyboard_focus_enabled_ = controller->focus_highlight_enabled();
...@@ -256,12 +259,13 @@ void AccessibilityDetailedView::AppendAccessibilityList() { ...@@ -256,12 +259,13 @@ void AccessibilityDetailedView::AppendAccessibilityList() {
IDS_ASH_STATUS_TRAY_ACCESSIBILITY_CARET_HIGHLIGHT), IDS_ASH_STATUS_TRAY_ACCESSIBILITY_CARET_HIGHLIGHT),
caret_highlight_enabled_); caret_highlight_enabled_);
highlight_mouse_cursor_enabled_ = controller->cursor_highlight_enabled(); if (controller->GetTrayVisiblityOfCursorHighlightSetting()) {
highlight_mouse_cursor_view_ = AddScrollListCheckableItem( highlight_mouse_cursor_enabled_ = controller->cursor_highlight_enabled();
l10n_util::GetStringUTF16( highlight_mouse_cursor_view_ = AddScrollListCheckableItem(
IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGHLIGHT_MOUSE_CURSOR), l10n_util::GetStringUTF16(
highlight_mouse_cursor_enabled_); IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGHLIGHT_MOUSE_CURSOR),
highlight_mouse_cursor_enabled_);
}
// Focus highlighting can't be on when spoken feedback is on because // Focus highlighting can't be on when spoken feedback is on because
// ChromeVox does its own focus highlighting. // ChromeVox does its own focus highlighting.
if (!spoken_feedback_enabled_) { if (!spoken_feedback_enabled_) {
......
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