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

Manage the visibility of high contrast feature on accessibility tray menu

Show the high contrast 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: Ia96b797ad9d1ea839b1e8cb74f597dbdfc8cc86b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1725911
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@{#682894}
parent c9c8d11d
...@@ -515,6 +515,11 @@ void AccessibilityControllerImpl::SetHighContrastEnabled(bool enabled) { ...@@ -515,6 +515,11 @@ void AccessibilityControllerImpl::SetHighContrastEnabled(bool enabled) {
active_user_prefs_->CommitPendingWrite(); active_user_prefs_->CommitPendingWrite();
} }
bool AccessibilityControllerImpl::GetTrayVisiblityOfHighContrastSetting() {
return IsAccessibilityFeatureVisibleInTrayMenu(
prefs::kAccessibilityHighContrastEnabled);
}
void AccessibilityControllerImpl::SetLargeCursorEnabled(bool enabled) { void AccessibilityControllerImpl::SetLargeCursorEnabled(bool enabled) {
if (!active_user_prefs_) if (!active_user_prefs_)
return; return;
......
...@@ -102,6 +102,10 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController, ...@@ -102,6 +102,10 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,
void SetHighContrastEnabled(bool enabled); void SetHighContrastEnabled(bool enabled);
bool high_contrast_enabled() const { return high_contrast_enabled_; } bool high_contrast_enabled() const { return high_contrast_enabled_; }
// Returns true if the high contrast 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 GetTrayVisiblityOfHighContrastSetting();
void SetLargeCursorEnabled(bool enabled); void SetLargeCursorEnabled(bool enabled);
bool large_cursor_enabled() const { return large_cursor_enabled_; } bool large_cursor_enabled() const { return large_cursor_enabled_; }
......
...@@ -232,6 +232,45 @@ TEST_F(AccessibilityControllerTest, LargeCursorTrayMenuVisibility) { ...@@ -232,6 +232,45 @@ TEST_F(AccessibilityControllerTest, LargeCursorTrayMenuVisibility) {
EXPECT_FALSE(controller->GetTrayVisiblityOfLargeCursorSetting()); EXPECT_FALSE(controller->GetTrayVisiblityOfLargeCursorSetting());
} }
TEST_F(AccessibilityControllerTest, HighContrastTrayMenuVisibility) {
// 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->SetHighContrastEnabled(true);
EXPECT_FALSE(
prefs->IsManagedPreference(prefs::kAccessibilityHighContrastEnabled));
EXPECT_TRUE(controller->high_contrast_enabled());
EXPECT_TRUE(controller->GetTrayVisiblityOfHighContrastSetting());
// Check when the value is false and not being controlled by any policy.
controller->SetHighContrastEnabled(false);
EXPECT_FALSE(
prefs->IsManagedPreference(prefs::kAccessibilityHighContrastEnabled));
EXPECT_FALSE(controller->high_contrast_enabled());
EXPECT_TRUE(controller->GetTrayVisiblityOfHighContrastSetting());
// Check that when the pref is managed and being forced on then it will be
// visible.
static_cast<TestingPrefServiceSimple*>(prefs)->SetManagedPref(
prefs::kAccessibilityHighContrastEnabled,
std::make_unique<base::Value>(true));
EXPECT_TRUE(
prefs->IsManagedPreference(prefs::kAccessibilityHighContrastEnabled));
EXPECT_TRUE(controller->GetTrayVisiblityOfHighContrastSetting());
// Check that when the pref is managed and only being forced off then it will
// be invisible.
static_cast<TestingPrefServiceSimple*>(prefs)->SetManagedPref(
prefs::kAccessibilityHighContrastEnabled,
std::make_unique<base::Value>(false));
EXPECT_TRUE(
prefs->IsManagedPreference(prefs::kAccessibilityHighContrastEnabled));
EXPECT_FALSE(controller->high_contrast_enabled());
EXPECT_FALSE(controller->GetTrayVisiblityOfHighContrastSetting());
}
TEST_F(AccessibilityControllerTest, DisableLargeCursorResetsSize) { TEST_F(AccessibilityControllerTest, DisableLargeCursorResetsSize) {
PrefService* prefs = PrefService* prefs =
Shell::Get()->session_controller()->GetLastActiveUserPrefService(); Shell::Get()->session_controller()->GetLastActiveUserPrefService();
......
...@@ -84,9 +84,12 @@ void AccessibilityDetailedView::OnAccessibilityStatusChanged() { ...@@ -84,9 +84,12 @@ void AccessibilityDetailedView::OnAccessibilityStatusChanged() {
TrayPopupUtils::UpdateCheckMarkVisibility(dictation_view_, TrayPopupUtils::UpdateCheckMarkVisibility(dictation_view_,
dictation_enabled_); dictation_enabled_);
high_contrast_enabled_ = controller->high_contrast_enabled(); if (high_contrast_view_ &&
TrayPopupUtils::UpdateCheckMarkVisibility(high_contrast_view_, controller->GetTrayVisiblityOfHighContrastSetting()) {
high_contrast_enabled_); high_contrast_enabled_ = controller->high_contrast_enabled();
TrayPopupUtils::UpdateCheckMarkVisibility(high_contrast_view_,
high_contrast_enabled_);
}
screen_magnifier_enabled_ = delegate->IsMagnifierEnabled(); screen_magnifier_enabled_ = delegate->IsMagnifierEnabled();
TrayPopupUtils::UpdateCheckMarkVisibility(screen_magnifier_view_, TrayPopupUtils::UpdateCheckMarkVisibility(screen_magnifier_view_,
...@@ -172,12 +175,14 @@ void AccessibilityDetailedView::AppendAccessibilityList() { ...@@ -172,12 +175,14 @@ void AccessibilityDetailedView::AppendAccessibilityList() {
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_DICTATION), l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_DICTATION),
dictation_enabled_); dictation_enabled_);
high_contrast_enabled_ = controller->high_contrast_enabled(); if (controller->GetTrayVisiblityOfHighContrastSetting()) {
high_contrast_view_ = AddScrollListCheckableItem( high_contrast_enabled_ = controller->high_contrast_enabled();
kSystemMenuAccessibilityContrastIcon, high_contrast_view_ = AddScrollListCheckableItem(
l10n_util::GetStringUTF16( kSystemMenuAccessibilityContrastIcon,
IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE), l10n_util::GetStringUTF16(
high_contrast_enabled_); IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE),
high_contrast_enabled_);
}
screen_magnifier_enabled_ = delegate->IsMagnifierEnabled(); screen_magnifier_enabled_ = delegate->IsMagnifierEnabled();
screen_magnifier_view_ = AddScrollListCheckableItem( screen_magnifier_view_ = AddScrollListCheckableItem(
......
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