Commit 9adcfb10 authored by Katie D's avatar Katie D Committed by Commit Bot

Keep switch access running until disable dialog is accepted.

Ensures the switch access extension is not unloaded until
the disable dialog is accepted by the user. This allows users
to use switch access switches to accept or cancel the dialog.

AX-Relnotes: n/a
Bug: 1095212
Change-Id: I0c34d1e8c3669faedf27bdbc9d45e4c7b5b29736
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261185
Commit-Queue: Katie Dektar <katie@chromium.org>
Reviewed-by: default avatarAnastasia Helfinstein <anastasi@google.com>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781920}
parent 10b3b32d
...@@ -1119,6 +1119,10 @@ void AccessibilityControllerImpl::SetSwitchAccessEnabled(bool enabled) { ...@@ -1119,6 +1119,10 @@ void AccessibilityControllerImpl::SetSwitchAccessEnabled(bool enabled) {
switch_access().SetEnabled(enabled); switch_access().SetEnabled(enabled);
} }
bool AccessibilityControllerImpl::IsSwitchAccessRunning() const {
return switch_access().enabled() || switch_access_disable_dialog_showing_;
}
bool AccessibilityControllerImpl::IsSwitchAccessSettingVisibleInTray() { bool AccessibilityControllerImpl::IsSwitchAccessSettingVisibleInTray() {
return switch_access().IsVisibleInTray(); return switch_access().IsVisibleInTray();
return IsEnterpriseIconVisibleInTrayMenu( return IsEnterpriseIconVisibleInTrayMenu(
...@@ -1135,11 +1139,13 @@ void AccessibilityControllerImpl:: ...@@ -1135,11 +1139,13 @@ void AccessibilityControllerImpl::
} }
void AccessibilityControllerImpl::HideSwitchAccessBackButton() { void AccessibilityControllerImpl::HideSwitchAccessBackButton() {
switch_access_bubble_controller_->HideBackButton(); if (IsSwitchAccessRunning())
switch_access_bubble_controller_->HideBackButton();
} }
void AccessibilityControllerImpl::HideSwitchAccessMenu() { void AccessibilityControllerImpl::HideSwitchAccessMenu() {
switch_access_bubble_controller_->HideMenuBubble(); if (IsSwitchAccessRunning())
switch_access_bubble_controller_->HideMenuBubble();
} }
void AccessibilityControllerImpl::ShowSwitchAccessBackButton( void AccessibilityControllerImpl::ShowSwitchAccessBackButton(
...@@ -1788,9 +1794,12 @@ void AccessibilityControllerImpl:: ...@@ -1788,9 +1794,12 @@ void AccessibilityControllerImpl::
void AccessibilityControllerImpl::SwitchAccessDisableDialogClosed( void AccessibilityControllerImpl::SwitchAccessDisableDialogClosed(
bool disable_dialog_accepted) { bool disable_dialog_accepted) {
switch_access_disable_dialog_showing_ = false;
if (disable_dialog_accepted) { if (disable_dialog_accepted) {
// The pref was already disabled, but we left switch access on until they // The pref was already disabled, but we left switch access on until they
// accepted the dialog. // accepted the dialog.
if (client_)
client_->OnSwitchAccessDisabled();
switch_access_bubble_controller_.reset(); switch_access_bubble_controller_.reset();
switch_access_event_handler_.reset(); switch_access_event_handler_.reset();
NotifyAccessibilityStatusChanged(); NotifyAccessibilityStatusChanged();
...@@ -1946,13 +1955,12 @@ void AccessibilityControllerImpl::UpdateFeatureFromPref(FeatureType feature) { ...@@ -1946,13 +1955,12 @@ void AccessibilityControllerImpl::UpdateFeatureFromPref(FeatureType feature) {
Shell::Get()->sticky_keys_controller()->Enable(enabled); Shell::Get()->sticky_keys_controller()->Enable(enabled);
break; break;
case FeatureType::kSwitchAccess: case FeatureType::kSwitchAccess:
// Show a dialog before disabling Switch Access.
if (!enabled) { if (!enabled) {
ShowAccessibilityNotification(A11yNotificationType::kNone); ShowAccessibilityNotification(A11yNotificationType::kNone);
if (no_switch_access_disable_confirmation_dialog_for_testing_) { if (no_switch_access_disable_confirmation_dialog_for_testing_) {
SwitchAccessDisableDialogClosed(true); SwitchAccessDisableDialogClosed(true);
} else { } else {
// Show a dialog before disabling Switch Access.
new AccessibilityFeatureDisableDialog( new AccessibilityFeatureDisableDialog(
IDS_ASH_SWITCH_ACCESS_DISABLE_CONFIRMATION_TITLE, IDS_ASH_SWITCH_ACCESS_DISABLE_CONFIRMATION_TITLE,
IDS_ASH_SWITCH_ACCESS_DISABLE_CONFIRMATION_BODY, IDS_ASH_SWITCH_ACCESS_DISABLE_CONFIRMATION_BODY,
...@@ -1962,7 +1970,10 @@ void AccessibilityControllerImpl::UpdateFeatureFromPref(FeatureType feature) { ...@@ -1962,7 +1970,10 @@ void AccessibilityControllerImpl::UpdateFeatureFromPref(FeatureType feature) {
base::BindOnce( base::BindOnce(
&AccessibilityControllerImpl::SwitchAccessDisableDialogClosed, &AccessibilityControllerImpl::SwitchAccessDisableDialogClosed,
weak_ptr_factory_.GetWeakPtr(), false)); weak_ptr_factory_.GetWeakPtr(), false));
switch_access_disable_dialog_showing_ = true;
} }
// Return early. We will call NotifyAccessibilityStatusChanged() if the
// user accepts the dialog.
return; return;
} else { } else {
switch_access_bubble_controller_ = switch_access_bubble_controller_ =
......
...@@ -285,6 +285,9 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController, ...@@ -285,6 +285,9 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,
void SetSwitchAccessEnabled(bool enabled); void SetSwitchAccessEnabled(bool enabled);
bool switch_access_enabled() const { return switch_access().enabled(); } bool switch_access_enabled() const { return switch_access().enabled(); }
// Switch access may be disabled in prefs but still running when the disable
// dialog is displaying.
bool IsSwitchAccessRunning() const;
bool IsSwitchAccessSettingVisibleInTray(); bool IsSwitchAccessSettingVisibleInTray();
bool IsEnterpriseIconVisibleForSwitchAccess(); bool IsEnterpriseIconVisibleForSwitchAccess();
...@@ -475,6 +478,7 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController, ...@@ -475,6 +478,7 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,
SwitchAccessEventHandlerDelegate* switch_access_event_handler_delegate_ = SwitchAccessEventHandlerDelegate* switch_access_event_handler_delegate_ =
nullptr; nullptr;
bool no_switch_access_disable_confirmation_dialog_for_testing_ = false; bool no_switch_access_disable_confirmation_dialog_for_testing_ = false;
bool switch_access_disable_dialog_showing_ = false;
// Used to control the highlights of caret, cursor and focus. // Used to control the highlights of caret, cursor and focus.
std::unique_ptr<AccessibilityHighlightController> std::unique_ptr<AccessibilityHighlightController>
......
...@@ -68,6 +68,8 @@ void TestAccessibilityControllerClient::RequestSelectToSpeakStateChange() { ...@@ -68,6 +68,8 @@ void TestAccessibilityControllerClient::RequestSelectToSpeakStateChange() {
void TestAccessibilityControllerClient:: void TestAccessibilityControllerClient::
RequestAutoclickScrollableBoundsForPoint(gfx::Point& point_in_screen) {} RequestAutoclickScrollableBoundsForPoint(gfx::Point& point_in_screen) {}
void TestAccessibilityControllerClient::OnSwitchAccessDisabled() {}
int32_t TestAccessibilityControllerClient::GetPlayedEarconAndReset() { int32_t TestAccessibilityControllerClient::GetPlayedEarconAndReset() {
int32_t tmp = sound_key_; int32_t tmp = sound_key_;
sound_key_ = -1; sound_key_ = -1;
......
...@@ -40,6 +40,7 @@ class TestAccessibilityControllerClient : public AccessibilityControllerClient { ...@@ -40,6 +40,7 @@ class TestAccessibilityControllerClient : public AccessibilityControllerClient {
void RequestSelectToSpeakStateChange() override; void RequestSelectToSpeakStateChange() override;
void RequestAutoclickScrollableBoundsForPoint( void RequestAutoclickScrollableBoundsForPoint(
gfx::Point& point_in_screen) override; gfx::Point& point_in_screen) override;
void OnSwitchAccessDisabled() override;
int32_t GetPlayedEarconAndReset(); int32_t GetPlayedEarconAndReset();
......
...@@ -16,8 +16,8 @@ namespace ash { ...@@ -16,8 +16,8 @@ namespace ash {
namespace { namespace {
bool IsSwitchAccessEnabled() { bool IsSwitchAccessRunning() {
return Shell::Get()->accessibility_controller()->switch_access_enabled(); return Shell::Get()->accessibility_controller()->IsSwitchAccessRunning();
} }
void CancelEvent(ui::Event* event) { void CancelEvent(ui::Event* event) {
...@@ -89,7 +89,7 @@ bool SwitchAccessEventHandler::SetKeyCodesForCommand( ...@@ -89,7 +89,7 @@ bool SwitchAccessEventHandler::SetKeyCodesForCommand(
} }
void SwitchAccessEventHandler::OnKeyEvent(ui::KeyEvent* event) { void SwitchAccessEventHandler::OnKeyEvent(ui::KeyEvent* event) {
DCHECK(IsSwitchAccessEnabled()); DCHECK(IsSwitchAccessRunning());
DCHECK(event); DCHECK(event);
if (ShouldCancelEvent(*event)) { if (ShouldCancelEvent(*event)) {
......
...@@ -81,6 +81,12 @@ class ASH_PUBLIC_EXPORT AccessibilityControllerClient { ...@@ -81,6 +81,12 @@ class ASH_PUBLIC_EXPORT AccessibilityControllerClient {
// bounds to the given point in screen coordinates. // bounds to the given point in screen coordinates.
virtual void RequestAutoclickScrollableBoundsForPoint( virtual void RequestAutoclickScrollableBoundsForPoint(
gfx::Point& point_in_screen) = 0; gfx::Point& point_in_screen) = 0;
// Called when Switch Access is fully disabled by the user accepting the
// disable dialog. Switch Access must be left running when the pref changes
// and before the disable dialog is accepted, so that users can use Switch
// Access to cancel or accept the dialog.
virtual void OnSwitchAccessDisabled() = 0;
}; };
} // namespace ash } // namespace ash
......
...@@ -985,12 +985,14 @@ void AccessibilityManager::OnSwitchAccessChanged() { ...@@ -985,12 +985,14 @@ void AccessibilityManager::OnSwitchAccessChanged() {
profile_, profile_,
base::BindRepeating(&AccessibilityManager::PostLoadSwitchAccess, base::BindRepeating(&AccessibilityManager::PostLoadSwitchAccess,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} else {
switch_access_loader_->Unload();
switch_access_event_handler_delegate_.reset(nullptr);
} }
} }
void AccessibilityManager::OnSwitchAccessDisabled() {
switch_access_loader_->Unload();
switch_access_event_handler_delegate_.reset();
}
bool AccessibilityManager::IsBrailleDisplayConnected() const { bool AccessibilityManager::IsBrailleDisplayConnected() const {
return braille_display_connected_; return braille_display_connected_;
} }
......
...@@ -290,6 +290,9 @@ class AccessibilityManager ...@@ -290,6 +290,9 @@ class AccessibilityManager
// Set the keys to be captured by Switch Access. // Set the keys to be captured by Switch Access.
void SetSwitchAccessKeys(const std::set<int>& key_codes); void SetSwitchAccessKeys(const std::set<int>& key_codes);
// Unloads Switch Access.
void OnSwitchAccessDisabled();
// Starts or stops dictation (type what you speak). // Starts or stops dictation (type what you speak).
bool ToggleDictation(); bool ToggleDictation();
......
...@@ -149,3 +149,7 @@ void AccessibilityControllerClient::RequestAutoclickScrollableBoundsForPoint( ...@@ -149,3 +149,7 @@ void AccessibilityControllerClient::RequestAutoclickScrollableBoundsForPoint(
chromeos::AccessibilityManager::Get() chromeos::AccessibilityManager::Get()
->RequestAutoclickScrollableBoundsForPoint(point_in_screen); ->RequestAutoclickScrollableBoundsForPoint(point_in_screen);
} }
void AccessibilityControllerClient::OnSwitchAccessDisabled() {
chromeos::AccessibilityManager::Get()->OnSwitchAccessDisabled();
}
...@@ -32,6 +32,7 @@ class AccessibilityControllerClient ...@@ -32,6 +32,7 @@ class AccessibilityControllerClient
void RequestSelectToSpeakStateChange() override; void RequestSelectToSpeakStateChange() override;
void RequestAutoclickScrollableBoundsForPoint( void RequestAutoclickScrollableBoundsForPoint(
gfx::Point& point_in_screen) override; gfx::Point& point_in_screen) override;
void OnSwitchAccessDisabled() override;
private: private:
DISALLOW_COPY_AND_ASSIGN(AccessibilityControllerClient); DISALLOW_COPY_AND_ASSIGN(AccessibilityControllerClient);
......
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