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

Manage the visibility of dictation accessibility feature on accessibility tray menu

Show the dictation 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: Id76a331ecfaed2fdcf24a65bd56552287b92bb9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1725640
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@{#684312}
parent d2e90125
......@@ -491,6 +491,11 @@ void AccessibilityControllerImpl::SetDictationEnabled(bool enabled) {
active_user_prefs_->CommitPendingWrite();
}
bool AccessibilityControllerImpl::GetTrayVisiblityOfDictationSetting() {
return IsAccessibilityFeatureVisibleInTrayMenu(
prefs::kAccessibilityDictationEnabled);
}
void AccessibilityControllerImpl::SetFocusHighlightEnabled(bool enabled) {
if (!active_user_prefs_)
return;
......
......@@ -94,6 +94,10 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,
void SetDictationEnabled(bool enabled);
bool dictation_enabled() const { return dictation_enabled_; }
// Returns true if the dictation 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 GetTrayVisiblityOfDictationSetting();
void SetFocusHighlightEnabled(bool enabled);
bool focus_highlight_enabled() const { return focus_highlight_enabled_; }
......
......@@ -310,6 +310,48 @@ TEST_F(AccessibilityControllerTest, MonoAudioTrayMenuVisibility) {
EXPECT_FALSE(controller->GetTrayVisiblityOfMonoAudioSetting());
}
TEST_F(AccessibilityControllerTest, DictationTrayMenuVisibility) {
// 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();
// Required to set the dialog to be true to change the value of the pref from
// the |AccessibilityControllerImpl|.
prefs->SetBoolean(prefs::kDictationAcceleratorDialogHasBeenAccepted, true);
// Check when the value is true and not being controlled by any policy.
controller->SetDictationEnabled(true);
EXPECT_FALSE(
prefs->IsManagedPreference(prefs::kAccessibilityDictationEnabled));
EXPECT_TRUE(controller->dictation_enabled());
EXPECT_TRUE(controller->GetTrayVisiblityOfDictationSetting());
// Check when the value is false and not being controlled by any policy.
controller->SetDictationEnabled(false);
EXPECT_FALSE(
prefs->IsManagedPreference(prefs::kAccessibilityDictationEnabled));
EXPECT_FALSE(controller->dictation_enabled());
EXPECT_TRUE(controller->GetTrayVisiblityOfDictationSetting());
// Check that when the pref is managed and being forced on then it will be
// visible.
static_cast<TestingPrefServiceSimple*>(prefs)->SetManagedPref(
prefs::kAccessibilityDictationEnabled,
std::make_unique<base::Value>(true));
EXPECT_TRUE(
prefs->IsManagedPreference(prefs::kAccessibilityDictationEnabled));
EXPECT_TRUE(controller->GetTrayVisiblityOfDictationSetting());
// Check that when the pref is managed and only being forced off then it will
// be invisible.
static_cast<TestingPrefServiceSimple*>(prefs)->SetManagedPref(
prefs::kAccessibilityDictationEnabled,
std::make_unique<base::Value>(false));
EXPECT_TRUE(
prefs->IsManagedPreference(prefs::kAccessibilityDictationEnabled));
EXPECT_FALSE(controller->dictation_enabled());
EXPECT_FALSE(controller->GetTrayVisiblityOfDictationSetting());
}
TEST_F(AccessibilityControllerTest, DisableLargeCursorResetsSize) {
PrefService* prefs =
Shell::Get()->session_controller()->GetLastActiveUserPrefService();
......
......@@ -80,9 +80,11 @@ void AccessibilityDetailedView::OnAccessibilityStatusChanged() {
TrayPopupUtils::UpdateCheckMarkVisibility(select_to_speak_view_,
select_to_speak_enabled_);
dictation_enabled_ = controller->dictation_enabled();
TrayPopupUtils::UpdateCheckMarkVisibility(dictation_view_,
dictation_enabled_);
if (dictation_view_ && controller->GetTrayVisiblityOfDictationSetting()) {
dictation_enabled_ = controller->dictation_enabled();
TrayPopupUtils::UpdateCheckMarkVisibility(dictation_view_,
dictation_enabled_);
}
if (high_contrast_view_ &&
controller->GetTrayVisiblityOfHighContrastSetting()) {
......@@ -171,11 +173,13 @@ void AccessibilityDetailedView::AppendAccessibilityList() {
IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SELECT_TO_SPEAK),
select_to_speak_enabled_);
dictation_enabled_ = controller->dictation_enabled();
dictation_view_ = AddScrollListCheckableItem(
kDictationMenuIcon,
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_DICTATION),
dictation_enabled_);
if (controller->GetTrayVisiblityOfDictationSetting()) {
dictation_enabled_ = controller->dictation_enabled();
dictation_view_ = AddScrollListCheckableItem(
kDictationMenuIcon,
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_DICTATION),
dictation_enabled_);
}
if (controller->GetTrayVisiblityOfHighContrastSetting()) {
high_contrast_enabled_ = controller->high_contrast_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