diff --git a/ash/BUILD.gn b/ash/BUILD.gn index b6144739401db8..245192458e7074 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn @@ -28,7 +28,7 @@ component("ash") { "ash_service.h", # TODO: move the following to source. Do NOT add new files here. - "accessibility/accessibility_controller.h", + "accessibility/accessibility_controller_impl.h", "accessibility/accessibility_delegate.h", "accessibility/focus_ring_controller.h", "app_list/app_list_controller_impl.h", @@ -124,7 +124,7 @@ component("ash") { "accelerometer/accelerometer_reader.h", "accelerometer/accelerometer_types.cc", "accelerometer/accelerometer_types.h", - "accessibility/accessibility_controller.cc", + "accessibility/accessibility_controller_impl.cc", "accessibility/accessibility_cursor_ring_layer.cc", "accessibility/accessibility_cursor_ring_layer.h", "accessibility/accessibility_focus_ring.cc", @@ -1381,6 +1381,7 @@ component("ash") { "//third_party/qcms", "//third_party/re2", "//ui/accessibility", + "//ui/accessibility:ax_enums_mojo", "//ui/base", "//ui/base:ui_data_pack", "//ui/base/ime/chromeos", diff --git a/ash/accelerators/accelerator_controller_impl.cc b/ash/accelerators/accelerator_controller_impl.cc index 64182cf54985ef..4b5a2f5f077a74 100644 --- a/ash/accelerators/accelerator_controller_impl.cc +++ b/ash/accelerators/accelerator_controller_impl.cc @@ -12,7 +12,7 @@ #include "ash/accelerators/accelerator_commands.h" #include "ash/accelerators/accelerator_confirmation_dialog.h" #include "ash/accelerators/debug_commands.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/app_list/app_list_controller_impl.h" #include "ash/assistant/assistant_controller.h" #include "ash/assistant/assistant_ui_controller.h" @@ -38,7 +38,6 @@ #include "ash/public/cpp/notification_utils.h" #include "ash/public/cpp/toast_data.h" #include "ash/public/cpp/voice_interaction_controller.h" -#include "ash/public/interfaces/accessibility_controller.mojom.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/root_window_controller.h" #include "ash/rotator/window_rotation.h" @@ -965,7 +964,7 @@ bool CanHandleToggleDictation() { void HandleToggleDictation() { base::RecordAction(UserMetricsAction("Accel_Toggle_Dictation")); Shell::Get()->accessibility_controller()->ToggleDictationFromSource( - mojom::DictationToggleSource::kKeyboard); + DictationToggleSource::kKeyboard); } bool CanHandleToggleOverview() { @@ -1074,7 +1073,7 @@ void SetFullscreenMagnifierEnabled(bool enabled) { } void SetHighContrastEnabled(bool enabled) { - AccessibilityController* accessibility_controller = + AccessibilityControllerImpl* accessibility_controller = Shell::Get()->accessibility_controller(); accessibility_controller->SetHighContrastEnabled(enabled); // Value could differ from one that were set because of higher-priority pref @@ -1095,7 +1094,7 @@ void SetHighContrastEnabled(bool enabled) { void HandleToggleHighContrast() { base::RecordAction(UserMetricsAction("Accel_Toggle_High_Contrast")); - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); const bool current_enabled = controller->high_contrast_enabled(); const bool dialog_ever_accepted = @@ -1142,7 +1141,7 @@ void HandleToggleFullscreenMagnifier() { void HandleToggleSpokenFeedback() { base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); bool old_value = controller->spoken_feedback_enabled(); controller->SetSpokenFeedbackEnabled(!controller->spoken_feedback_enabled(), @@ -2060,7 +2059,7 @@ AcceleratorControllerImpl::GetAcceleratorProcessingRestriction( ->BuildMruWindowList(kActiveDesk) .empty()) { Shell::Get()->accessibility_controller()->TriggerAccessibilityAlert( - mojom::AccessibilityAlert::WINDOW_NEEDED); + AccessibilityAlert::WINDOW_NEEDED); return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; } return RESTRICTION_NONE; diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc index 69d9867da7b9c1..aa418c1c211691 100644 --- a/ash/accelerators/accelerator_controller_unittest.cc +++ b/ash/accelerators/accelerator_controller_unittest.cc @@ -9,7 +9,7 @@ #include "ash/accelerators/accelerator_confirmation_dialog.h" #include "ash/accelerators/accelerator_table.h" #include "ash/accelerators/pre_target_accelerator_handler.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/accessibility/test_accessibility_controller_client.h" #include "ash/app_list/app_list_metrics.h" #include "ash/app_list/test/app_list_test_helper.h" @@ -553,7 +553,7 @@ TEST_F(AcceleratorControllerTest, RotateScreen) { display::Display::Rotation initial_rotation = GetActiveDisplayRotation(display.id()); ui::test::EventGenerator* generator = GetEventGenerator(); - AccessibilityController* accessibility_controller = + AccessibilityControllerImpl* accessibility_controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(accessibility_controller @@ -860,7 +860,7 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { } TEST_F(AcceleratorControllerTest, GlobalAcceleratorsToggleAppList) { - AccessibilityController* accessibility_controller = + AccessibilityControllerImpl* accessibility_controller = Shell::Get()->accessibility_controller(); // The press event should not toggle the AppList, the release should instead. @@ -1625,20 +1625,16 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { } TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { - TestAccessibilityControllerClient client; - AccessibilityController* accessibility_controller = + AccessibilityControllerImpl* accessibility_controller = Shell::Get()->accessibility_controller(); - accessibility_controller->SetClient(client.CreateInterfacePtrAndBind()); + TestAccessibilityControllerClient client; for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { accessibility_controller->TriggerAccessibilityAlert( - mojom::AccessibilityAlert::NONE); - accessibility_controller->FlushMojoForTest(); + AccessibilityAlert::NONE); EXPECT_TRUE( controller_->PerformActionIfEnabled(kActionsNeedingWindow[i], {})); - accessibility_controller->FlushMojoForTest(); - EXPECT_EQ(mojom::AccessibilityAlert::WINDOW_NEEDED, - client.last_a11y_alert()); + EXPECT_EQ(AccessibilityAlert::WINDOW_NEEDED, client.last_a11y_alert()); } // Make sure we don't alert if we do have a window. @@ -1647,12 +1643,9 @@ TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); wm::ActivateWindow(window.get()); accessibility_controller->TriggerAccessibilityAlert( - mojom::AccessibilityAlert::NONE); - accessibility_controller->FlushMojoForTest(); + AccessibilityAlert::NONE); controller_->PerformActionIfEnabled(kActionsNeedingWindow[i], {}); - accessibility_controller->FlushMojoForTest(); - EXPECT_NE(mojom::AccessibilityAlert::WINDOW_NEEDED, - client.last_a11y_alert()); + EXPECT_NE(AccessibilityAlert::WINDOW_NEEDED, client.last_a11y_alert()); } // Don't alert if we have a minimized window either. @@ -1661,19 +1654,16 @@ TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { wm::ActivateWindow(window.get()); controller_->PerformActionIfEnabled(WINDOW_MINIMIZE, {}); accessibility_controller->TriggerAccessibilityAlert( - mojom::AccessibilityAlert::NONE); - accessibility_controller->FlushMojoForTest(); + AccessibilityAlert::NONE); controller_->PerformActionIfEnabled(kActionsNeedingWindow[i], {}); - accessibility_controller->FlushMojoForTest(); - EXPECT_NE(mojom::AccessibilityAlert::WINDOW_NEEDED, - client.last_a11y_alert()); + EXPECT_NE(AccessibilityAlert::WINDOW_NEEDED, client.last_a11y_alert()); } } TEST_F(AcceleratorControllerTest, TestDialogCancel) { ui::Accelerator accelerator(ui::VKEY_H, ui::EF_COMMAND_DOWN | ui::EF_CONTROL_DOWN); - AccessibilityController* accessibility_controller = + AccessibilityControllerImpl* accessibility_controller = Shell::Get()->accessibility_controller(); // Pressing cancel on the dialog should have no effect. EXPECT_FALSE( @@ -1693,7 +1683,7 @@ TEST_F(AcceleratorControllerTest, TestToggleHighContrast) { ui::EF_COMMAND_DOWN | ui::EF_CONTROL_DOWN); // High Contrast Mode Enabled dialog and notification should be shown. EXPECT_FALSE(IsConfirmationDialogOpen()); - AccessibilityController* accessibility_controller = + AccessibilityControllerImpl* accessibility_controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE( accessibility_controller->HasHighContrastAcceleratorDialogBeenAccepted()); @@ -1900,7 +1890,7 @@ TEST_F(MagnifiersAcceleratorsTester, TestToggleFullscreenMagnifier) { EXPECT_FALSE(fullscreen_magnifier_controller()->IsEnabled()); EXPECT_FALSE(IsConfirmationDialogOpen()); - AccessibilityController* accessibility_controller = + AccessibilityControllerImpl* accessibility_controller = Shell::Get()->accessibility_controller(); // Toggle the fullscreen magnifier on/off, dialog should be shown on first use // of accelerator. @@ -1942,7 +1932,7 @@ TEST_F(MagnifiersAcceleratorsTester, TestToggleDockedMagnifier) { EXPECT_FALSE(fullscreen_magnifier_controller()->IsEnabled()); EXPECT_FALSE(IsConfirmationDialogOpen()); - AccessibilityController* accessibility_controller = + AccessibilityControllerImpl* accessibility_controller = Shell::Get()->accessibility_controller(); // Toggle the docked magnifier on/off, dialog should be shown on first use of // accelerator. diff --git a/ash/accelerators/spoken_feedback_toggler.cc b/ash/accelerators/spoken_feedback_toggler.cc index c07a2c6a7e72e1..6f98191fe2b214 100644 --- a/ash/accelerators/spoken_feedback_toggler.cc +++ b/ash/accelerators/spoken_feedback_toggler.cc @@ -7,7 +7,7 @@ #include #include "ash/accelerators/key_hold_detector.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/shell.h" #include "ui/events/event.h" @@ -52,7 +52,7 @@ bool SpokenFeedbackToggler::ShouldStopEventPropagation() const { void SpokenFeedbackToggler::OnKeyHold(const ui::KeyEvent* event) { if (!toggled_) { toggled_ = true; - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); controller->SetSpokenFeedbackEnabled(!controller->spoken_feedback_enabled(), A11Y_NOTIFICATION_SHOW); diff --git a/ash/accelerators/spoken_feedback_toggler_unittest.cc b/ash/accelerators/spoken_feedback_toggler_unittest.cc index b0ecff9fdf1e95..ad28bf06533faa 100644 --- a/ash/accelerators/spoken_feedback_toggler_unittest.cc +++ b/ash/accelerators/spoken_feedback_toggler_unittest.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "ash/accelerators/spoken_feedback_toggler.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/wm/window_util.h" @@ -17,7 +17,7 @@ using SpokenFeedbackTogglerTest = AshTestBase; TEST_F(SpokenFeedbackTogglerTest, Basic) { SpokenFeedbackToggler::ScopedEnablerForTest scoped; - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); ui::test::EventGenerator* generator = GetEventGenerator(); EXPECT_FALSE(controller->spoken_feedback_enabled()); diff --git a/ash/accessibility/accessibility_controller.cc b/ash/accessibility/accessibility_controller_impl.cc similarity index 76% rename from ash/accessibility/accessibility_controller.cc rename to ash/accessibility/accessibility_controller_impl.cc index 2cdf6b2a9a0815..a8e4ac88b11ecf 100644 --- a/ash/accessibility/accessibility_controller.cc +++ b/ash/accessibility/accessibility_controller_impl.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include #include @@ -19,6 +19,7 @@ #include "ash/keyboard/ash_keyboard_controller.h" #include "ash/keyboard/ui/keyboard_util.h" #include "ash/policy/policy_recommendation_restorer.h" +#include "ash/public/cpp/accessibility_controller_client.h" #include "ash/public/cpp/ash_constants.h" #include "ash/public/cpp/ash_pref_names.h" #include "ash/public/cpp/notification_utils.h" @@ -238,15 +239,15 @@ AccessibilityPanelLayoutManager* GetLayoutManager() { container->layout_manager()); } -std::string PrefKeyForSwitchAccessCommand(mojom::SwitchAccessCommand command) { +std::string PrefKeyForSwitchAccessCommand(SwitchAccessCommand command) { switch (command) { - case mojom::SwitchAccessCommand::kSelect: + case SwitchAccessCommand::kSelect: return prefs::kAccessibilitySwitchAccessSelectKeyCodes; - case mojom::SwitchAccessCommand::kNext: + case SwitchAccessCommand::kNext: return prefs::kAccessibilitySwitchAccessNextKeyCodes; - case mojom::SwitchAccessCommand::kPrevious: + case SwitchAccessCommand::kPrevious: return prefs::kAccessibilitySwitchAccessPreviousKeyCodes; - case mojom::SwitchAccessCommand::kNone: + case SwitchAccessCommand::kNone: NOTREACHED(); return ""; } @@ -254,21 +255,22 @@ std::string PrefKeyForSwitchAccessCommand(mojom::SwitchAccessCommand command) { } // namespace -AccessibilityController::AccessibilityController() +AccessibilityControllerImpl::AccessibilityControllerImpl() : autoclick_delay_(AutoclickController::GetDefaultAutoclickDelay()) { Shell::Get()->session_controller()->AddObserver(this); Shell::Get()->tablet_mode_controller()->AddObserver(this); } -AccessibilityController::~AccessibilityController() { +AccessibilityControllerImpl::~AccessibilityControllerImpl() { if (Shell::Get()->tablet_mode_controller()) Shell::Get()->tablet_mode_controller()->RemoveObserver(this); Shell::Get()->session_controller()->RemoveObserver(this); } // static -void AccessibilityController::RegisterProfilePrefs(PrefRegistrySimple* registry, - bool for_test) { +void AccessibilityControllerImpl::RegisterProfilePrefs( + PrefRegistrySimple* registry, + bool for_test) { if (for_test) { // In tests there is no remote pref service. Make ash own the prefs. registry->RegisterBooleanPref(prefs::kAccessibilityAutoclickEnabled, false); @@ -353,7 +355,7 @@ void AccessibilityController::RegisterProfilePrefs(PrefRegistrySimple* registry, // TODO(jamescook): Move ownership to ash. } -void AccessibilityController::SetHighContrastAcceleratorDialogAccepted() { +void AccessibilityControllerImpl::SetHighContrastAcceleratorDialogAccepted() { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean( @@ -361,14 +363,15 @@ void AccessibilityController::SetHighContrastAcceleratorDialogAccepted() { active_user_prefs_->CommitPendingWrite(); } -bool AccessibilityController::HasHighContrastAcceleratorDialogBeenAccepted() +bool AccessibilityControllerImpl::HasHighContrastAcceleratorDialogBeenAccepted() const { return active_user_prefs_ && active_user_prefs_->GetBoolean( prefs::kHighContrastAcceleratorDialogHasBeenAccepted); } -void AccessibilityController::SetScreenMagnifierAcceleratorDialogAccepted() { +void AccessibilityControllerImpl:: + SetScreenMagnifierAcceleratorDialogAccepted() { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean( @@ -376,14 +379,15 @@ void AccessibilityController::SetScreenMagnifierAcceleratorDialogAccepted() { active_user_prefs_->CommitPendingWrite(); } -bool AccessibilityController::HasScreenMagnifierAcceleratorDialogBeenAccepted() - const { +bool AccessibilityControllerImpl:: + HasScreenMagnifierAcceleratorDialogBeenAccepted() const { return active_user_prefs_ && active_user_prefs_->GetBoolean( prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted); } -void AccessibilityController::SetDockedMagnifierAcceleratorDialogAccepted() { +void AccessibilityControllerImpl:: + SetDockedMagnifierAcceleratorDialogAccepted() { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean( @@ -391,14 +395,14 @@ void AccessibilityController::SetDockedMagnifierAcceleratorDialogAccepted() { active_user_prefs_->CommitPendingWrite(); } -bool AccessibilityController::HasDisplayRotationAcceleratorDialogBeenAccepted() - const { +bool AccessibilityControllerImpl:: + HasDisplayRotationAcceleratorDialogBeenAccepted() const { return active_user_prefs_ && active_user_prefs_->GetBoolean( prefs::kDisplayRotationAcceleratorDialogHasBeenAccepted); } -void AccessibilityController:: +void AccessibilityControllerImpl:: SetDisplayRotationAcceleratorDialogBeenAccepted() { if (!active_user_prefs_) return; @@ -407,14 +411,14 @@ void AccessibilityController:: active_user_prefs_->CommitPendingWrite(); } -bool AccessibilityController::HasDockedMagnifierAcceleratorDialogBeenAccepted() - const { +bool AccessibilityControllerImpl:: + HasDockedMagnifierAcceleratorDialogBeenAccepted() const { return active_user_prefs_ && active_user_prefs_->GetBoolean( prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted); } -void AccessibilityController::SetDictationAcceleratorDialogAccepted() { +void AccessibilityControllerImpl::SetDictationAcceleratorDialogAccepted() { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean( @@ -422,27 +426,23 @@ void AccessibilityController::SetDictationAcceleratorDialogAccepted() { active_user_prefs_->CommitPendingWrite(); } -bool AccessibilityController::HasDictationAcceleratorDialogBeenAccepted() +bool AccessibilityControllerImpl::HasDictationAcceleratorDialogBeenAccepted() const { return active_user_prefs_ && active_user_prefs_->GetBoolean( prefs::kDictationAcceleratorDialogHasBeenAccepted); } -void AccessibilityController::AddObserver(AccessibilityObserver* observer) { +void AccessibilityControllerImpl::AddObserver(AccessibilityObserver* observer) { observers_.AddObserver(observer); } -void AccessibilityController::RemoveObserver(AccessibilityObserver* observer) { +void AccessibilityControllerImpl::RemoveObserver( + AccessibilityObserver* observer) { observers_.RemoveObserver(observer); } -void AccessibilityController::BindRequest( - mojom::AccessibilityControllerRequest request) { - bindings_.AddBinding(this, std::move(request)); -} - -void AccessibilityController::SetAutoclickEnabled(bool enabled) { +void AccessibilityControllerImpl::SetAutoclickEnabled(bool enabled) { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean(prefs::kAccessibilityAutoclickEnabled, @@ -450,7 +450,7 @@ void AccessibilityController::SetAutoclickEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::SetCaretHighlightEnabled(bool enabled) { +void AccessibilityControllerImpl::SetCaretHighlightEnabled(bool enabled) { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean(prefs::kAccessibilityCaretHighlightEnabled, @@ -458,7 +458,7 @@ void AccessibilityController::SetCaretHighlightEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::SetCursorHighlightEnabled(bool enabled) { +void AccessibilityControllerImpl::SetCursorHighlightEnabled(bool enabled) { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean(prefs::kAccessibilityCursorHighlightEnabled, @@ -466,7 +466,7 @@ void AccessibilityController::SetCursorHighlightEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::SetDictationEnabled(bool enabled) { +void AccessibilityControllerImpl::SetDictationEnabled(bool enabled) { if (!active_user_prefs_) return; @@ -478,7 +478,7 @@ void AccessibilityController::SetDictationEnabled(bool enabled) { IDS_ASH_DICTATION_CONFIRMATION_BODY, // Callback for if the user accepts the dialog base::BindOnce([]() { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); controller->SetDictationAcceleratorDialogAccepted(); // If they accept, try again to set dictation_enabled to true @@ -491,7 +491,7 @@ void AccessibilityController::SetDictationEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::SetFocusHighlightEnabled(bool enabled) { +void AccessibilityControllerImpl::SetFocusHighlightEnabled(bool enabled) { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean(prefs::kAccessibilityFocusHighlightEnabled, @@ -499,7 +499,7 @@ void AccessibilityController::SetFocusHighlightEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::SetFullscreenMagnifierEnabled(bool enabled) { +void AccessibilityControllerImpl::SetFullscreenMagnifierEnabled(bool enabled) { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled, @@ -507,7 +507,7 @@ void AccessibilityController::SetFullscreenMagnifierEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::SetHighContrastEnabled(bool enabled) { +void AccessibilityControllerImpl::SetHighContrastEnabled(bool enabled) { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean(prefs::kAccessibilityHighContrastEnabled, @@ -515,7 +515,7 @@ void AccessibilityController::SetHighContrastEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::SetLargeCursorEnabled(bool enabled) { +void AccessibilityControllerImpl::SetLargeCursorEnabled(bool enabled) { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean(prefs::kAccessibilityLargeCursorEnabled, @@ -523,7 +523,7 @@ void AccessibilityController::SetLargeCursorEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::SetMonoAudioEnabled(bool enabled) { +void AccessibilityControllerImpl::SetMonoAudioEnabled(bool enabled) { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean(prefs::kAccessibilityMonoAudioEnabled, @@ -531,7 +531,7 @@ void AccessibilityController::SetMonoAudioEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::SetSpokenFeedbackEnabled( +void AccessibilityControllerImpl::SetSpokenFeedbackEnabled( bool enabled, AccessibilityNotificationVisibility notify) { if (!active_user_prefs_) @@ -551,7 +551,7 @@ void AccessibilityController::SetSpokenFeedbackEnabled( ShowAccessibilityNotification(type); } -void AccessibilityController::SetSelectToSpeakEnabled(bool enabled) { +void AccessibilityControllerImpl::SetSelectToSpeakEnabled(bool enabled) { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean(prefs::kAccessibilitySelectToSpeakEnabled, @@ -559,12 +559,12 @@ void AccessibilityController::SetSelectToSpeakEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::RequestSelectToSpeakStateChange() { +void AccessibilityControllerImpl::RequestSelectToSpeakStateChange() { client_->RequestSelectToSpeakStateChange(); } -void AccessibilityController::SetSelectToSpeakState( - mojom::SelectToSpeakState state) { +void AccessibilityControllerImpl::SetSelectToSpeakState( + SelectToSpeakState state) { select_to_speak_state_ = state; // Forward the state change event to select_to_speak_event_handler_. @@ -572,23 +572,22 @@ void AccessibilityController::SetSelectToSpeakState( // Prepare to start capturing events from stylus, mouse or touch. if (select_to_speak_event_handler_) { select_to_speak_event_handler_->SetSelectToSpeakStateSelecting( - state == mojom::SelectToSpeakState::kSelectToSpeakStateSelecting); + state == SelectToSpeakState::kSelectToSpeakStateSelecting); } NotifyAccessibilityStatusChanged(); } -void AccessibilityController::SetSelectToSpeakEventHandlerDelegate( - mojom::SelectToSpeakEventHandlerDelegatePtr delegate) { - select_to_speak_event_handler_delegate_ptr_ = std::move(delegate); +void AccessibilityControllerImpl::SetSelectToSpeakEventHandlerDelegate( + SelectToSpeakEventHandlerDelegate* delegate) { + select_to_speak_event_handler_delegate_ = delegate; MaybeCreateSelectToSpeakEventHandler(); } -mojom::SelectToSpeakState AccessibilityController::GetSelectToSpeakState() - const { +SelectToSpeakState AccessibilityControllerImpl::GetSelectToSpeakState() const { return select_to_speak_state_; } -void AccessibilityController::SetSwitchAccessEnabled(bool enabled) { +void AccessibilityControllerImpl::SetSwitchAccessEnabled(bool enabled) { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean(prefs::kAccessibilitySwitchAccessEnabled, @@ -596,7 +595,7 @@ void AccessibilityController::SetSwitchAccessEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::SetSwitchAccessKeysToCapture( +void AccessibilityControllerImpl::SetSwitchAccessKeysToCapture( const std::vector& keys_to_capture) { // Forward the keys to capture to switch_access_event_handler_. if (switch_access_event_handler_) @@ -604,23 +603,23 @@ void AccessibilityController::SetSwitchAccessKeysToCapture( NotifyAccessibilityStatusChanged(); } -void AccessibilityController::SetSwitchAccessIgnoreVirtualKeyEvent( +void AccessibilityControllerImpl::SetSwitchAccessIgnoreVirtualKeyEvent( bool should_ignore) { switch_access_event_handler_->set_ignore_virtual_key_events(should_ignore); } -void AccessibilityController::ForwardKeyEventsToSwitchAccess( +void AccessibilityControllerImpl::ForwardKeyEventsToSwitchAccess( bool should_forward) { switch_access_event_handler_->set_forward_key_events(should_forward); } -void AccessibilityController::SetSwitchAccessEventHandlerDelegate( - mojom::SwitchAccessEventHandlerDelegatePtr delegate) { - switch_access_event_handler_delegate_ptr_ = std::move(delegate); +void AccessibilityControllerImpl::SetSwitchAccessEventHandlerDelegate( + SwitchAccessEventHandlerDelegate* delegate) { + switch_access_event_handler_delegate_ = delegate; MaybeCreateSwitchAccessEventHandler(); } -void AccessibilityController::SetStickyKeysEnabled(bool enabled) { +void AccessibilityControllerImpl::SetStickyKeysEnabled(bool enabled) { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean(prefs::kAccessibilityStickyKeysEnabled, @@ -628,7 +627,7 @@ void AccessibilityController::SetStickyKeysEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::SetVirtualKeyboardEnabled(bool enabled) { +void AccessibilityControllerImpl::SetVirtualKeyboardEnabled(bool enabled) { if (!active_user_prefs_) return; active_user_prefs_->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, @@ -636,97 +635,85 @@ void AccessibilityController::SetVirtualKeyboardEnabled(bool enabled) { active_user_prefs_->CommitPendingWrite(); } -void AccessibilityController::SetDictationActive(bool is_active) { - dictation_active_ = is_active; -} - -void AccessibilityController::TriggerAccessibilityAlert( - mojom::AccessibilityAlert alert) { +void AccessibilityControllerImpl::TriggerAccessibilityAlert( + AccessibilityAlert alert) { if (client_) client_->TriggerAccessibilityAlert(alert); } -void AccessibilityController::PlayEarcon(int32_t sound_key) { +void AccessibilityControllerImpl::PlayEarcon(int32_t sound_key) { if (client_) client_->PlayEarcon(sound_key); } -void AccessibilityController::PlayShutdownSound( - base::OnceCallback callback) { - if (client_) - client_->PlayShutdownSound(std::move(callback)); +base::TimeDelta AccessibilityControllerImpl::PlayShutdownSound() { + return client_ ? client_->PlayShutdownSound() : base::TimeDelta(); } -void AccessibilityController::HandleAccessibilityGesture( +void AccessibilityControllerImpl::HandleAccessibilityGesture( ax::mojom::Gesture gesture) { if (client_) client_->HandleAccessibilityGesture(gesture); } -void AccessibilityController::ToggleDictation() { +void AccessibilityControllerImpl::ToggleDictation() { // Do nothing if dictation is not enabled. if (!dictation_enabled()) return; if (client_) { - client_->ToggleDictation(base::BindOnce( - [](AccessibilityController* self, bool is_active) { - self->SetDictationActive(is_active); - if (is_active) - Shell::Get()->OnDictationStarted(); - else - Shell::Get()->OnDictationEnded(); - }, - base::Unretained(this))); + const bool is_active = client_->ToggleDictation(); + SetDictationActive(is_active); + if (is_active) + Shell::Get()->OnDictationStarted(); + else + Shell::Get()->OnDictationEnded(); } } -void AccessibilityController::ToggleDictationFromSource( - mojom::DictationToggleSource source) { +void AccessibilityControllerImpl::SetDictationActive(bool is_active) { + dictation_active_ = is_active; +} + +void AccessibilityControllerImpl::ToggleDictationFromSource( + DictationToggleSource source) { base::RecordAction(base::UserMetricsAction("Accel_Toggle_Dictation")); UserMetricsRecorder::RecordUserToggleDictation(source); ToggleDictation(); } -void AccessibilityController::SilenceSpokenFeedback() { +void AccessibilityControllerImpl::SilenceSpokenFeedback() { if (client_) client_->SilenceSpokenFeedback(); } -void AccessibilityController::OnTwoFingerTouchStart() { +void AccessibilityControllerImpl::OnTwoFingerTouchStart() { if (client_) client_->OnTwoFingerTouchStart(); } -void AccessibilityController::OnTwoFingerTouchStop() { +void AccessibilityControllerImpl::OnTwoFingerTouchStop() { if (client_) client_->OnTwoFingerTouchStop(); } -void AccessibilityController::ShouldToggleSpokenFeedbackViaTouch( - base::OnceCallback callback) { - if (client_) - client_->ShouldToggleSpokenFeedbackViaTouch(std::move(callback)); +bool AccessibilityControllerImpl::ShouldToggleSpokenFeedbackViaTouch() const { + return client_ && client_->ShouldToggleSpokenFeedbackViaTouch(); } -void AccessibilityController::PlaySpokenFeedbackToggleCountdown( +void AccessibilityControllerImpl::PlaySpokenFeedbackToggleCountdown( int tick_count) { if (client_) client_->PlaySpokenFeedbackToggleCountdown(tick_count); } -void AccessibilityController::NotifyAccessibilityStatusChanged() { - for (auto& observer : observers_) - observer.OnAccessibilityStatusChanged(); -} - -void AccessibilityController::SetClient( - mojom::AccessibilityControllerClientPtr client) { - client_ = std::move(client); +void AccessibilityControllerImpl::SetClient( + AccessibilityControllerClient* client) { + client_ = client; } -void AccessibilityController::SetDarkenScreen(bool darken) { +void AccessibilityControllerImpl::SetDarkenScreen(bool darken) { if (darken && !scoped_backlights_forced_off_) { scoped_backlights_forced_off_ = Shell::Get()->backlights_forced_off_setter()->ForceBacklightsOff(); @@ -735,7 +722,7 @@ void AccessibilityController::SetDarkenScreen(bool darken) { } } -void AccessibilityController::BrailleDisplayStateChanged(bool connected) { +void AccessibilityControllerImpl::BrailleDisplayStateChanged(bool connected) { A11yNotificationType type = A11yNotificationType::kNone; if (connected && spoken_feedback_enabled_) type = A11yNotificationType::kBrailleDisplayConnected; @@ -749,32 +736,32 @@ void AccessibilityController::BrailleDisplayStateChanged(bool connected) { ShowAccessibilityNotification(type); } -void AccessibilityController::SetFocusHighlightRect( +void AccessibilityControllerImpl::SetFocusHighlightRect( const gfx::Rect& bounds_in_screen) { if (!accessibility_highlight_controller_) return; accessibility_highlight_controller_->SetFocusHighlightRect(bounds_in_screen); } -void AccessibilityController::SetCaretBounds( +void AccessibilityControllerImpl::SetCaretBounds( const gfx::Rect& bounds_in_screen) { if (!accessibility_highlight_controller_) return; accessibility_highlight_controller_->SetCaretBounds(bounds_in_screen); } -void AccessibilityController::SetAccessibilityPanelAlwaysVisible( +void AccessibilityControllerImpl::SetAccessibilityPanelAlwaysVisible( bool always_visible) { GetLayoutManager()->SetAlwaysVisible(always_visible); } -void AccessibilityController::SetAccessibilityPanelBounds( +void AccessibilityControllerImpl::SetAccessibilityPanelBounds( const gfx::Rect& bounds, - mojom::AccessibilityPanelState state) { + AccessibilityPanelState state) { GetLayoutManager()->SetPanelBounds(bounds, state); } -void AccessibilityController::OnSigninScreenPrefServiceInitialized( +void AccessibilityControllerImpl::OnSigninScreenPrefServiceInitialized( PrefService* prefs) { // Make |kA11yPrefsForRecommendedValueOnSignin| observing recommended values // on signin screen. See PolicyRecommendationRestorer. @@ -787,7 +774,7 @@ void AccessibilityController::OnSigninScreenPrefServiceInitialized( ObservePrefs(prefs); } -void AccessibilityController::OnActiveUserPrefServiceChanged( +void AccessibilityControllerImpl::OnActiveUserPrefServiceChanged( PrefService* prefs) { // This is guaranteed to be received after // OnSigninScreenPrefServiceInitialized() so only copy the signin prefs if @@ -796,33 +783,24 @@ void AccessibilityController::OnActiveUserPrefServiceChanged( ObservePrefs(prefs); } -void AccessibilityController::FlushMojoForTest() { - if (client_) - client_.FlushForTesting(); - if (select_to_speak_event_handler_) - select_to_speak_event_handler_->FlushMojoForTest(); - if (switch_access_event_handler_) - switch_access_event_handler_->FlushMojoForTest(); -} - SwitchAccessEventHandler* -AccessibilityController::GetSwitchAccessEventHandlerForTest() { +AccessibilityControllerImpl::GetSwitchAccessEventHandlerForTest() { if (switch_access_event_handler_) return switch_access_event_handler_.get(); return nullptr; } -void AccessibilityController::OnTabletModeStarted() { +void AccessibilityControllerImpl::OnTabletModeStarted() { if (spoken_feedback_enabled()) ShowAccessibilityNotification(A11yNotificationType::kSpokenFeedbackEnabled); } -void AccessibilityController::OnTabletModeEnded() { +void AccessibilityControllerImpl::OnTabletModeEnded() { if (spoken_feedback_enabled()) ShowAccessibilityNotification(A11yNotificationType::kSpokenFeedbackEnabled); } -void AccessibilityController::ObservePrefs(PrefService* prefs) { +void AccessibilityControllerImpl::ObservePrefs(PrefService* prefs) { DCHECK(prefs); active_user_prefs_ = prefs; @@ -832,109 +810,115 @@ void AccessibilityController::ObservePrefs(PrefService* prefs) { pref_change_registrar_->Init(prefs); pref_change_registrar_->Add( prefs::kAccessibilityAutoclickEnabled, - base::BindRepeating(&AccessibilityController::UpdateAutoclickFromPref, + base::BindRepeating(&AccessibilityControllerImpl::UpdateAutoclickFromPref, base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityAutoclickDelayMs, base::BindRepeating( - &AccessibilityController::UpdateAutoclickDelayFromPref, + &AccessibilityControllerImpl::UpdateAutoclickDelayFromPref, base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityAutoclickEventType, base::BindRepeating( - &AccessibilityController::UpdateAutoclickEventTypeFromPref, + &AccessibilityControllerImpl::UpdateAutoclickEventTypeFromPref, base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityAutoclickRevertToLeftClick, - base::BindRepeating( - &AccessibilityController::UpdateAutoclickRevertToLeftClickFromPref, - base::Unretained(this))); + base::BindRepeating(&AccessibilityControllerImpl:: + UpdateAutoclickRevertToLeftClickFromPref, + base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityAutoclickStabilizePosition, - base::BindRepeating( - &AccessibilityController::UpdateAutoclickStabilizePositionFromPref, - base::Unretained(this))); + base::BindRepeating(&AccessibilityControllerImpl:: + UpdateAutoclickStabilizePositionFromPref, + base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityAutoclickMovementThreshold, - base::BindRepeating( - &AccessibilityController::UpdateAutoclickMovementThresholdFromPref, - base::Unretained(this))); + base::BindRepeating(&AccessibilityControllerImpl:: + UpdateAutoclickMovementThresholdFromPref, + base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityAutoclickMenuPosition, base::BindRepeating( - &AccessibilityController::UpdateAutoclickMenuPositionFromPref, + &AccessibilityControllerImpl::UpdateAutoclickMenuPositionFromPref, base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityCaretHighlightEnabled, base::BindRepeating( - &AccessibilityController::UpdateCaretHighlightFromPref, + &AccessibilityControllerImpl::UpdateCaretHighlightFromPref, base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityCursorHighlightEnabled, base::BindRepeating( - &AccessibilityController::UpdateCursorHighlightFromPref, + &AccessibilityControllerImpl::UpdateCursorHighlightFromPref, base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityDictationEnabled, - base::BindRepeating(&AccessibilityController::UpdateDictationFromPref, + base::BindRepeating(&AccessibilityControllerImpl::UpdateDictationFromPref, base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityFocusHighlightEnabled, base::BindRepeating( - &AccessibilityController::UpdateFocusHighlightFromPref, + &AccessibilityControllerImpl::UpdateFocusHighlightFromPref, base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityHighContrastEnabled, - base::BindRepeating(&AccessibilityController::UpdateHighContrastFromPref, - base::Unretained(this))); + base::BindRepeating( + &AccessibilityControllerImpl::UpdateHighContrastFromPref, + base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityLargeCursorEnabled, - base::BindRepeating(&AccessibilityController::UpdateLargeCursorFromPref, - base::Unretained(this))); + base::BindRepeating( + &AccessibilityControllerImpl::UpdateLargeCursorFromPref, + base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityLargeCursorDipSize, - base::BindRepeating(&AccessibilityController::UpdateLargeCursorFromPref, - base::Unretained(this))); + base::BindRepeating( + &AccessibilityControllerImpl::UpdateLargeCursorFromPref, + base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityMonoAudioEnabled, - base::BindRepeating(&AccessibilityController::UpdateMonoAudioFromPref, + base::BindRepeating(&AccessibilityControllerImpl::UpdateMonoAudioFromPref, base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilitySpokenFeedbackEnabled, base::BindRepeating( - &AccessibilityController::UpdateSpokenFeedbackFromPref, + &AccessibilityControllerImpl::UpdateSpokenFeedbackFromPref, base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilitySelectToSpeakEnabled, - base::BindRepeating(&AccessibilityController::UpdateSelectToSpeakFromPref, - base::Unretained(this))); + base::BindRepeating( + &AccessibilityControllerImpl::UpdateSelectToSpeakFromPref, + base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilityStickyKeysEnabled, - base::BindRepeating(&AccessibilityController::UpdateStickyKeysFromPref, - base::Unretained(this))); + base::BindRepeating( + &AccessibilityControllerImpl::UpdateStickyKeysFromPref, + base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilitySwitchAccessEnabled, - base::BindRepeating(&AccessibilityController::UpdateSwitchAccessFromPref, - base::Unretained(this))); + base::BindRepeating( + &AccessibilityControllerImpl::UpdateSwitchAccessFromPref, + base::Unretained(this))); pref_change_registrar_->Add( prefs::kAccessibilitySwitchAccessSelectKeyCodes, base::BindRepeating( - &AccessibilityController::UpdateSwitchAccessKeyCodesFromPref, - base::Unretained(this), mojom::SwitchAccessCommand::kSelect)); + &AccessibilityControllerImpl::UpdateSwitchAccessKeyCodesFromPref, + base::Unretained(this), SwitchAccessCommand::kSelect)); pref_change_registrar_->Add( prefs::kAccessibilitySwitchAccessNextKeyCodes, base::BindRepeating( - &AccessibilityController::UpdateSwitchAccessKeyCodesFromPref, - base::Unretained(this), mojom::SwitchAccessCommand::kNext)); + &AccessibilityControllerImpl::UpdateSwitchAccessKeyCodesFromPref, + base::Unretained(this), SwitchAccessCommand::kNext)); pref_change_registrar_->Add( prefs::kAccessibilitySwitchAccessPreviousKeyCodes, base::BindRepeating( - &AccessibilityController::UpdateSwitchAccessKeyCodesFromPref, - base::Unretained(this), mojom::SwitchAccessCommand::kPrevious)); + &AccessibilityControllerImpl::UpdateSwitchAccessKeyCodesFromPref, + base::Unretained(this), SwitchAccessCommand::kPrevious)); pref_change_registrar_->Add( prefs::kAccessibilityVirtualKeyboardEnabled, base::BindRepeating( - &AccessibilityController::UpdateVirtualKeyboardFromPref, + &AccessibilityControllerImpl::UpdateVirtualKeyboardFromPref, base::Unretained(this))); // Load current state. @@ -959,7 +943,7 @@ void AccessibilityController::ObservePrefs(PrefService* prefs) { UpdateVirtualKeyboardFromPref(); } -void AccessibilityController::UpdateAutoclickFromPref() { +void AccessibilityControllerImpl::UpdateAutoclickFromPref() { DCHECK(active_user_prefs_); const bool enabled = active_user_prefs_->GetBoolean(prefs::kAccessibilityAutoclickEnabled); @@ -975,7 +959,7 @@ void AccessibilityController::UpdateAutoclickFromPref() { enabled, true /* show confirmation dialog */); } -void AccessibilityController::UpdateAutoclickDelayFromPref() { +void AccessibilityControllerImpl::UpdateAutoclickDelayFromPref() { DCHECK(active_user_prefs_); base::TimeDelta autoclick_delay = base::TimeDelta::FromMilliseconds(int64_t{ active_user_prefs_->GetInteger(prefs::kAccessibilityAutoclickDelayMs)}); @@ -987,13 +971,13 @@ void AccessibilityController::UpdateAutoclickDelayFromPref() { Shell::Get()->autoclick_controller()->SetAutoclickDelay(autoclick_delay_); } -void AccessibilityController::UpdateAutoclickEventTypeFromPref() { +void AccessibilityControllerImpl::UpdateAutoclickEventTypeFromPref() { Shell::Get()->autoclick_controller()->SetAutoclickEventType( GetAutoclickEventType()); } -void AccessibilityController::SetAutoclickEventType( - mojom::AutoclickEventType event_type) { +void AccessibilityControllerImpl::SetAutoclickEventType( + AutoclickEventType event_type) { if (!active_user_prefs_) return; active_user_prefs_->SetInteger(prefs::kAccessibilityAutoclickEventType, @@ -1002,13 +986,13 @@ void AccessibilityController::SetAutoclickEventType( Shell::Get()->autoclick_controller()->SetAutoclickEventType(event_type); } -mojom::AutoclickEventType AccessibilityController::GetAutoclickEventType() { +AutoclickEventType AccessibilityControllerImpl::GetAutoclickEventType() { DCHECK(active_user_prefs_); - return static_cast( + return static_cast( active_user_prefs_->GetInteger(prefs::kAccessibilityAutoclickEventType)); } -void AccessibilityController::UpdateAutoclickRevertToLeftClickFromPref() { +void AccessibilityControllerImpl::UpdateAutoclickRevertToLeftClickFromPref() { DCHECK(active_user_prefs_); bool revert_to_left_click = active_user_prefs_->GetBoolean( prefs::kAccessibilityAutoclickRevertToLeftClick); @@ -1017,7 +1001,7 @@ void AccessibilityController::UpdateAutoclickRevertToLeftClickFromPref() { revert_to_left_click); } -void AccessibilityController::UpdateAutoclickStabilizePositionFromPref() { +void AccessibilityControllerImpl::UpdateAutoclickStabilizePositionFromPref() { DCHECK(active_user_prefs_); bool stabilize_position = active_user_prefs_->GetBoolean( prefs::kAccessibilityAutoclickStabilizePosition); @@ -1026,7 +1010,7 @@ void AccessibilityController::UpdateAutoclickStabilizePositionFromPref() { stabilize_position); } -void AccessibilityController::UpdateAutoclickMovementThresholdFromPref() { +void AccessibilityControllerImpl::UpdateAutoclickMovementThresholdFromPref() { DCHECK(active_user_prefs_); int movement_threshold = active_user_prefs_->GetInteger( prefs::kAccessibilityAutoclickMovementThreshold); @@ -1035,13 +1019,13 @@ void AccessibilityController::UpdateAutoclickMovementThresholdFromPref() { movement_threshold); } -void AccessibilityController::UpdateAutoclickMenuPositionFromPref() { +void AccessibilityControllerImpl::UpdateAutoclickMenuPositionFromPref() { Shell::Get()->autoclick_controller()->SetMenuPosition( GetAutoclickMenuPosition()); } -void AccessibilityController::SetAutoclickMenuPosition( - mojom::AutoclickMenuPosition position) { +void AccessibilityControllerImpl::SetAutoclickMenuPosition( + AutoclickMenuPosition position) { if (!active_user_prefs_) return; active_user_prefs_->SetInteger(prefs::kAccessibilityAutoclickMenuPosition, @@ -1050,19 +1034,17 @@ void AccessibilityController::SetAutoclickMenuPosition( Shell::Get()->autoclick_controller()->SetMenuPosition(position); } -mojom::AutoclickMenuPosition -AccessibilityController::GetAutoclickMenuPosition() { +AutoclickMenuPosition AccessibilityControllerImpl::GetAutoclickMenuPosition() { DCHECK(active_user_prefs_); - return static_cast( - active_user_prefs_->GetInteger( - prefs::kAccessibilityAutoclickMenuPosition)); + return static_cast(active_user_prefs_->GetInteger( + prefs::kAccessibilityAutoclickMenuPosition)); } -void AccessibilityController::UpdateAutoclickMenuBoundsIfNeeded() { +void AccessibilityControllerImpl::UpdateAutoclickMenuBoundsIfNeeded() { Shell::Get()->autoclick_controller()->UpdateAutoclickMenuBoundsIfNeeded(); } -void AccessibilityController::UpdateCaretHighlightFromPref() { +void AccessibilityControllerImpl::UpdateCaretHighlightFromPref() { DCHECK(active_user_prefs_); const bool enabled = active_user_prefs_->GetBoolean( prefs::kAccessibilityCaretHighlightEnabled); @@ -1076,7 +1058,7 @@ void AccessibilityController::UpdateCaretHighlightFromPref() { UpdateAccessibilityHighlightingFromPrefs(); } -void AccessibilityController::UpdateCursorHighlightFromPref() { +void AccessibilityControllerImpl::UpdateCursorHighlightFromPref() { DCHECK(active_user_prefs_); const bool enabled = active_user_prefs_->GetBoolean( prefs::kAccessibilityCursorHighlightEnabled); @@ -1090,7 +1072,7 @@ void AccessibilityController::UpdateCursorHighlightFromPref() { UpdateAccessibilityHighlightingFromPrefs(); } -void AccessibilityController::UpdateDictationFromPref() { +void AccessibilityControllerImpl::UpdateDictationFromPref() { DCHECK(active_user_prefs_); const bool enabled = active_user_prefs_->GetBoolean(prefs::kAccessibilityDictationEnabled); @@ -1103,7 +1085,7 @@ void AccessibilityController::UpdateDictationFromPref() { NotifyAccessibilityStatusChanged(); } -void AccessibilityController::UpdateFocusHighlightFromPref() { +void AccessibilityControllerImpl::UpdateFocusHighlightFromPref() { DCHECK(active_user_prefs_); bool enabled = active_user_prefs_->GetBoolean( prefs::kAccessibilityFocusHighlightEnabled); @@ -1122,7 +1104,7 @@ void AccessibilityController::UpdateFocusHighlightFromPref() { UpdateAccessibilityHighlightingFromPrefs(); } -void AccessibilityController::UpdateHighContrastFromPref() { +void AccessibilityControllerImpl::UpdateHighContrastFromPref() { DCHECK(active_user_prefs_); const bool enabled = active_user_prefs_->GetBoolean(prefs::kAccessibilityHighContrastEnabled); @@ -1138,7 +1120,7 @@ void AccessibilityController::UpdateHighContrastFromPref() { Shell::Get()->UpdateCursorCompositingEnabled(); } -void AccessibilityController::UpdateLargeCursorFromPref() { +void AccessibilityControllerImpl::UpdateLargeCursorFromPref() { DCHECK(active_user_prefs_); const bool enabled = active_user_prefs_->GetBoolean(prefs::kAccessibilityLargeCursorEnabled); @@ -1162,7 +1144,7 @@ void AccessibilityController::UpdateLargeCursorFromPref() { Shell::Get()->UpdateCursorCompositingEnabled(); } -void AccessibilityController::UpdateMonoAudioFromPref() { +void AccessibilityControllerImpl::UpdateMonoAudioFromPref() { DCHECK(active_user_prefs_); const bool enabled = active_user_prefs_->GetBoolean(prefs::kAccessibilityMonoAudioEnabled); @@ -1176,7 +1158,7 @@ void AccessibilityController::UpdateMonoAudioFromPref() { chromeos::CrasAudioHandler::Get()->SetOutputMonoEnabled(enabled); } -void AccessibilityController::UpdateSpokenFeedbackFromPref() { +void AccessibilityControllerImpl::UpdateSpokenFeedbackFromPref() { DCHECK(active_user_prefs_); const bool enabled = active_user_prefs_->GetBoolean( prefs::kAccessibilitySpokenFeedbackEnabled); @@ -1195,7 +1177,7 @@ void AccessibilityController::UpdateSpokenFeedbackFromPref() { UpdateFocusHighlightFromPref(); } -void AccessibilityController::UpdateAccessibilityHighlightingFromPrefs() { +void AccessibilityControllerImpl::UpdateAccessibilityHighlightingFromPrefs() { if (!caret_highlight_enabled_ && !cursor_highlight_enabled_ && !focus_highlight_enabled_) { accessibility_highlight_controller_.reset(); @@ -1213,7 +1195,7 @@ void AccessibilityController::UpdateAccessibilityHighlightingFromPrefs() { accessibility_highlight_controller_->HighlightFocus(focus_highlight_enabled_); } -void AccessibilityController::UpdateSelectToSpeakFromPref() { +void AccessibilityControllerImpl::UpdateSelectToSpeakFromPref() { DCHECK(active_user_prefs_); const bool enabled = active_user_prefs_->GetBoolean(prefs::kAccessibilitySelectToSpeakEnabled); @@ -1222,8 +1204,7 @@ void AccessibilityController::UpdateSelectToSpeakFromPref() { return; select_to_speak_enabled_ = enabled; - select_to_speak_state_ = - mojom::SelectToSpeakState::kSelectToSpeakStateInactive; + select_to_speak_state_ = SelectToSpeakState::kSelectToSpeakStateInactive; if (enabled) MaybeCreateSelectToSpeakEventHandler(); @@ -1233,22 +1214,23 @@ void AccessibilityController::UpdateSelectToSpeakFromPref() { NotifyAccessibilityStatusChanged(); } -void AccessibilityController::MaybeCreateSelectToSpeakEventHandler() { - // Sometimes the handler is not yet created if the prefs change has taken - // longer to propagate than setting the delegate from Chrome. - // Create the handler here; we only set the delegate when Select-to-Speak - // has been enabled. - // A different ordering has been observed between interactive_ui_tests and - // running Chrome on Linux, for example. - if (!select_to_speak_enabled_ || select_to_speak_event_handler_ || - !select_to_speak_event_handler_delegate_ptr_) +void AccessibilityControllerImpl::MaybeCreateSelectToSpeakEventHandler() { + // Construct the handler as needed when Select-to-Speak is enabled and the + // delegate is set. Otherwise, destroy the handler when Select-to-Speak is + // disabled or the delegate has been destroyed. + if (!select_to_speak_enabled_ || !select_to_speak_event_handler_delegate_) { + select_to_speak_event_handler_.reset(); + return; + } + + if (select_to_speak_event_handler_) return; select_to_speak_event_handler_ = std::make_unique( - std::move(select_to_speak_event_handler_delegate_ptr_)); + select_to_speak_event_handler_delegate_); } -void AccessibilityController::UpdateStickyKeysFromPref() { +void AccessibilityControllerImpl::UpdateStickyKeysFromPref() { DCHECK(active_user_prefs_); const bool enabled = active_user_prefs_->GetBoolean(prefs::kAccessibilityStickyKeysEnabled); @@ -1263,7 +1245,7 @@ void AccessibilityController::UpdateStickyKeysFromPref() { Shell::Get()->sticky_keys_controller()->Enable(enabled); } -void AccessibilityController::UpdateSwitchAccessFromPref() { +void AccessibilityControllerImpl::UpdateSwitchAccessFromPref() { DCHECK(active_user_prefs_); const bool enabled = active_user_prefs_->GetBoolean(prefs::kAccessibilitySwitchAccessEnabled); @@ -1280,8 +1262,8 @@ void AccessibilityController::UpdateSwitchAccessFromPref() { NotifyAccessibilityStatusChanged(); } -void AccessibilityController::UpdateSwitchAccessKeyCodesFromPref( - mojom::SwitchAccessCommand command) { +void AccessibilityControllerImpl::UpdateSwitchAccessKeyCodesFromPref( + SwitchAccessCommand command) { if (!switch_access_event_handler_) return; @@ -1298,29 +1280,31 @@ void AccessibilityController::UpdateSwitchAccessKeyCodesFromPref( switch_access_event_handler_->SetKeyCodesForCommand(key_codes, command); } -void AccessibilityController::MaybeCreateSwitchAccessEventHandler() { - // Sometimes the handler is not yet created if the prefs change has taken - // longer to propogate than setting the delegate from Chrome. - // Create the handler here; we only set the delegate when Switch Access has - // been enabled. - if (!switch_access_enabled_ || switch_access_event_handler_ || - !switch_access_event_handler_delegate_ptr_) { +void AccessibilityControllerImpl::MaybeCreateSwitchAccessEventHandler() { + // Construct the handler as needed when Switch Access is enabled and the + // delegate is set. Otherwise, destroy the handler when Switch Access is + // disabled or the delegate has been destroyed. + if (!switch_access_enabled_ || !switch_access_event_handler_delegate_) { + switch_access_event_handler_.reset(); return; } + if (switch_access_event_handler_) + return; + switch_access_event_handler_ = std::make_unique( - std::move(switch_access_event_handler_delegate_ptr_)); + switch_access_event_handler_delegate_); if (!active_user_prefs_) return; // Update the key codes for each command once the handler is initialized. - UpdateSwitchAccessKeyCodesFromPref(mojom::SwitchAccessCommand::kSelect); - UpdateSwitchAccessKeyCodesFromPref(mojom::SwitchAccessCommand::kNext); - UpdateSwitchAccessKeyCodesFromPref(mojom::SwitchAccessCommand::kPrevious); + UpdateSwitchAccessKeyCodesFromPref(SwitchAccessCommand::kSelect); + UpdateSwitchAccessKeyCodesFromPref(SwitchAccessCommand::kNext); + UpdateSwitchAccessKeyCodesFromPref(SwitchAccessCommand::kPrevious); } -void AccessibilityController::UpdateVirtualKeyboardFromPref() { +void AccessibilityControllerImpl::UpdateVirtualKeyboardFromPref() { DCHECK(active_user_prefs_); const bool enabled = active_user_prefs_->GetBoolean( prefs::kAccessibilityVirtualKeyboardEnabled); @@ -1335,18 +1319,21 @@ void AccessibilityController::UpdateVirtualKeyboardFromPref() { keyboard::SetAccessibilityKeyboardEnabled(enabled); } -void AccessibilityController::GetBatteryDescription( - GetBatteryDescriptionCallback callback) { +base::string16 AccessibilityControllerImpl::GetBatteryDescription() const { // Pass battery status as string to callback function. - std::move(callback).Run(PowerStatus::Get()->GetAccessibleNameString( - true /* Enables full description*/)); + return PowerStatus::Get()->GetAccessibleNameString(/*full_description=*/true); } -void AccessibilityController::SetVirtualKeyboardVisible(bool is_visible) { +void AccessibilityControllerImpl::SetVirtualKeyboardVisible(bool is_visible) { if (is_visible) Shell::Get()->ash_keyboard_controller()->ShowKeyboard(); else Shell::Get()->ash_keyboard_controller()->HideKeyboard(HideReason::kUser); } +void AccessibilityControllerImpl::NotifyAccessibilityStatusChanged() { + for (auto& observer : observers_) + observer.OnAccessibilityStatusChanged(); +} + } // namespace ash diff --git a/ash/accessibility/accessibility_controller.h b/ash/accessibility/accessibility_controller_impl.h similarity index 76% rename from ash/accessibility/accessibility_controller.h rename to ash/accessibility/accessibility_controller_impl.h index 5c03a0b5e38a1e..cff0696b1fe971 100644 --- a/ash/accessibility/accessibility_controller.h +++ b/ash/accessibility/accessibility_controller_impl.h @@ -2,26 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_ACCESSIBILITY_ACCESSIBILITY_CONTROLLER_H_ -#define ASH_ACCESSIBILITY_ACCESSIBILITY_CONTROLLER_H_ +#ifndef ASH_ACCESSIBILITY_ACCESSIBILITY_CONTROLLER_IMPL_H_ +#define ASH_ACCESSIBILITY_ACCESSIBILITY_CONTROLLER_IMPL_H_ #include #include "ash/ash_export.h" +#include "ash/public/cpp/accessibility_controller.h" #include "ash/public/cpp/ash_constants.h" -#include "ash/public/interfaces/accessibility_controller.mojom.h" #include "ash/session/session_observer.h" #include "ash/wm/tablet_mode/tablet_mode_observer.h" #include "base/macros.h" #include "base/observer_list.h" #include "base/time/time.h" -#include "mojo/public/cpp/bindings/binding_set.h" -#include "ui/accessibility/ax_enums.mojom.h" class PrefChangeRegistrar; class PrefRegistrySimple; class PrefService; +namespace ax { +namespace mojom { +enum class Gesture; +} // namespace mojom +} // namespace ax + namespace ash { class AccessibilityHighlightController; @@ -38,13 +42,12 @@ enum AccessibilityNotificationVisibility { // The controller for accessibility features in ash. Features can be enabled // in chrome's webui settings or the system tray menu (see TrayAccessibility). // Uses preferences to communicate with chrome to support mash. -class ASH_EXPORT AccessibilityController - : public mojom::AccessibilityController, - public SessionObserver, - public TabletModeObserver { +class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController, + public SessionObserver, + public TabletModeObserver { public: - AccessibilityController(); - ~AccessibilityController() override; + AccessibilityControllerImpl(); + ~AccessibilityControllerImpl() override; // See Shell::RegisterProfilePrefs(). static void RegisterProfilePrefs(PrefRegistrySimple* registry, bool for_test); @@ -52,9 +55,6 @@ class ASH_EXPORT AccessibilityController void AddObserver(AccessibilityObserver* observer); void RemoveObserver(AccessibilityObserver* observer); - // Binds the mojom::AccessibilityController interface to this object. - void BindRequest(mojom::AccessibilityControllerRequest request); - // The following functions read and write to their associated preference. // These values are then used to determine whether the accelerator // confirmation dialog for the respective preference has been accepted before. @@ -71,10 +71,10 @@ class ASH_EXPORT AccessibilityController void SetAutoclickEnabled(bool enabled); bool autoclick_enabled() const { return autoclick_enabled_; } - void SetAutoclickEventType(mojom::AutoclickEventType event_type); - mojom::AutoclickEventType GetAutoclickEventType(); - void SetAutoclickMenuPosition(mojom::AutoclickMenuPosition position); - mojom::AutoclickMenuPosition GetAutoclickMenuPosition(); + void SetAutoclickEventType(AutoclickEventType event_type); + AutoclickEventType GetAutoclickEventType(); + void SetAutoclickMenuPosition(AutoclickMenuPosition position); + AutoclickMenuPosition GetAutoclickMenuPosition(); // Update the autoclick menu bounds if necessary. This may need to happen when // the display work area changes, or if system ui regions change (like the @@ -112,7 +112,7 @@ class ASH_EXPORT AccessibilityController bool select_to_speak_enabled() const { return select_to_speak_enabled_; } void RequestSelectToSpeakStateChange(); - mojom::SelectToSpeakState GetSelectToSpeakState() const; + SelectToSpeakState GetSelectToSpeakState() const; void SetStickyKeysEnabled(bool enabled); bool sticky_keys_enabled() const { return sticky_keys_enabled_; } @@ -125,20 +125,18 @@ class ASH_EXPORT AccessibilityController void SetVirtualKeyboardEnabled(bool enabled); bool virtual_keyboard_enabled() const { return virtual_keyboard_enabled_; } - void SetDictationActive(bool is_active); bool dictation_active() const { return dictation_active_; } // Triggers an accessibility alert to give the user feedback. - void TriggerAccessibilityAlert(mojom::AccessibilityAlert alert); + void TriggerAccessibilityAlert(AccessibilityAlert alert); // Plays an earcon. Earcons are brief and distinctive sounds that indicate // that their mapped event has occurred. The |sound_key| enums can be found in // chromeos/audio/chromeos_sounds.h. - void PlayEarcon(int32_t sound_key); + void PlayEarcon(int sound_key); - // Initiates play of shutdown sound. The base::TimeDelta parameter gets the - // shutdown duration. - void PlayShutdownSound(base::OnceCallback callback); + // Initiates play of shutdown sound. Returns the TimeDelta duration. + base::TimeDelta PlayShutdownSound(); // Forwards an accessibility gesture from the touch exploration controller to // ChromeVox. @@ -160,45 +158,40 @@ class ASH_EXPORT AccessibilityController // Whether or not to enable toggling spoken feedback via holding down two // fingers on the screen. - void ShouldToggleSpokenFeedbackViaTouch( - base::OnceCallback callback); + bool ShouldToggleSpokenFeedbackViaTouch() const; // Plays tick sound indicating spoken feedback will be toggled after // countdown. void PlaySpokenFeedbackToggleCountdown(int tick_count); - // Public because a11y features like screen magnifier are managed outside of - // this controller. - void NotifyAccessibilityStatusChanged(); - - // mojom::AccessibilityController: - void SetClient(mojom::AccessibilityControllerClientPtr client) override; + // AccessibilityController: + void SetClient(AccessibilityControllerClient* client) override; void SetDarkenScreen(bool darken) override; void BrailleDisplayStateChanged(bool connected) override; void SetFocusHighlightRect(const gfx::Rect& bounds_in_screen) override; void SetCaretBounds(const gfx::Rect& bounds_in_screen) override; void SetAccessibilityPanelAlwaysVisible(bool always_visible) override; - void SetAccessibilityPanelBounds( - const gfx::Rect& bounds, - mojom::AccessibilityPanelState state) override; - void SetSelectToSpeakState(mojom::SelectToSpeakState state) override; + void SetAccessibilityPanelBounds(const gfx::Rect& bounds, + AccessibilityPanelState state) override; + void SetSelectToSpeakState(SelectToSpeakState state) override; void SetSelectToSpeakEventHandlerDelegate( - mojom::SelectToSpeakEventHandlerDelegatePtr delegate) override; + SelectToSpeakEventHandlerDelegate* delegate) override; void SetSwitchAccessKeysToCapture( const std::vector& keys_to_capture) override; void SetSwitchAccessEventHandlerDelegate( - mojom::SwitchAccessEventHandlerDelegatePtr delegate) override; - void ToggleDictationFromSource(mojom::DictationToggleSource source) override; + SwitchAccessEventHandlerDelegate* delegate) override; + void SetDictationActive(bool is_active) override; + void ToggleDictationFromSource(DictationToggleSource source) override; void ForwardKeyEventsToSwitchAccess(bool should_forward) override; - void GetBatteryDescription(GetBatteryDescriptionCallback callback) override; + base::string16 GetBatteryDescription() const override; void SetVirtualKeyboardVisible(bool is_visible) override; + void NotifyAccessibilityStatusChanged() override; // SessionObserver: void OnSigninScreenPrefServiceInitialized(PrefService* prefs) override; void OnActiveUserPrefServiceChanged(PrefService* prefs) override; // Test helpers: - void FlushMojoForTest(); SwitchAccessEventHandler* GetSwitchAccessEventHandlerForTest(); private: @@ -228,7 +221,7 @@ class ASH_EXPORT AccessibilityController void UpdateSelectToSpeakFromPref(); void UpdateStickyKeysFromPref(); void UpdateSwitchAccessFromPref(); - void UpdateSwitchAccessKeyCodesFromPref(mojom::SwitchAccessCommand command); + void UpdateSwitchAccessKeyCodesFromPref(SwitchAccessCommand command); void UpdateVirtualKeyboardFromPref(); void UpdateAccessibilityHighlightingFromPrefs(); @@ -241,11 +234,8 @@ class ASH_EXPORT AccessibilityController std::unique_ptr pref_change_registrar_; - // Binding for mojom::AccessibilityController interface. - mojo::BindingSet bindings_; - // Client interface in chrome browser. - mojom::AccessibilityControllerClientPtr client_; + AccessibilityControllerClient* client_ = nullptr; bool autoclick_enabled_ = false; base::TimeDelta autoclick_delay_; @@ -264,17 +254,17 @@ class ASH_EXPORT AccessibilityController bool virtual_keyboard_enabled_ = false; bool dictation_active_ = false; - mojom::SelectToSpeakState select_to_speak_state_ = - mojom::SelectToSpeakState::kSelectToSpeakStateInactive; + SelectToSpeakState select_to_speak_state_ = + SelectToSpeakState::kSelectToSpeakStateInactive; std::unique_ptr select_to_speak_event_handler_; - mojom::SelectToSpeakEventHandlerDelegatePtr - select_to_speak_event_handler_delegate_ptr_; + SelectToSpeakEventHandlerDelegate* select_to_speak_event_handler_delegate_ = + nullptr; // List of key codes that Switch Access should capture. std::vector switch_access_keys_to_capture_; std::unique_ptr switch_access_event_handler_; - mojom::SwitchAccessEventHandlerDelegatePtr - switch_access_event_handler_delegate_ptr_; + SwitchAccessEventHandlerDelegate* switch_access_event_handler_delegate_ = + nullptr; // Used to control the highlights of caret, cursor and focus. std::unique_ptr @@ -285,9 +275,9 @@ class ASH_EXPORT AccessibilityController base::ObserverList::Unchecked observers_; - DISALLOW_COPY_AND_ASSIGN(AccessibilityController); + DISALLOW_COPY_AND_ASSIGN(AccessibilityControllerImpl); }; } // namespace ash -#endif // ASH_ACCESSIBILITY_ACCESSIBILITY_CONTROLLER_H_ +#endif // ASH_ACCESSIBILITY_ACCESSIBILITY_CONTROLLER_IMPL_H_ diff --git a/ash/accessibility/accessibility_controller_unittest.cc b/ash/accessibility/accessibility_controller_unittest.cc index c1d2eb90d7368d..8e8c0c738f2883 100644 --- a/ash/accessibility/accessibility_controller_unittest.cc +++ b/ash/accessibility/accessibility_controller_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include @@ -71,7 +71,7 @@ TEST_F(AccessibilityControllerTest, PrefsAreRegistered) { } TEST_F(AccessibilityControllerTest, SetAutoclickEnabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(controller->autoclick_enabled()); @@ -91,7 +91,7 @@ TEST_F(AccessibilityControllerTest, SetAutoclickEnabled) { } TEST_F(AccessibilityControllerTest, SetCaretHighlightEnabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(controller->caret_highlight_enabled()); @@ -111,7 +111,7 @@ TEST_F(AccessibilityControllerTest, SetCaretHighlightEnabled) { } TEST_F(AccessibilityControllerTest, SetCursorHighlightEnabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(controller->cursor_highlight_enabled()); @@ -131,7 +131,7 @@ TEST_F(AccessibilityControllerTest, SetCursorHighlightEnabled) { } TEST_F(AccessibilityControllerTest, SetFocusHighlightEnabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(controller->focus_highlight_enabled()); @@ -151,7 +151,7 @@ TEST_F(AccessibilityControllerTest, SetFocusHighlightEnabled) { } TEST_F(AccessibilityControllerTest, SetHighContrastEnabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(controller->high_contrast_enabled()); @@ -171,7 +171,7 @@ TEST_F(AccessibilityControllerTest, SetHighContrastEnabled) { } TEST_F(AccessibilityControllerTest, SetLargeCursorEnabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(controller->large_cursor_enabled()); @@ -208,7 +208,7 @@ TEST_F(AccessibilityControllerTest, DisableLargeCursorResetsSize) { } TEST_F(AccessibilityControllerTest, SetMonoAudioEnabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(controller->mono_audio_enabled()); @@ -228,7 +228,7 @@ TEST_F(AccessibilityControllerTest, SetMonoAudioEnabled) { } TEST_F(AccessibilityControllerTest, SetSpokenFeedbackEnabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(controller->spoken_feedback_enabled()); @@ -248,7 +248,7 @@ TEST_F(AccessibilityControllerTest, SetSpokenFeedbackEnabled) { } TEST_F(AccessibilityControllerTest, SetStickyKeysEnabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(controller->sticky_keys_enabled()); @@ -272,7 +272,7 @@ TEST_F(AccessibilityControllerTest, SetStickyKeysEnabled) { } TEST_F(AccessibilityControllerTest, SetVirtualKeyboardEnabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(controller->virtual_keyboard_enabled()); @@ -293,45 +293,29 @@ TEST_F(AccessibilityControllerTest, SetVirtualKeyboardEnabled) { controller->RemoveObserver(&observer); } -// Tests that ash's controller gets shutdown sound duration properly from -// remote client. +// The controller should get ShutdownSoundDuration from its client. TEST_F(AccessibilityControllerTest, GetShutdownSoundDuration) { - AccessibilityController* controller = - Shell::Get()->accessibility_controller(); TestAccessibilityControllerClient client; - controller->SetClient(client.CreateInterfacePtrAndBind()); - - base::TimeDelta sound_duration; - controller->PlayShutdownSound(base::BindOnce( - [](base::TimeDelta* dst, base::TimeDelta duration) { *dst = duration; }, - base::Unretained(&sound_duration))); - controller->FlushMojoForTest(); EXPECT_EQ(TestAccessibilityControllerClient::kShutdownSoundDuration, - sound_duration); + client.PlayShutdownSound()); + EXPECT_EQ(TestAccessibilityControllerClient::kShutdownSoundDuration, + Shell::Get()->accessibility_controller()->PlayShutdownSound()); } -// Tests that ash's controller gets should toggle spoken feedback via touch -// properly from remote client. +// The controller should get ShouldToggleSpokenFeedbackViaTouch from its client. TEST_F(AccessibilityControllerTest, GetShouldToggleSpokenFeedbackViaTouch) { - AccessibilityController* controller = - Shell::Get()->accessibility_controller(); TestAccessibilityControllerClient client; - controller->SetClient(client.CreateInterfacePtrAndBind()); - - bool should_toggle = false; - controller->ShouldToggleSpokenFeedbackViaTouch(base::BindOnce( - [](bool* dst, bool should_toggle) { *dst = should_toggle; }, - base::Unretained(&should_toggle))); - controller->FlushMojoForTest(); - // Expects true which is passed by |client|. - EXPECT_TRUE(should_toggle); + EXPECT_TRUE(client.ShouldToggleSpokenFeedbackViaTouch()); + EXPECT_TRUE(Shell::Get() + ->accessibility_controller() + ->ShouldToggleSpokenFeedbackViaTouch()); } TEST_F(AccessibilityControllerTest, SetDarkenScreen) { ASSERT_FALSE( chromeos::FakePowerManagerClient::Get()->backlights_forced_off()); - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); controller->SetDarkenScreen(true); EXPECT_TRUE(chromeos::FakePowerManagerClient::Get()->backlights_forced_off()); @@ -346,7 +330,7 @@ TEST_F(AccessibilityControllerTest, ShowNotificationOnSpokenFeedback) { base::ASCIIToUTF16("ChromeVox enabled"); const base::string16 kChromeVoxEnabled = base::ASCIIToUTF16("Press Ctrl + Alt + Z to disable spoken feedback."); - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); // Enabling spoken feedback should show the notification if specified to show @@ -379,7 +363,7 @@ TEST_F(AccessibilityControllerTest, base::ASCIIToUTF16("Press Ctrl + Alt + Z to disable spoken feedback."); const base::string16 kBrailleConnectedAndChromeVoxEnabledTitle = base::ASCIIToUTF16("Braille and ChromeVox are enabled"); - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); controller->SetSpokenFeedbackEnabled(true, A11Y_NOTIFICATION_SHOW); @@ -415,21 +399,21 @@ TEST_F(AccessibilityControllerTest, } TEST_F(AccessibilityControllerTest, SelectToSpeakStateChanges) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); TestAccessibilityObserver observer; controller->AddObserver(&observer); controller->SetSelectToSpeakState( - ash::mojom::SelectToSpeakState::kSelectToSpeakStateSelecting); + ash::SelectToSpeakState::kSelectToSpeakStateSelecting); EXPECT_EQ(controller->GetSelectToSpeakState(), - ash::mojom::SelectToSpeakState::kSelectToSpeakStateSelecting); + ash::SelectToSpeakState::kSelectToSpeakStateSelecting); EXPECT_EQ(observer.status_changed_count_, 1); controller->SetSelectToSpeakState( - ash::mojom::SelectToSpeakState::kSelectToSpeakStateSpeaking); + ash::SelectToSpeakState::kSelectToSpeakStateSpeaking); EXPECT_EQ(controller->GetSelectToSpeakState(), - ash::mojom::SelectToSpeakState::kSelectToSpeakStateSpeaking); + ash::SelectToSpeakState::kSelectToSpeakStateSpeaking); EXPECT_EQ(observer.status_changed_count_, 2); } @@ -480,7 +464,7 @@ INSTANTIATE_TEST_SUITE_P(, TEST_P(AccessibilityControllerSigninTest, EnableOnLoginScreenAndLogin) { constexpr float kMagnifierScale = 4.3f; - AccessibilityController* accessibility = + AccessibilityControllerImpl* accessibility = Shell::Get()->accessibility_controller(); DockedMagnifierControllerImpl* docked_magnifier = Shell::Get()->docked_magnifier_controller(); diff --git a/ash/accessibility/accessibility_highlight_controller_unittest.cc b/ash/accessibility/accessibility_highlight_controller_unittest.cc index b0602681be530f..679c41489f3fbb 100644 --- a/ash/accessibility/accessibility_highlight_controller_unittest.cc +++ b/ash/accessibility/accessibility_highlight_controller_unittest.cc @@ -7,7 +7,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/accessibility/accessibility_cursor_ring_layer.h" #include "ash/accessibility/accessibility_focus_ring_controller_impl.h" #include "ash/shell.h" @@ -302,7 +302,7 @@ TEST_F(AccessibilityHighlightControllerTest, SetCaretBounds) { std::unique_ptr window = CreateTestWidget(); window->SetBounds(gfx::Rect(5, 5, 300, 300)); - AccessibilityController* accessibility_controller = + AccessibilityControllerImpl* accessibility_controller = Shell::Get()->accessibility_controller(); accessibility_controller->SetCaretHighlightEnabled(true); diff --git a/ash/accessibility/accessibility_panel_layout_manager.cc b/ash/accessibility/accessibility_panel_layout_manager.cc index e17cf788e74f4c..a6fb43518e87be 100644 --- a/ash/accessibility/accessibility_panel_layout_manager.cc +++ b/ash/accessibility/accessibility_panel_layout_manager.cc @@ -34,7 +34,7 @@ void AccessibilityPanelLayoutManager::SetAlwaysVisible(bool always_visible) { void AccessibilityPanelLayoutManager::SetPanelBounds( const gfx::Rect& bounds, - mojom::AccessibilityPanelState state) { + AccessibilityPanelState state) { if (!panel_window_) return; @@ -107,9 +107,9 @@ void AccessibilityPanelLayoutManager::UpdateWindowBounds() { gfx::Rect bounds = panel_bounds_; // The panel can make itself fill the screen (including covering the shelf). - if (panel_state_ == mojom::AccessibilityPanelState::FULLSCREEN) { + if (panel_state_ == AccessibilityPanelState::FULLSCREEN) { bounds = root_window->bounds(); - } else if (panel_state_ == mojom::AccessibilityPanelState::FULL_WIDTH) { + } else if (panel_state_ == AccessibilityPanelState::FULL_WIDTH) { bounds.set_x(0); bounds.set_width(root_window->bounds().width()); @@ -146,7 +146,7 @@ void AccessibilityPanelLayoutManager::UpdateWindowBounds() { void AccessibilityPanelLayoutManager::UpdateWorkAreaForPanelHeight() { bool has_height = panel_window_ && panel_window_->bounds().y() == 0 && - panel_state_ == mojom::AccessibilityPanelState::FULL_WIDTH; + panel_state_ == AccessibilityPanelState::FULL_WIDTH; Shell::GetPrimaryRootWindowController() ->work_area_insets() ->SetAccessibilityPanelHeight( diff --git a/ash/accessibility/accessibility_panel_layout_manager.h b/ash/accessibility/accessibility_panel_layout_manager.h index 70c90c2aabc9f8..c22812979dce79 100644 --- a/ash/accessibility/accessibility_panel_layout_manager.h +++ b/ash/accessibility/accessibility_panel_layout_manager.h @@ -6,7 +6,7 @@ #define ASH_ACCESSIBILITY_ACCESSIBILITY_PANEL_LAYOUT_MANAGER_H_ #include "ash/ash_export.h" -#include "ash/public/interfaces/accessibility_controller.mojom.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "ash/shell_observer.h" #include "base/macros.h" #include "ui/aura/layout_manager.h" @@ -39,8 +39,7 @@ class ASH_EXPORT AccessibilityPanelLayoutManager // Controls the panel's visibility and location. void SetAlwaysVisible(bool always_visible); - void SetPanelBounds(const gfx::Rect& bounds, - mojom::AccessibilityPanelState state); + void SetPanelBounds(const gfx::Rect& bounds, AccessibilityPanelState state); // aura::LayoutManager: void OnWindowResized() override {} @@ -86,8 +85,7 @@ class ASH_EXPORT AccessibilityPanelLayoutManager bool always_visible_ = false; // Determines how the panel_bounds_ are used when displaying the panel. - mojom::AccessibilityPanelState panel_state_ = - mojom::AccessibilityPanelState::BOUNDED; + AccessibilityPanelState panel_state_ = AccessibilityPanelState::BOUNDED; DISALLOW_COPY_AND_ASSIGN(AccessibilityPanelLayoutManager); }; diff --git a/ash/accessibility/accessibility_panel_layout_manager_unittest.cc b/ash/accessibility/accessibility_panel_layout_manager_unittest.cc index 94c684f37fd6ac..4ea0b46362a151 100644 --- a/ash/accessibility/accessibility_panel_layout_manager_unittest.cc +++ b/ash/accessibility/accessibility_panel_layout_manager_unittest.cc @@ -83,14 +83,14 @@ TEST_F(AccessibilityPanelLayoutManagerTest, PanelFullscreen) { widget->Show(); layout_manager->SetPanelBounds(gfx::Rect(0, 0, 0, kDefaultPanelHeight), - mojom::AccessibilityPanelState::FULL_WIDTH); + AccessibilityPanelState::FULL_WIDTH); gfx::Rect expected_work_area = screen->GetPrimaryDisplay().work_area(); // When the panel is fullscreen it fills the display and clears the // work area. layout_manager->SetPanelBounds(gfx::Rect(), - mojom::AccessibilityPanelState::FULLSCREEN); + AccessibilityPanelState::FULLSCREEN); EXPECT_EQ(widget->GetNativeWindow()->bounds(), screen->GetPrimaryDisplay().bounds()); EXPECT_EQ(screen->GetPrimaryDisplay().work_area().y(), 0); @@ -98,7 +98,7 @@ TEST_F(AccessibilityPanelLayoutManagerTest, PanelFullscreen) { // Restoring the panel to default size restores the bounds and sets // the work area. layout_manager->SetPanelBounds(gfx::Rect(0, 0, 0, kDefaultPanelHeight), - mojom::AccessibilityPanelState::FULL_WIDTH); + AccessibilityPanelState::FULL_WIDTH); gfx::Rect expected_bounds(0, 0, screen->GetPrimaryDisplay().bounds().width(), kDefaultPanelHeight); EXPECT_EQ(widget->GetNativeWindow()->bounds(), expected_bounds); @@ -110,17 +110,15 @@ TEST_F(AccessibilityPanelLayoutManagerTest, SetBounds) { widget->Show(); gfx::Rect bounds(0, 0, 100, 100); - GetLayoutManager()->SetPanelBounds(bounds, - mojom::AccessibilityPanelState::BOUNDED); + GetLayoutManager()->SetPanelBounds(bounds, AccessibilityPanelState::BOUNDED); EXPECT_EQ(widget->GetNativeWindow()->bounds(), bounds); } TEST_F(AccessibilityPanelLayoutManagerTest, DisplayBoundsChange) { std::unique_ptr widget = CreateChromeVoxPanel(); widget->Show(); - GetLayoutManager()->SetPanelBounds( - gfx::Rect(0, 0, 0, kDefaultPanelHeight), - mojom::AccessibilityPanelState::FULL_WIDTH); + GetLayoutManager()->SetPanelBounds(gfx::Rect(0, 0, 0, kDefaultPanelHeight), + AccessibilityPanelState::FULL_WIDTH); // When the display resolution changes the panel still sits at the top of the // screen. diff --git a/ash/accessibility/default_accessibility_delegate.cc b/ash/accessibility/default_accessibility_delegate.cc index 2f1ada87a5a024..75600ee3a0e2d3 100644 --- a/ash/accessibility/default_accessibility_delegate.cc +++ b/ash/accessibility/default_accessibility_delegate.cc @@ -6,7 +6,7 @@ #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/shell.h" namespace ash { @@ -24,7 +24,7 @@ bool DefaultAccessibilityDelegate::IsMagnifierEnabled() const { } bool DefaultAccessibilityDelegate::ShouldShowAccessibilityMenu() const { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); return controller->spoken_feedback_enabled() || screen_magnifier_enabled_ || controller->autoclick_enabled() || diff --git a/ash/accessibility/key_accessibility_enabler_unittest.cc b/ash/accessibility/key_accessibility_enabler_unittest.cc index 8e7bd272aa205a..f243675df60e5f 100644 --- a/ash/accessibility/key_accessibility_enabler_unittest.cc +++ b/ash/accessibility/key_accessibility_enabler_unittest.cc @@ -4,7 +4,7 @@ #include "ash/accessibility/key_accessibility_enabler.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/accessibility/accessibility_observer.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" @@ -65,7 +65,7 @@ TEST_F(KeyAccessibilityEnablerTest, TwoVolumeKeyDown) { ui::KeyEvent vol_up_release(ui::ET_KEY_RELEASED, ui::VKEY_VOLUME_UP, ui::EF_NONE); - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); ASSERT_FALSE(controller->spoken_feedback_enabled()); diff --git a/ash/accessibility/spoken_feedback_enabler.cc b/ash/accessibility/spoken_feedback_enabler.cc index cbebaefd7849b0..8c2f350b15363b 100644 --- a/ash/accessibility/spoken_feedback_enabler.cc +++ b/ash/accessibility/spoken_feedback_enabler.cc @@ -4,7 +4,7 @@ #include "ash/accessibility/spoken_feedback_enabler.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/shell.h" #include "ui/events/base_event_utils.h" @@ -35,14 +35,15 @@ void SpokenFeedbackEnabler::OnTimer() { double tick_count_f = (now - start_time_) / kTimerDelay; int tick_count = roundf(tick_count_f); - AccessibilityController* delegate = Shell::Get()->accessibility_controller(); - CHECK(delegate); + AccessibilityControllerImpl* controller = + Shell::Get()->accessibility_controller(); + CHECK(controller); if (tick_count >= kTimerTicksOfFirstSoundFeedback && tick_count < kTimerTicksToToggleSpokenFeedback) { - delegate->PlaySpokenFeedbackToggleCountdown(tick_count); + controller->PlaySpokenFeedbackToggleCountdown(tick_count); } else if (tick_count == kTimerTicksToToggleSpokenFeedback) { - delegate->SetSpokenFeedbackEnabled(!delegate->spoken_feedback_enabled(), - A11Y_NOTIFICATION_SHOW); + controller->SetSpokenFeedbackEnabled(!controller->spoken_feedback_enabled(), + A11Y_NOTIFICATION_SHOW); timer_.Stop(); } } diff --git a/ash/accessibility/test_accessibility_controller_client.cc b/ash/accessibility/test_accessibility_controller_client.cc index 91563c71465625..754a39b16196bf 100644 --- a/ash/accessibility/test_accessibility_controller_client.cc +++ b/ash/accessibility/test_accessibility_controller_client.cc @@ -4,26 +4,23 @@ #include "ash/accessibility/test_accessibility_controller_client.h" +#include "ash/public/cpp/accessibility_controller.h" + namespace ash { constexpr base::TimeDelta TestAccessibilityControllerClient::kShutdownSoundDuration; -TestAccessibilityControllerClient::TestAccessibilityControllerClient() - : binding_(this) {} - -TestAccessibilityControllerClient::~TestAccessibilityControllerClient() = - default; +TestAccessibilityControllerClient::TestAccessibilityControllerClient() { + AccessibilityController::Get()->SetClient(this); +} -mojom::AccessibilityControllerClientPtr -TestAccessibilityControllerClient::CreateInterfacePtrAndBind() { - mojom::AccessibilityControllerClientPtr ptr; - binding_.Bind(mojo::MakeRequest(&ptr)); - return ptr; +TestAccessibilityControllerClient::~TestAccessibilityControllerClient() { + AccessibilityController::Get()->SetClient(nullptr); } void TestAccessibilityControllerClient::TriggerAccessibilityAlert( - mojom::AccessibilityAlert alert) { + AccessibilityAlert alert) { last_a11y_alert_ = alert; } @@ -31,9 +28,8 @@ void TestAccessibilityControllerClient::PlayEarcon(int32_t sound_key) { sound_key_ = sound_key; } -void TestAccessibilityControllerClient::PlayShutdownSound( - PlayShutdownSoundCallback callback) { - std::move(callback).Run(kShutdownSoundDuration); +base::TimeDelta TestAccessibilityControllerClient::PlayShutdownSound() { + return kShutdownSoundDuration; } void TestAccessibilityControllerClient::HandleAccessibilityGesture( @@ -41,10 +37,9 @@ void TestAccessibilityControllerClient::HandleAccessibilityGesture( last_a11y_gesture_ = gesture; } -void TestAccessibilityControllerClient::ToggleDictation( - ToggleDictationCallback callback) { +bool TestAccessibilityControllerClient::ToggleDictation() { is_dictation_active_ = !is_dictation_active_; - std::move(callback).Run(is_dictation_active_); + return is_dictation_active_; } void TestAccessibilityControllerClient::SilenceSpokenFeedback() {} @@ -53,9 +48,9 @@ void TestAccessibilityControllerClient::OnTwoFingerTouchStart() {} void TestAccessibilityControllerClient::OnTwoFingerTouchStop() {} -void TestAccessibilityControllerClient::ShouldToggleSpokenFeedbackViaTouch( - ShouldToggleSpokenFeedbackViaTouchCallback callback) { - std::move(callback).Run(true); // Passing true for testing. +bool TestAccessibilityControllerClient::ShouldToggleSpokenFeedbackViaTouch() + const { + return true; } void TestAccessibilityControllerClient::PlaySpokenFeedbackToggleCountdown( diff --git a/ash/accessibility/test_accessibility_controller_client.h b/ash/accessibility/test_accessibility_controller_client.h index 879a101d4ee541..cd86ce00d486aa 100644 --- a/ash/accessibility/test_accessibility_controller_client.h +++ b/ash/accessibility/test_accessibility_controller_client.h @@ -5,10 +5,9 @@ #ifndef ASH_ACCESSIBILITY_TEST_ACCESSIBILITY_CONTROLLER_CLEINT_H_ #define ASH_ACCESSIBILITY_TEST_ACCESSIBILITY_CONTROLLER_CLEINT_H_ -#include "ash/public/interfaces/accessibility_controller.mojom.h" +#include "ash/public/cpp/accessibility_controller_client.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "base/macros.h" -#include "base/time/time.h" -#include "mojo/public/cpp/bindings/binding.h" #include "ui/accessibility/ax_enums.mojom.h" namespace ash { @@ -16,41 +15,37 @@ namespace ash { // Implement AccessibilityControllerClient mojo interface to simulate chrome // behavior in tests. This breaks the ash/chrome dependency to allow testing ash // code in isolation. -class TestAccessibilityControllerClient - : public mojom::AccessibilityControllerClient { +class TestAccessibilityControllerClient : public AccessibilityControllerClient { public: TestAccessibilityControllerClient(); - ~TestAccessibilityControllerClient() override; + ~TestAccessibilityControllerClient(); static constexpr base::TimeDelta kShutdownSoundDuration = base::TimeDelta::FromMilliseconds(1000); - mojom::AccessibilityControllerClientPtr CreateInterfacePtrAndBind(); - // mojom::AccessibilityControllerClient: - void TriggerAccessibilityAlert(mojom::AccessibilityAlert alert) override; + void TriggerAccessibilityAlert(AccessibilityAlert alert) override; void PlayEarcon(int32_t sound_key) override; - void PlayShutdownSound(PlayShutdownSoundCallback callback) override; + base::TimeDelta PlayShutdownSound() override; void HandleAccessibilityGesture(ax::mojom::Gesture gesture) override; - void ToggleDictation(ToggleDictationCallback callback) override; + bool ToggleDictation() override; void SilenceSpokenFeedback() override; void OnTwoFingerTouchStart() override; void OnTwoFingerTouchStop() override; - void ShouldToggleSpokenFeedbackViaTouch( - ShouldToggleSpokenFeedbackViaTouchCallback callback) override; + bool ShouldToggleSpokenFeedbackViaTouch() const override; void PlaySpokenFeedbackToggleCountdown(int tick_count) override; void RequestSelectToSpeakStateChange() override; int32_t GetPlayedEarconAndReset(); - mojom::AccessibilityAlert last_a11y_alert() const { return last_a11y_alert_; } + AccessibilityAlert last_a11y_alert() const { return last_a11y_alert_; } ax::mojom::Gesture last_a11y_gesture() const { return last_a11y_gesture_; } int select_to_speak_change_change_requests() const { return select_to_speak_state_change_requests_; } private: - mojom::AccessibilityAlert last_a11y_alert_ = mojom::AccessibilityAlert::NONE; + AccessibilityAlert last_a11y_alert_ = AccessibilityAlert::NONE; int32_t sound_key_ = -1; bool is_dictation_active_ = false; @@ -59,8 +54,6 @@ class TestAccessibilityControllerClient int select_to_speak_state_change_requests_ = 0; - mojo::Binding binding_; - DISALLOW_COPY_AND_ASSIGN(TestAccessibilityControllerClient); }; diff --git a/ash/accessibility/touch_exploration_manager.cc b/ash/accessibility/touch_exploration_manager.cc index 67b94446d38a6d..ae5744ba8608f0 100644 --- a/ash/accessibility/touch_exploration_manager.cc +++ b/ash/accessibility/touch_exploration_manager.cc @@ -7,7 +7,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/accessibility/accessibility_focus_ring_controller_impl.h" #include "ash/accessibility/touch_exploration_controller.h" #include "ash/keyboard/ui/keyboard_controller.h" @@ -16,7 +16,6 @@ #include "ash/root_window_controller.h" #include "ash/shell.h" #include "ash/wm/window_util.h" -#include "base/bind.h" #include "base/command_line.h" #include "chromeos/audio/chromeos_sounds.h" #include "chromeos/audio/cras_audio_handler.h" @@ -30,7 +29,7 @@ namespace ash { namespace { -AccessibilityController* GetA11yController() { +AccessibilityControllerImpl* GetA11yController() { return Shell::Get()->accessibility_controller(); } @@ -133,20 +132,14 @@ void TouchExplorationManager::OnTwoFingerTouchStart() { void TouchExplorationManager::OnTwoFingerTouchStop() { // Can be null during shutdown. - AccessibilityController* controller = GetA11yController(); - if (controller) + if (AccessibilityControllerImpl* controller = GetA11yController()) controller->OnTwoFingerTouchStop(); } void TouchExplorationManager::PlaySpokenFeedbackToggleCountdown( int tick_count) { - GetA11yController()->ShouldToggleSpokenFeedbackViaTouch(base::BindOnce( - [](int tick_count, bool should_toggle) { - if (!should_toggle) - return; - GetA11yController()->PlaySpokenFeedbackToggleCountdown(tick_count); - }, - tick_count)); + if (GetA11yController()->ShouldToggleSpokenFeedbackViaTouch()) + GetA11yController()->PlaySpokenFeedbackToggleCountdown(tick_count); } void TouchExplorationManager::PlayTouchTypeEarcon() { @@ -154,14 +147,11 @@ void TouchExplorationManager::PlayTouchTypeEarcon() { } void TouchExplorationManager::ToggleSpokenFeedback() { - GetA11yController()->ShouldToggleSpokenFeedbackViaTouch( - base::BindOnce([](bool should_toggle) { - if (!should_toggle) - return; - GetA11yController()->SetSpokenFeedbackEnabled( - !GetA11yController()->spoken_feedback_enabled(), - A11Y_NOTIFICATION_SHOW); - })); + if (GetA11yController()->ShouldToggleSpokenFeedbackViaTouch()) { + GetA11yController()->SetSpokenFeedbackEnabled( + !GetA11yController()->spoken_feedback_enabled(), + A11Y_NOTIFICATION_SHOW); + } } void TouchExplorationManager::OnWindowActivated( diff --git a/ash/accessibility/touch_exploration_manager_unittest.cc b/ash/accessibility/touch_exploration_manager_unittest.cc index 3263aa738e4c9b..1e2c9f6cae2259 100644 --- a/ash/accessibility/touch_exploration_manager_unittest.cc +++ b/ash/accessibility/touch_exploration_manager_unittest.cc @@ -4,7 +4,6 @@ #include "ash/accessibility/touch_exploration_manager.h" -#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/test_accessibility_controller_client.h" #include "ash/root_window_controller.h" #include "ash/shell.h" @@ -41,19 +40,14 @@ TEST_F(TouchExplorationManagerTest, AdjustSound) { TEST_F(TouchExplorationManagerTest, HandleAccessibilityGesture) { RootWindowController* controller = Shell::GetPrimaryRootWindowController(); TouchExplorationManager touch_exploration_manager(controller); - AccessibilityController* a11y_controller = - Shell::Get()->accessibility_controller(); TestAccessibilityControllerClient client; - a11y_controller->SetClient(client.CreateInterfacePtrAndBind()); touch_exploration_manager.HandleAccessibilityGesture( ax::mojom::Gesture::kClick); - a11y_controller->FlushMojoForTest(); EXPECT_EQ(ax::mojom::Gesture::kClick, client.last_a11y_gesture()); touch_exploration_manager.HandleAccessibilityGesture( ax::mojom::Gesture::kSwipeLeft1); - a11y_controller->FlushMojoForTest(); EXPECT_EQ(ax::mojom::Gesture::kSwipeLeft1, client.last_a11y_gesture()); } diff --git a/ash/ash_prefs.cc b/ash/ash_prefs.cc index c1aa3905a50227..d2946cf9282a36 100644 --- a/ash/ash_prefs.cc +++ b/ash/ash_prefs.cc @@ -4,7 +4,7 @@ #include "ash/public/cpp/ash_prefs.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/app_list/app_list_controller_impl.h" #include "ash/assistant/assistant_controller.h" #include "ash/detachable_base/detachable_base_handler.h" @@ -32,7 +32,7 @@ namespace { // Registers prefs whose default values are same in user and signin prefs. void RegisterProfilePrefs(PrefRegistrySimple* registry, bool for_test) { - AccessibilityController::RegisterProfilePrefs(registry, for_test); + AccessibilityControllerImpl::RegisterProfilePrefs(registry, for_test); AppListControllerImpl::RegisterProfilePrefs(registry); AssistantController::RegisterProfilePrefs(registry); BluetoothPowerController::RegisterProfilePrefs(registry); diff --git a/ash/assistant/assistant_controller.cc b/ash/assistant/assistant_controller.cc index cd5c4814f307ba..4dcd40d896448b 100644 --- a/ash/assistant/assistant_controller.cc +++ b/ash/assistant/assistant_controller.cc @@ -7,7 +7,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/assistant/util/deep_link_util.h" #include "ash/public/cpp/android_intent_helper.h" #include "ash/public/cpp/ash_pref_names.h" diff --git a/ash/assistant/assistant_interaction_controller.cc b/ash/assistant/assistant_interaction_controller.cc index 9cb18f72af33f3..0a8caf433c6b8c 100644 --- a/ash/assistant/assistant_interaction_controller.cc +++ b/ash/assistant/assistant_interaction_controller.cc @@ -6,7 +6,7 @@ #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/assistant/assistant_controller.h" #include "ash/assistant/assistant_screen_context_controller.h" #include "ash/assistant/assistant_ui_controller.h" diff --git a/ash/autoclick/autoclick_controller.cc b/ash/autoclick/autoclick_controller.cc index 845bb79640fa9f..ac1e1c74fbdd17 100644 --- a/ash/autoclick/autoclick_controller.cc +++ b/ash/autoclick/autoclick_controller.cc @@ -4,7 +4,7 @@ #include "ash/autoclick/autoclick_controller.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/autoclick/autoclick_drag_event_rewriter.h" #include "ash/autoclick/autoclick_ring_handler.h" #include "ash/autoclick/autoclick_scroll_position_handler.h" @@ -123,7 +123,7 @@ void AutoclickController::SetEnabled(bool enabled, // is on. menu_bubble_controller_ = std::make_unique(); menu_bubble_controller_->ShowBubble(event_type_, menu_position_); - if (event_type_ == mojom::AutoclickEventType::kScroll) { + if (event_type_ == AutoclickEventType::kScroll) { InitializeScrollLocation(); UpdateScrollPosition(scroll_location_); } @@ -146,10 +146,8 @@ void AutoclickController::SetEnabled(bool enabled, // Callback for if the user cancels the dialog - marks the // feature as enabled again in prefs. base::BindOnce([]() { - AccessibilityController* controller = - Shell::Get()->accessibility_controller(); // If they cancel, ensure autoclick is enabled. - controller->SetAutoclickEnabled(true); + Shell::Get()->accessibility_controller()->SetAutoclickEnabled(true); })); disable_dialog_ = dialog->GetWeakPtr(); } else { @@ -176,12 +174,11 @@ void AutoclickController::SetAutoclickDelay(base::TimeDelta delay) { } } -void AutoclickController::SetAutoclickEventType( - mojom::AutoclickEventType type) { +void AutoclickController::SetAutoclickEventType(AutoclickEventType type) { if (menu_bubble_controller_) menu_bubble_controller_->SetEventType(type); - if (type == mojom::AutoclickEventType::kScroll) { + if (type == AutoclickEventType::kScroll) { InitializeScrollLocation(); UpdateScrollPosition(scroll_location_); } else { @@ -200,8 +197,7 @@ void AutoclickController::SetMovementThreshold(int movement_threshold) { UpdateRingSize(); } -void AutoclickController::SetMenuPosition( - mojom::AutoclickMenuPosition menu_position) { +void AutoclickController::SetMenuPosition(AutoclickMenuPosition menu_position) { menu_position_ = menu_position; UpdateAutoclickMenuBoundsIfNeeded(); } @@ -213,7 +209,7 @@ void AutoclickController::DoScrollAction(ScrollPadAction action) { -kDefaultAutoclickMovementThreshold); // Return to left click. - event_type_ = mojom::AutoclickEventType::kLeftClick; + event_type_ = AutoclickEventType::kLeftClick; Shell::Get()->accessibility_controller()->SetAutoclickEventType( event_type_); return; @@ -323,10 +319,10 @@ void AutoclickController::DoAutoclickAction() { // Set the in-progress event type locally so that if the event type is updated // in the middle of this event being executed it doesn't change execution. - mojom::AutoclickEventType in_progress_event_type = event_type_; + AutoclickEventType in_progress_event_type = event_type_; RecordUserAction(in_progress_event_type); - if (in_progress_event_type == mojom::AutoclickEventType::kScroll) { + if (in_progress_event_type == AutoclickEventType::kScroll) { // A dwell during a scroll. // Check if the event is over the scroll bubble controller, and if it is, // click on the scroll bubble. @@ -354,18 +350,17 @@ void AutoclickController::DoAutoclickAction() { host->ConvertDIPToPixels(&location_in_pixels); bool drag_start = - in_progress_event_type == mojom::AutoclickEventType::kDragAndDrop && + in_progress_event_type == AutoclickEventType::kDragAndDrop && !drag_event_rewriter_->IsEnabled(); bool drag_stop = DragInProgress(); - if (in_progress_event_type == mojom::AutoclickEventType::kLeftClick || - in_progress_event_type == mojom::AutoclickEventType::kRightClick || - in_progress_event_type == mojom::AutoclickEventType::kDoubleClick || + if (in_progress_event_type == AutoclickEventType::kLeftClick || + in_progress_event_type == AutoclickEventType::kRightClick || + in_progress_event_type == AutoclickEventType::kDoubleClick || drag_start || drag_stop) { - int button = - in_progress_event_type == mojom::AutoclickEventType::kRightClick - ? ui::EF_RIGHT_MOUSE_BUTTON - : ui::EF_LEFT_MOUSE_BUTTON; + int button = in_progress_event_type == AutoclickEventType::kRightClick + ? ui::EF_RIGHT_MOUSE_BUTTON + : ui::EF_LEFT_MOUSE_BUTTON; ui::EventDispatchDetails details; if (!drag_stop) { @@ -392,7 +387,7 @@ void AutoclickController::DoAutoclickAction() { details = host->event_sink()->OnEventFromSource(&release_event); // Now a single click, or half the drag & drop, has been completed. - if (in_progress_event_type != mojom::AutoclickEventType::kDoubleClick || + if (in_progress_event_type != AutoclickEventType::kDoubleClick || details.dispatcher_destroyed) { OnActionCompleted(in_progress_event_type); return; @@ -417,7 +412,7 @@ void AutoclickController::DoAutoclickAction() { } void AutoclickController::StartAutoclickGesture() { - if (event_type_ == mojom::AutoclickEventType::kNoAction) { + if (event_type_ == AutoclickEventType::kNoAction) { // If we are set to "no action" and the gesture wouldn't occur over // the autoclick menu, cancel and return early rather than starting the // gesture. @@ -454,16 +449,15 @@ void AutoclickController::CancelAutoclickAction() { } void AutoclickController::OnActionCompleted( - mojom::AutoclickEventType completed_event_type) { + AutoclickEventType completed_event_type) { // No need to change to left click if the setting is not enabled or the // event that just executed already was a left click. - if (!revert_to_left_click_ || - event_type_ == mojom::AutoclickEventType::kLeftClick || - completed_event_type == mojom::AutoclickEventType::kLeftClick) + if (!revert_to_left_click_ || event_type_ == AutoclickEventType::kLeftClick || + completed_event_type == AutoclickEventType::kLeftClick) return; // Change the preference, but set it locally so we do not reset any state when // AutoclickController::SetAutoclickEventType is called. - event_type_ = mojom::AutoclickEventType::kLeftClick; + event_type_ = AutoclickEventType::kLeftClick; Shell::Get()->accessibility_controller()->SetAutoclickEventType(event_type_); } @@ -530,7 +524,7 @@ void AutoclickController::HideScrollPosition() { } bool AutoclickController::DragInProgress() const { - return event_type_ == mojom::AutoclickEventType::kDragAndDrop && + return event_type_ == AutoclickEventType::kDragAndDrop && drag_event_rewriter_->IsEnabled(); } @@ -547,21 +541,21 @@ bool AutoclickController::AutoclickScrollContainsPoint( } void AutoclickController::RecordUserAction( - mojom::AutoclickEventType event_type) const { + AutoclickEventType event_type) const { switch (event_type) { - case mojom::AutoclickEventType::kLeftClick: + case AutoclickEventType::kLeftClick: base::RecordAction( base::UserMetricsAction("Accessibility.Autoclick.LeftClick")); return; - case mojom::AutoclickEventType::kRightClick: + case AutoclickEventType::kRightClick: base::RecordAction( base::UserMetricsAction("Accessibility.Autoclick.RightClick")); return; - case mojom::AutoclickEventType::kDoubleClick: + case AutoclickEventType::kDoubleClick: base::RecordAction( base::UserMetricsAction("Accessibility.Autoclick.DoubleClick")); return; - case mojom::AutoclickEventType::kDragAndDrop: + case AutoclickEventType::kDragAndDrop: // Only log drag-and-drop once per drag-and-drop. It takes two "dwells" // to complete a full drag-and-drop cycle, which could lead to double // the events logged. @@ -570,9 +564,9 @@ void AutoclickController::RecordUserAction( base::RecordAction( base::UserMetricsAction("Accessibility.Autoclick.DragAndDrop")); return; - case mojom::AutoclickEventType::kScroll: + case AutoclickEventType::kScroll: // Scroll users actions will be recorded from AutoclickScrollView. - case mojom::AutoclickEventType::kNoAction: + case AutoclickEventType::kNoAction: // No action shouldn't have a UserAction, so we return. return; } diff --git a/ash/autoclick/autoclick_controller.h b/ash/autoclick/autoclick_controller.h index 4f981eea77cca5..8ffd7d676da230 100644 --- a/ash/autoclick/autoclick_controller.h +++ b/ash/autoclick/autoclick_controller.h @@ -7,7 +7,6 @@ #include "ash/ash_export.h" #include "ash/public/cpp/ash_constants.h" -#include "ash/public/interfaces/accessibility_controller_enums.mojom.h" #include "base/macros.h" #include "base/time/time.h" #include "ui/aura/client/cursor_client_observer.h" @@ -68,14 +67,14 @@ class ASH_EXPORT AutoclickController static base::TimeDelta GetDefaultAutoclickDelay(); // Sets the event type. - void SetAutoclickEventType(mojom::AutoclickEventType type); + void SetAutoclickEventType(AutoclickEventType type); // Sets the movement threshold beyond which mouse movements cancel or begin // a new Autoclick event. void SetMovementThreshold(int movement_threshold); // Sets the menu position and updates the UI. - void SetMenuPosition(mojom::AutoclickMenuPosition menu_position); + void SetMenuPosition(AutoclickMenuPosition menu_position); // Performs the given ScrollPadAction at the current scrolling point. void DoScrollAction(ScrollPadAction action); @@ -123,14 +122,14 @@ class ASH_EXPORT AutoclickController void DoAutoclickAction(); void StartAutoclickGesture(); void CancelAutoclickAction(); - void OnActionCompleted(mojom::AutoclickEventType event_type); + void OnActionCompleted(AutoclickEventType event_type); void InitClickTimers(); void UpdateRingWidget(const gfx::Point& mouse_location); void UpdateRingSize(); void InitializeScrollLocation(); void UpdateScrollPosition(const gfx::Point& point_in_screen); void HideScrollPosition(); - void RecordUserAction(mojom::AutoclickEventType event_type) const; + void RecordUserAction(AutoclickEventType event_type) const; bool DragInProgress() const; void CreateMenuBubbleController(); bool AutoclickMenuContainsPoint(const gfx::Point& point) const; @@ -153,7 +152,7 @@ class ASH_EXPORT AutoclickController // Whether Autoclick is currently enabled. bool enabled_ = false; - mojom::AutoclickEventType event_type_ = kDefaultAutoclickEventType; + AutoclickEventType event_type_ = kDefaultAutoclickEventType; bool revert_to_left_click_ = true; bool stabilize_click_position_ = false; int movement_threshold_ = kDefaultAutoclickMovementThreshold; @@ -163,7 +162,7 @@ class ASH_EXPORT AutoclickController // manually, the position will be fixed regardless of language direction and // shelf position. This probably means adding a new AutoclickMenuPostion // enum for "system default". - mojom::AutoclickMenuPosition menu_position_ = kDefaultAutoclickMenuPosition; + AutoclickMenuPosition menu_position_ = kDefaultAutoclickMenuPosition; int mouse_event_flags_ = ui::EF_NONE; // The target window is observed by AutoclickController for the duration // of a autoclick gesture. diff --git a/ash/autoclick/autoclick_unittest.cc b/ash/autoclick/autoclick_unittest.cc index e3bebbabceb266..aa12c73e1663ff 100644 --- a/ash/autoclick/autoclick_unittest.cc +++ b/ash/autoclick/autoclick_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/autoclick/autoclick_controller.h" #include "ash/shelf/shelf.h" #include "ash/shell.h" @@ -536,7 +536,7 @@ TEST_F(AutoclickTest, AutoclickChangeEventTypes) { GetAutoclickController()->SetEnabled(true, false /* do not show dialog */); GetAutoclickController()->set_revert_to_left_click(false); GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kRightClick); + AutoclickEventType::kRightClick); std::vector events; GetEventGenerator()->MoveMouseTo(30, 30); @@ -550,7 +550,7 @@ TEST_F(AutoclickTest, AutoclickChangeEventTypes) { // Changing the event type cancels the event GetEventGenerator()->MoveMouseTo(60, 60); GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kLeftClick); + AutoclickEventType::kLeftClick); events = WaitForMouseEvents(); EXPECT_EQ(0u, events.size()); @@ -558,7 +558,7 @@ TEST_F(AutoclickTest, AutoclickChangeEventTypes) { // kLeftClick type does not produce a double-click. GetEventGenerator()->MoveMouseTo(90, 90); GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kLeftClick); + AutoclickEventType::kLeftClick); events = WaitForMouseEvents(); ASSERT_EQ(2u, events.size()); EXPECT_EQ(ui::ET_MOUSE_PRESSED, events[0].type()); @@ -570,7 +570,7 @@ TEST_F(AutoclickTest, AutoclickChangeEventTypes) { // Double-click works as expected. GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kDoubleClick); + AutoclickEventType::kDoubleClick); GetEventGenerator()->MoveMouseTo(120, 120); events = WaitForMouseEvents(); ASSERT_EQ(4u, events.size()); @@ -590,7 +590,7 @@ TEST_F(AutoclickTest, AutoclickChangeEventTypes) { // Pause / no action does not cause events to be generated even when the // mouse moves. GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kNoAction); + AutoclickEventType::kNoAction); GetEventGenerator()->MoveMouseTo(120, 120); events = WaitForMouseEvents(); EXPECT_EQ(0u, events.size()); @@ -600,7 +600,7 @@ TEST_F(AutoclickTest, AutoclickDragAndDropEvents) { GetAutoclickController()->SetEnabled(true, false /* do not show dialog */); GetAutoclickController()->set_revert_to_left_click(false); GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kDragAndDrop); + AutoclickEventType::kDragAndDrop); std::vector events; GetEventGenerator()->MoveMouseTo(30, 30); @@ -632,8 +632,7 @@ TEST_F(AutoclickTest, AutoclickScrollEvents) { UpdateDisplay("800x600"); EnableExperimentalAutoclickFlag(true); GetAutoclickController()->SetEnabled(true, false /* do not show dialog */); - GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kScroll); + GetAutoclickController()->SetAutoclickEventType(AutoclickEventType::kScroll); std::vector events; std::vector wheel_events; @@ -707,7 +706,7 @@ TEST_F(AutoclickTest, AutoclickRevertsToLeftClick) { GetAutoclickController()->SetEnabled(true, false /* do not show dialog */); GetAutoclickController()->set_revert_to_left_click(true); GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kRightClick); + AutoclickEventType::kRightClick); std::vector events; GetEventGenerator()->MoveMouseTo(30, 30); @@ -719,7 +718,7 @@ TEST_F(AutoclickTest, AutoclickRevertsToLeftClick) { // Another event is now left-click; we've reverted to left click. GetEventGenerator()->MoveMouseTo(90, 90); GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kLeftClick); + AutoclickEventType::kLeftClick); events = WaitForMouseEvents(); ASSERT_EQ(2u, events.size()); EXPECT_TRUE(ui::EF_LEFT_MOUSE_BUTTON & events[0].flags()); @@ -728,7 +727,7 @@ TEST_F(AutoclickTest, AutoclickRevertsToLeftClick) { // The next event is also a left click. GetEventGenerator()->MoveMouseTo(120, 120); GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kLeftClick); + AutoclickEventType::kLeftClick); events = WaitForMouseEvents(); ASSERT_EQ(2u, events.size()); EXPECT_TRUE(ui::EF_LEFT_MOUSE_BUTTON & events[0].flags()); @@ -739,7 +738,7 @@ TEST_F(AutoclickTest, AutoclickRevertsToLeftClick) { GetAutoclickController()->set_revert_to_left_click(false); GetEventGenerator()->MoveMouseTo(150, 150); GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kLeftClick); + AutoclickEventType::kLeftClick); events = WaitForMouseEvents(); ASSERT_EQ(2u, events.size()); EXPECT_TRUE(ui::EF_LEFT_MOUSE_BUTTON & events[0].flags()); @@ -747,7 +746,7 @@ TEST_F(AutoclickTest, AutoclickRevertsToLeftClick) { // But we should no longer revert to left click if the type is something else. GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kRightClick); + AutoclickEventType::kRightClick); GetEventGenerator()->MoveMouseTo(180, 180); events = WaitForMouseEvents(); ASSERT_EQ(2u, events.size()); @@ -826,7 +825,7 @@ TEST_F(AutoclickTest, WaitsToDrawAnimationAfterDwellBegins) { } TEST_F(AutoclickTest, DoesActionOnBubbleWhenInDifferentModes) { - AccessibilityController* accessibility_controller = + AccessibilityControllerImpl* accessibility_controller = Shell::Get()->accessibility_controller(); // Enable autoclick from the accessibility controller so that the bubble is // constructed too. @@ -840,18 +839,18 @@ TEST_F(AutoclickTest, DoesActionOnBubbleWhenInDifferentModes) { const struct { const std::string display_spec; float scale; - mojom::AutoclickMenuPosition position; + AutoclickMenuPosition position; } kTestCases[] = { - {"800x600", 1.0f, mojom::AutoclickMenuPosition::kBottomRight}, - {"1024x800*2.0", 2.0f, mojom::AutoclickMenuPosition::kBottomRight}, - {"800x600", 1.0f, mojom::AutoclickMenuPosition::kTopLeft}, - {"1024x800*2.0", 2.0f, mojom::AutoclickMenuPosition::kTopLeft}, + {"800x600", 1.0f, AutoclickMenuPosition::kBottomRight}, + {"1024x800*2.0", 2.0f, AutoclickMenuPosition::kBottomRight}, + {"800x600", 1.0f, AutoclickMenuPosition::kTopLeft}, + {"1024x800*2.0", 2.0f, AutoclickMenuPosition::kTopLeft}, }; for (const auto& test : kTestCases) { UpdateDisplay(test.display_spec); accessibility_controller->SetAutoclickMenuPosition(test.position); accessibility_controller->SetAutoclickEventType( - mojom::AutoclickEventType::kRightClick); + AutoclickEventType::kRightClick); AutoclickMenuView* menu = GetAutoclickMenuView(); ASSERT_TRUE(menu); @@ -876,12 +875,12 @@ TEST_F(AutoclickTest, DoesActionOnBubbleWhenInDifferentModes) { events = WaitForMouseEvents(); EXPECT_EQ(0u, events.size()); // But the event type did change with a the hover on the button. - EXPECT_EQ(mojom::AutoclickEventType::kDoubleClick, + EXPECT_EQ(AutoclickEventType::kDoubleClick, accessibility_controller->GetAutoclickEventType()); // Change to a pause action type. accessibility_controller->SetAutoclickEventType( - mojom::AutoclickEventType::kNoAction); + AutoclickEventType::kNoAction); // Outside the bubble, no action occurs. GetEventGenerator()->MoveMouseTo(200 * test.scale, 200 * test.scale); @@ -898,7 +897,7 @@ TEST_F(AutoclickTest, DoesActionOnBubbleWhenInDifferentModes) { events = WaitForMouseEvents(); EXPECT_EQ(0u, events.size()); // The event type did not change because we were not over any button. - EXPECT_EQ(mojom::AutoclickEventType::kNoAction, + EXPECT_EQ(AutoclickEventType::kNoAction, accessibility_controller->GetAutoclickEventType()); // Leaving the bubble we are still paused. @@ -915,7 +914,7 @@ TEST_F(AutoclickTest, DoesActionOnBubbleWhenInDifferentModes) { GetEventGenerator()->MoveMouseTo(button_location); events = WaitForMouseEvents(); EXPECT_EQ(0u, events.size()); - EXPECT_EQ(mojom::AutoclickEventType::kLeftClick, + EXPECT_EQ(AutoclickEventType::kLeftClick, accessibility_controller->GetAutoclickEventType()); } } @@ -925,9 +924,9 @@ TEST_F(AutoclickTest, Shell::Get()->accessibility_controller()->SetAutoclickEnabled(true); GetAutoclickController()->set_revert_to_left_click(false); GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kNoAction); + AutoclickEventType::kNoAction); Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( - mojom::AutoclickMenuPosition::kBottomRight); + AutoclickMenuPosition::kBottomRight); int animation_delay = 5; int full_delay = UpdateAnimationDelayAndGetFullDelay(animation_delay); @@ -998,7 +997,7 @@ TEST_F(AutoclickTest, BubbleMovesWithShelfPositionChange) { // Set up autoclick and the shelf. Shell::Get()->accessibility_controller()->SetAutoclickEnabled(true); Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( - mojom::AutoclickMenuPosition::kBottomRight); + AutoclickMenuPosition::kBottomRight); Shelf* shelf = GetPrimaryShelf(); shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); EXPECT_EQ(shelf->GetVisibilityState(), SHELF_VISIBLE); @@ -1050,7 +1049,7 @@ TEST_F(AutoclickTest, AvoidsShelfBubble) { // Set up autoclick and the shelf. Shell::Get()->accessibility_controller()->SetAutoclickEnabled(true); Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( - mojom::AutoclickMenuPosition::kBottomRight); + AutoclickMenuPosition::kBottomRight); auto* unified_system_tray = GetPrimaryUnifiedSystemTray(); EXPECT_FALSE(unified_system_tray->IsBubbleShown()); AutoclickMenuView* menu = GetAutoclickMenuView(); @@ -1220,12 +1219,11 @@ TEST_F(AutoclickTest, ScrollClosesWhenHoveredOverScrollButton) { EnableExperimentalAutoclickFlag(true); GetAutoclickController()->SetEnabled(true, false /* do not show dialog */); GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kLeftClick); + AutoclickEventType::kLeftClick); EXPECT_FALSE(GetAutoclickScrollView()); // Enable scroll. - GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kScroll); + GetAutoclickController()->SetAutoclickEventType(AutoclickEventType::kScroll); ASSERT_TRUE(GetAutoclickScrollView()); views::View* close_button = GetScrollButton(AutoclickScrollView::ButtonId::kCloseScroll); @@ -1238,7 +1236,7 @@ TEST_F(AutoclickTest, ScrollClosesWhenHoveredOverScrollButton) { EXPECT_EQ(0u, events.size()); // Reset to left click and scroll view is gone. - EXPECT_EQ(mojom::AutoclickEventType::kLeftClick, + EXPECT_EQ(AutoclickEventType::kLeftClick, Shell::Get()->accessibility_controller()->GetAutoclickEventType()); EXPECT_FALSE(GetAutoclickScrollView()); @@ -1251,8 +1249,7 @@ TEST_F(AutoclickTest, ScrollOccursWhenHoveredOverScrollButtons) { GetAutoclickController()->SetEnabled(true, false /* do not show dialog */); // Enable scroll. - GetAutoclickController()->SetAutoclickEventType( - mojom::AutoclickEventType::kScroll); + GetAutoclickController()->SetAutoclickEventType(AutoclickEventType::kScroll); ASSERT_TRUE(GetAutoclickScrollView()); // TODO: Do for all four buttons, wait a few scrolls each. diff --git a/ash/display/cursor_window_controller_unittest.cc b/ash/display/cursor_window_controller_unittest.cc index beb6ff316b305a..8e092e38807954 100644 --- a/ash/display/cursor_window_controller_unittest.cc +++ b/ash/display/cursor_window_controller_unittest.cc @@ -4,7 +4,7 @@ #include "ash/display/cursor_window_controller.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/display/display_util.h" #include "ash/display/window_tree_host_manager.h" #include "ash/public/cpp/ash_pref_names.h" diff --git a/ash/display/display_move_window_util.cc b/ash/display/display_move_window_util.cc index ebeded81ebdb2b..e959432ccf74ec 100644 --- a/ash/display/display_move_window_util.cc +++ b/ash/display/display_move_window_util.cc @@ -8,7 +8,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/shell.h" #include "ash/wm/mru_window_tracker.h" #include "ash/wm/window_util.h" @@ -78,7 +78,7 @@ void HandleMoveActiveWindowBetweenDisplays() { itr == display_id_list.end() ? display_id_list[0] : *itr; wm::MoveWindowToDisplay(window, target_display_id); Shell::Get()->accessibility_controller()->TriggerAccessibilityAlert( - mojom::AccessibilityAlert::WINDOW_MOVED_TO_ANOTHER_DISPLAY); + AccessibilityAlert::WINDOW_MOVED_TO_ANOTHER_DISPLAY); base::RecordAction( base::UserMetricsAction("Accel_Move_Active_Window_Between_Displays")); } diff --git a/ash/display/display_move_window_util_unittest.cc b/ash/display/display_move_window_util_unittest.cc index 6b53a0f443652e..7cfe983269b576 100644 --- a/ash/display/display_move_window_util_unittest.cc +++ b/ash/display/display_move_window_util_unittest.cc @@ -6,7 +6,6 @@ #include "ash/accelerators/accelerator_controller_impl.h" #include "ash/accelerators/accelerator_table.h" -#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/test_accessibility_controller_client.h" #include "ash/root_window_controller.h" #include "ash/screen_util.h" @@ -200,17 +199,13 @@ TEST_F(DisplayMoveWindowUtilTest, FourDisplays) { TEST_F(DisplayMoveWindowUtilTest, A11yAlert) { // Layout: [p][1] UpdateDisplay("400x300,400x300"); - AccessibilityController* controller = - Shell::Get()->accessibility_controller(); TestAccessibilityControllerClient client; - controller->SetClient(client.CreateInterfacePtrAndBind()); aura::Window* window = CreateTestWindowInShellWithBounds(gfx::Rect(10, 20, 200, 100)); wm::ActivateWindow(window); PerformMoveWindowAccel(); - controller->FlushMojoForTest(); - EXPECT_EQ(mojom::AccessibilityAlert::WINDOW_MOVED_TO_ANOTHER_DISPLAY, + EXPECT_EQ(AccessibilityAlert::WINDOW_MOVED_TO_ANOTHER_DISPLAY, client.last_a11y_alert()); } diff --git a/ash/events/select_to_speak_event_handler.cc b/ash/events/select_to_speak_event_handler.cc index a4e8c14a499665..35e45613652a0e 100644 --- a/ash/events/select_to_speak_event_handler.cc +++ b/ash/events/select_to_speak_event_handler.cc @@ -4,26 +4,18 @@ #include "ash/events/select_to_speak_event_handler.h" -#include -#include - -#include "ash/accessibility/accessibility_controller.h" -#include "ash/public/interfaces/accessibility_controller.mojom.h" +#include "ash/accessibility/accessibility_controller_impl.h" +#include "ash/public/cpp/select_to_speak_event_handler_delegate.h" #include "ash/shell.h" -#include "base/macros.h" -#include "ui/aura/env.h" -#include "ui/aura/window_tree_host.h" -#include "ui/events/event.h" -#include "ui/events/event_sink.h" namespace ash { const ui::KeyboardCode kSpeakSelectionKey = ui::VKEY_S; SelectToSpeakEventHandler::SelectToSpeakEventHandler( - mojom::SelectToSpeakEventHandlerDelegatePtr delegate_ptr) - : delegate_ptr_(std::move(delegate_ptr)) { - DCHECK(delegate_ptr_.is_bound()); + SelectToSpeakEventHandlerDelegate* delegate) + : delegate_(delegate) { + DCHECK(delegate_); Shell::Get()->AddPreTargetHandler(this, ui::EventTarget::Priority::kAccessibility); } @@ -55,10 +47,6 @@ void SelectToSpeakEventHandler::SetSelectToSpeakStateSelecting( } } -void SelectToSpeakEventHandler::FlushMojoForTest() { - delegate_ptr_.FlushForTesting(); -} - void SelectToSpeakEventHandler::OnKeyEvent(ui::KeyEvent* event) { DCHECK(IsSelectToSpeakEnabled()); DCHECK(event); @@ -115,7 +103,7 @@ void SelectToSpeakEventHandler::OnKeyEvent(ui::KeyEvent* event) { } // Forward the key to the chrome process for the extension. - delegate_ptr_->DispatchKeyEvent(ui::Event::Clone(*event)); + delegate_->DispatchKeyEvent(*event); if (cancel_event) CancelEvent(event); @@ -152,7 +140,7 @@ void SelectToSpeakEventHandler::OnMouseEvent(ui::MouseEvent* event) { state_ = INACTIVE; } - delegate_ptr_->DispatchMouseEvent(ui::Event::Clone(*event)); + delegate_->DispatchMouseEvent(*event); if (event->type() == ui::ET_MOUSE_PRESSED || event->type() == ui::ET_MOUSE_RELEASED) @@ -212,10 +200,10 @@ void SelectToSpeakEventHandler::OnTouchEvent(ui::TouchEvent* event) { return; } int flags = ui::EF_LEFT_MOUSE_BUTTON; - ui::MouseEvent mutable_event(type, event->location(), event->root_location(), + ui::MouseEvent event_to_send(type, event->location(), event->root_location(), event->time_stamp(), flags, flags); - delegate_ptr_->DispatchMouseEvent(ui::Event::Clone(mutable_event)); + delegate_->DispatchMouseEvent(event_to_send); if (event->type() != ui::ET_TOUCH_MOVED) { // Don't cancel move events in case focus needs to change. diff --git a/ash/events/select_to_speak_event_handler.h b/ash/events/select_to_speak_event_handler.h index b13bad1213b4df..b194e4b53f7a42 100644 --- a/ash/events/select_to_speak_event_handler.h +++ b/ash/events/select_to_speak_event_handler.h @@ -6,18 +6,20 @@ #define ASH_EVENTS_SELECT_TO_SPEAK_EVENT_HANDLER_H_ #include "ash/ash_export.h" -#include "ash/public/interfaces/accessibility_controller.mojom.h" #include "base/macros.h" +#include "ui/events/event.h" #include "ui/events/event_handler.h" namespace ash { +class SelectToSpeakEventHandlerDelegate; + // SelectToSpeakEventHandler sends touch, mouse and key events to // the Select-to-Speak extension (via the delegate) when it is enabled. class ASH_EXPORT SelectToSpeakEventHandler : public ui::EventHandler { public: explicit SelectToSpeakEventHandler( - mojom::SelectToSpeakEventHandlerDelegatePtr delegate_ptr); + SelectToSpeakEventHandlerDelegate* delegate); ~SelectToSpeakEventHandler() override; // Called when the Select-to-Speak extension changes state. |is_selecting| is @@ -26,9 +28,6 @@ class ASH_EXPORT SelectToSpeakEventHandler : public ui::EventHandler { // in an inactive state. void SetSelectToSpeakStateSelecting(bool is_selecting); - // For testing usage only. - void FlushMojoForTest(); - private: // ui::EventHandler: void OnKeyEvent(ui::KeyEvent* event) override; @@ -103,7 +102,7 @@ class ASH_EXPORT SelectToSpeakEventHandler : public ui::EventHandler { ui::EventPointerType touch_type_ = ui::EventPointerType::POINTER_TYPE_UNKNOWN; // The delegate used to send key events to the Select-to-Speak extension. - mojom::SelectToSpeakEventHandlerDelegatePtr delegate_ptr_; + SelectToSpeakEventHandlerDelegate* delegate_; DISALLOW_COPY_AND_ASSIGN(SelectToSpeakEventHandler); }; diff --git a/ash/events/select_to_speak_event_handler_unittest.cc b/ash/events/select_to_speak_event_handler_unittest.cc index 3e03cebc666c8c..000b2c7054ea26 100644 --- a/ash/events/select_to_speak_event_handler_unittest.cc +++ b/ash/events/select_to_speak_event_handler_unittest.cc @@ -6,7 +6,8 @@ #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" +#include "ash/public/cpp/select_to_speak_event_handler_delegate.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/test/ash_test_helper.h" @@ -56,16 +57,10 @@ class EventCapturer : public ui::EventHandler { DISALLOW_COPY_AND_ASSIGN(EventCapturer); }; -class TestDelegate : public mojom::SelectToSpeakEventHandlerDelegate { +class TestDelegate : public SelectToSpeakEventHandlerDelegate { public: - TestDelegate() : binding_(this) {} - ~TestDelegate() override = default; - - mojom::SelectToSpeakEventHandlerDelegatePtr BindInterface() { - mojom::SelectToSpeakEventHandlerDelegatePtr ptr; - binding_.Bind(MakeRequest(&ptr)); - return ptr; - } + TestDelegate() = default; + virtual ~TestDelegate() = default; bool CapturedMouseEvent(ui::EventType event_type) { return mouse_events_captured_.find(event_type) != @@ -81,20 +76,17 @@ class TestDelegate : public mojom::SelectToSpeakEventHandlerDelegate { private: // SelectToSpeakEventHandlerDelegate: - void DispatchMouseEvent(std::unique_ptr event) override { - mouse_events_captured_.insert(event->type()); - last_mouse_location_ = event->AsMouseEvent()->location(); + void DispatchMouseEvent(const ui::MouseEvent& event) override { + mouse_events_captured_.insert(event.type()); + last_mouse_location_ = event.location(); } - void DispatchKeyEvent(std::unique_ptr event) override { + void DispatchKeyEvent(const ui::KeyEvent& event) override { // Unused for now. } gfx::Point last_mouse_location_; std::set mouse_events_captured_; - // The binding that backs the interface pointer held by the event handler. - mojo::Binding binding_; - DISALLOW_COPY_AND_ASSIGN(TestDelegate); }; @@ -115,8 +107,7 @@ class SelectToSpeakEventHandlerTest : public AshTestBase { controller_ = Shell::Get()->accessibility_controller(); controller_->SetSelectToSpeakEnabled(true); - controller_->SetSelectToSpeakEventHandlerDelegate( - delegate_->BindInterface()); + controller_->SetSelectToSpeakEventHandlerDelegate(delegate_.get()); } void TearDown() override { @@ -126,20 +117,13 @@ class SelectToSpeakEventHandlerTest : public AshTestBase { AshTestBase::TearDown(); } - // Flush messages to the delegate before callers check its state. - TestDelegate* GetDelegate() { - controller_->FlushMojoForTest(); - return delegate_.get(); - } - protected: ui::test::EventGenerator* generator_ = nullptr; EventCapturer event_capturer_; - AccessibilityController* controller_ = nullptr; - - private: + AccessibilityControllerImpl* controller_ = nullptr; std::unique_ptr delegate_; + private: DISALLOW_COPY_AND_ASSIGN(SelectToSpeakEventHandlerTest); }; @@ -177,14 +161,14 @@ TEST_F(SelectToSpeakEventHandlerTest, SearchPlusClick) { generator_->PressLeftButton(); EXPECT_FALSE(event_capturer_.last_mouse_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); - EXPECT_EQ(click_location, GetDelegate()->last_mouse_event_location()); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_EQ(click_location, delegate_->last_mouse_event_location()); generator_->ReleaseLeftButton(); EXPECT_FALSE(event_capturer_.last_mouse_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); - EXPECT_EQ(click_location, GetDelegate()->last_mouse_event_location()); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); + EXPECT_EQ(click_location, delegate_->last_mouse_event_location()); event_capturer_.Reset(); generator_->ReleaseKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); @@ -199,19 +183,19 @@ TEST_F(SelectToSpeakEventHandlerTest, SearchPlusDrag) { generator_->set_current_screen_location(click_location); generator_->PressLeftButton(); - EXPECT_EQ(click_location, GetDelegate()->last_mouse_event_location()); + EXPECT_EQ(click_location, delegate_->last_mouse_event_location()); // Drags are not blocked. gfx::Point drag_location = gfx::Point(120, 32); generator_->DragMouseTo(drag_location); - EXPECT_EQ(drag_location, GetDelegate()->last_mouse_event_location()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_DRAGGED)); + EXPECT_EQ(drag_location, delegate_->last_mouse_event_location()); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_DRAGGED)); EXPECT_TRUE(event_capturer_.last_mouse_event()); event_capturer_.Reset(); generator_->ReleaseLeftButton(); - EXPECT_EQ(drag_location, GetDelegate()->last_mouse_event_location()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); + EXPECT_EQ(drag_location, delegate_->last_mouse_event_location()); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); generator_->ReleaseKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); } @@ -227,20 +211,20 @@ TEST_F(SelectToSpeakEventHandlerTest, SearchPlusDragOnLargeDisplay) { generator_->set_current_screen_location(click_location_px); generator_->PressLeftButton(); EXPECT_EQ(gfx::Point(click_location_px.x() / 2, click_location_px.y() / 2), - GetDelegate()->last_mouse_event_location()); + delegate_->last_mouse_event_location()); gfx::Point drag_location_px = gfx::Point(120, 32); generator_->DragMouseTo(drag_location_px); EXPECT_EQ(gfx::Point(drag_location_px.x() / 2, drag_location_px.y() / 2), - GetDelegate()->last_mouse_event_location()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_DRAGGED)); + delegate_->last_mouse_event_location()); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_DRAGGED)); EXPECT_TRUE(event_capturer_.last_mouse_event()); event_capturer_.Reset(); generator_->ReleaseLeftButton(); EXPECT_EQ(gfx::Point(drag_location_px.x() / 2, drag_location_px.y() / 2), - GetDelegate()->last_mouse_event_location()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); + delegate_->last_mouse_event_location()); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); generator_->ReleaseKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); } @@ -255,7 +239,7 @@ TEST_F(SelectToSpeakEventHandlerTest, RepeatSearchKey) { generator_->PressLeftButton(); EXPECT_FALSE(event_capturer_.last_mouse_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); generator_->PressKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); generator_->PressKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); @@ -263,7 +247,7 @@ TEST_F(SelectToSpeakEventHandlerTest, RepeatSearchKey) { generator_->ReleaseLeftButton(); EXPECT_FALSE(event_capturer_.last_mouse_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); event_capturer_.Reset(); generator_->ReleaseKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); @@ -293,23 +277,23 @@ TEST_F(SelectToSpeakEventHandlerTest, SearchPlusClickTwice) { generator_->set_current_screen_location(gfx::Point(100, 12)); generator_->PressLeftButton(); EXPECT_FALSE(event_capturer_.last_mouse_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); generator_->ReleaseLeftButton(); EXPECT_FALSE(event_capturer_.last_mouse_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); - GetDelegate()->Reset(); - EXPECT_FALSE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); - EXPECT_FALSE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); + delegate_->Reset(); + EXPECT_FALSE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_FALSE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); generator_->PressLeftButton(); EXPECT_FALSE(event_capturer_.last_mouse_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); generator_->ReleaseLeftButton(); EXPECT_FALSE(event_capturer_.last_mouse_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); event_capturer_.Reset(); generator_->ReleaseKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); @@ -334,13 +318,13 @@ TEST_F(SelectToSpeakEventHandlerTest, SearchPlusKeyIgnoresClicks) { ASSERT_TRUE(event_capturer_.last_mouse_event()); EXPECT_FALSE(event_capturer_.last_mouse_event()->handled()); - EXPECT_FALSE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_FALSE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); generator_->ReleaseLeftButton(); ASSERT_TRUE(event_capturer_.last_mouse_event()); EXPECT_FALSE(event_capturer_.last_mouse_event()->handled()); - EXPECT_FALSE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); + EXPECT_FALSE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); event_capturer_.Reset(); generator_->ReleaseKey(ui::VKEY_I, ui::EF_COMMAND_DOWN); @@ -431,7 +415,7 @@ TEST_F(SelectToSpeakEventHandlerTest, DoesntStartSelectionModeIfNotInactive) { // This shouldn't cause any changes since the state is not inactive. controller_->SetSelectToSpeakState( - mojom::SelectToSpeakState::kSelectToSpeakStateSelecting); + SelectToSpeakState::kSelectToSpeakStateSelecting); // Mouse event still captured. gfx::Point click_location = gfx::Point(100, 12); @@ -441,7 +425,7 @@ TEST_F(SelectToSpeakEventHandlerTest, DoesntStartSelectionModeIfNotInactive) { // This shouldn't cause any changes since the state is not inactive. controller_->SetSelectToSpeakState( - mojom::SelectToSpeakState::kSelectToSpeakStateSelecting); + SelectToSpeakState::kSelectToSpeakStateSelecting); generator_->ReleaseLeftButton(); @@ -459,17 +443,17 @@ TEST_F(SelectToSpeakEventHandlerTest, generator_->set_current_screen_location(click_location); generator_->PressLeftButton(); EXPECT_FALSE(event_capturer_.last_mouse_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); generator_->ReleaseLeftButton(); EXPECT_FALSE(event_capturer_.last_mouse_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); // Set the state to inactive. // This is realistic because Select-to-Speak will set the state to inactive // after the hittest / search for the focused node callbacks, which may occur // before the user actually releases the search key. controller_->SetSelectToSpeakState( - mojom::SelectToSpeakState::kSelectToSpeakStateInactive); + SelectToSpeakState::kSelectToSpeakStateInactive); // The search key release should still be captured. event_capturer_.Reset(); @@ -484,7 +468,7 @@ TEST_F(SelectToSpeakEventHandlerTest, SelectionRequestedWorksWithMouse) { // Mouse events are let through normally before entering selecting state. // Another mouse event is let through normally. controller_->SetSelectToSpeakState( - mojom::SelectToSpeakState::kSelectToSpeakStateInactive); + SelectToSpeakState::kSelectToSpeakStateInactive); generator_->PressLeftButton(); EXPECT_TRUE(event_capturer_.last_mouse_event()); event_capturer_.Reset(); @@ -494,17 +478,17 @@ TEST_F(SelectToSpeakEventHandlerTest, SelectionRequestedWorksWithMouse) { // Start selection mode. controller_->SetSelectToSpeakState( - mojom::SelectToSpeakState::kSelectToSpeakStateSelecting); + SelectToSpeakState::kSelectToSpeakStateSelecting); generator_->PressLeftButton(); EXPECT_FALSE(event_capturer_.last_mouse_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); event_capturer_.Reset(); gfx::Point drag_location = gfx::Point(120, 32); generator_->DragMouseTo(drag_location); - EXPECT_EQ(drag_location, GetDelegate()->last_mouse_event_location()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_DRAGGED)); + EXPECT_EQ(drag_location, delegate_->last_mouse_event_location()); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_DRAGGED)); EXPECT_TRUE(event_capturer_.last_mouse_event()); event_capturer_.Reset(); @@ -526,7 +510,7 @@ TEST_F(SelectToSpeakEventHandlerTest, SelectionRequestedWorksWithTouch) { // Mouse events are let through normally before entering selecting state. // Another mouse event is let through normally. controller_->SetSelectToSpeakState( - mojom::SelectToSpeakState::kSelectToSpeakStateInactive); + SelectToSpeakState::kSelectToSpeakStateInactive); generator_->PressTouch(); EXPECT_TRUE(event_capturer_.last_touch_event()); event_capturer_.Reset(); @@ -536,25 +520,25 @@ TEST_F(SelectToSpeakEventHandlerTest, SelectionRequestedWorksWithTouch) { // Start selection mode. controller_->SetSelectToSpeakState( - mojom::SelectToSpeakState::kSelectToSpeakStateSelecting); + SelectToSpeakState::kSelectToSpeakStateSelecting); generator_->PressTouch(); EXPECT_FALSE(event_capturer_.last_touch_event()); // Touch events are converted to mouse events for the extension. - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); event_capturer_.Reset(); gfx::Point drag_location = gfx::Point(120, 32); generator_->MoveTouch(drag_location); - EXPECT_EQ(drag_location, GetDelegate()->last_mouse_event_location()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_DRAGGED)); + EXPECT_EQ(drag_location, delegate_->last_mouse_event_location()); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_DRAGGED)); EXPECT_TRUE(event_capturer_.last_touch_event()); event_capturer_.Reset(); // Touch up is the last event captured in the sequence generator_->ReleaseTouch(); EXPECT_FALSE(event_capturer_.last_touch_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); event_capturer_.Reset(); // Another touch event is let through normally. @@ -566,7 +550,7 @@ TEST_F(SelectToSpeakEventHandlerTest, SelectionRequestedWorksWithTouch) { TEST_F(SelectToSpeakEventHandlerTest, SelectionRequestedIgnoresOtherInput) { // Start selection mode. controller_->SetSelectToSpeakState( - mojom::SelectToSpeakState::kSelectToSpeakStateSelecting); + SelectToSpeakState::kSelectToSpeakStateSelecting); // Search key events are not impacted. generator_->PressKey(ui::VKEY_LWIN, ui::EF_COMMAND_DOWN); @@ -579,7 +563,7 @@ TEST_F(SelectToSpeakEventHandlerTest, SelectionRequestedIgnoresOtherInput) { // Start a touch selection, it should get captured and forwarded. generator_->PressTouch(); EXPECT_FALSE(event_capturer_.last_touch_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); event_capturer_.Reset(); // Mouse event happening during the touch selection are not impacted; @@ -602,38 +586,38 @@ TEST_F(SelectToSpeakEventHandlerTest, TrackingTouchIgnoresOtherTouchPointers) { gfx::Point drag_location = gfx::Point(120, 32); generator_->set_current_screen_location(touch_location); controller_->SetSelectToSpeakState( - mojom::SelectToSpeakState::kSelectToSpeakStateSelecting); + SelectToSpeakState::kSelectToSpeakStateSelecting); // The first touch event is captured and sent to the extension. generator_->PressTouchId(1); EXPECT_FALSE(event_capturer_.last_touch_event()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); event_capturer_.Reset(); - GetDelegate()->Reset(); + delegate_->Reset(); // A second touch event up and down is canceled but not sent to the extension. generator_->PressTouchId(2); EXPECT_FALSE(event_capturer_.last_touch_event()); - EXPECT_FALSE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_FALSE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); generator_->MoveTouchId(drag_location, 2); EXPECT_FALSE(event_capturer_.last_touch_event()); - EXPECT_FALSE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_DRAGGED)); + EXPECT_FALSE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_DRAGGED)); generator_->ReleaseTouchId(2); EXPECT_FALSE(event_capturer_.last_touch_event()); - EXPECT_FALSE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); + EXPECT_FALSE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_RELEASED)); // A pointer type event will not be sent either, as we are tracking touch, // even if the ID is the same. generator_->EnterPenPointerMode(); generator_->PressTouchId(1); EXPECT_FALSE(event_capturer_.last_touch_event()); - EXPECT_FALSE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); + EXPECT_FALSE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_PRESSED)); generator_->ExitPenPointerMode(); // The first pointer is still tracked. generator_->MoveTouchId(drag_location, 1); - EXPECT_EQ(drag_location, GetDelegate()->last_mouse_event_location()); - EXPECT_TRUE(GetDelegate()->CapturedMouseEvent(ui::ET_MOUSE_DRAGGED)); + EXPECT_EQ(drag_location, delegate_->last_mouse_event_location()); + EXPECT_TRUE(delegate_->CapturedMouseEvent(ui::ET_MOUSE_DRAGGED)); EXPECT_TRUE(event_capturer_.last_touch_event()); event_capturer_.Reset(); diff --git a/ash/events/spoken_feedback_event_rewriter.cc b/ash/events/spoken_feedback_event_rewriter.cc index f65d6e4d278299..24939684f8ea29 100644 --- a/ash/events/spoken_feedback_event_rewriter.cc +++ b/ash/events/spoken_feedback_event_rewriter.cc @@ -7,7 +7,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/public/cpp/spoken_feedback_event_rewriter_delegate.h" #include "ash/shell.h" #include "ui/aura/window_tree_host.h" diff --git a/ash/events/spoken_feedback_event_rewriter_unittest.cc b/ash/events/spoken_feedback_event_rewriter_unittest.cc index 6e19b978e26329..c709524d415be9 100644 --- a/ash/events/spoken_feedback_event_rewriter_unittest.cc +++ b/ash/events/spoken_feedback_event_rewriter_unittest.cc @@ -7,7 +7,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/public/cpp/spoken_feedback_event_rewriter_delegate.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" @@ -114,7 +114,7 @@ class SpokenFeedbackEventRewriterTest : public ash::AshTestBase { // The delegate should not intercept events when spoken feedback is disabled. TEST_F(SpokenFeedbackEventRewriterTest, EventsNotConsumedWhenDisabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(controller->spoken_feedback_enabled()); @@ -136,7 +136,7 @@ TEST_F(SpokenFeedbackEventRewriterTest, EventsNotConsumedWhenDisabled) { // The delegate should intercept key events when spoken feedback is enabled. TEST_F(SpokenFeedbackEventRewriterTest, KeyEventsConsumedWhenEnabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); controller->SetSpokenFeedbackEnabled(true, A11Y_NOTIFICATION_NONE); EXPECT_TRUE(controller->spoken_feedback_enabled()); @@ -181,7 +181,7 @@ TEST_F(SpokenFeedbackEventRewriterTest, UnhandledEventsSentToOtherRewriters) { } TEST_F(SpokenFeedbackEventRewriterTest, KeysNotEatenWithChromeVoxDisabled) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); EXPECT_FALSE(controller->spoken_feedback_enabled()); @@ -212,7 +212,7 @@ TEST_F(SpokenFeedbackEventRewriterTest, KeysNotEatenWithChromeVoxDisabled) { } TEST_F(SpokenFeedbackEventRewriterTest, KeyEventsCaptured) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); controller->SetSpokenFeedbackEnabled(true, A11Y_NOTIFICATION_NONE); EXPECT_TRUE(controller->spoken_feedback_enabled()); diff --git a/ash/events/switch_access_event_handler.cc b/ash/events/switch_access_event_handler.cc index 5a4ae41549eaf1..0c988e1c467766 100644 --- a/ash/events/switch_access_event_handler.cc +++ b/ash/events/switch_access_event_handler.cc @@ -4,10 +4,10 @@ #include "ash/events/switch_access_event_handler.h" -#include - -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" +#include "ash/public/cpp/switch_access_event_handler_delegate.h" #include "ash/shell.h" +#include "ui/events/event.h" namespace ash { @@ -28,9 +28,9 @@ void CancelEvent(ui::Event* event) { } // namespace SwitchAccessEventHandler::SwitchAccessEventHandler( - mojom::SwitchAccessEventHandlerDelegatePtr delegate_ptr) - : delegate_ptr_(std::move(delegate_ptr)) { - DCHECK(delegate_ptr_.is_bound()); + SwitchAccessEventHandlerDelegate* delegate) + : delegate_(delegate) { + DCHECK(delegate_); Shell::Get()->AddPreTargetHandler(this, ui::EventTarget::Priority::kAccessibility); } @@ -39,20 +39,16 @@ SwitchAccessEventHandler::~SwitchAccessEventHandler() { Shell::Get()->RemovePreTargetHandler(this); } -void SwitchAccessEventHandler::FlushMojoForTest() { - delegate_ptr_.FlushForTesting(); -} - bool SwitchAccessEventHandler::SetKeyCodesForCommand( std::set new_key_codes, - mojom::SwitchAccessCommand command) { + SwitchAccessCommand command) { bool has_changed = false; std::set to_clear; // Clear old values that conflict with the new assignment. for (const auto& val : command_for_key_code_) { int old_key_code = val.first; - mojom::SwitchAccessCommand old_command = val.second; + SwitchAccessCommand old_command = val.second; if (new_key_codes.count(old_key_code) > 0) { if (old_command != command) { @@ -97,14 +93,13 @@ void SwitchAccessEventHandler::OnKeyEvent(ui::KeyEvent* event) { CancelEvent(event); // TODO(anastasi): Remove event dispatch once settings migration is // complete. - delegate_ptr_->DispatchKeyEvent(ui::Event::Clone(*event)); + delegate_->DispatchKeyEvent(*event); // The Command events are currently sent, but ignored. The next step of the // migration will be to switch from using the key events to using the // commands, and the final step will be to remove the key events entirely. - mojom::SwitchAccessCommand command = - command_for_key_code_[event->key_code()]; - delegate_ptr_->SendSwitchAccessCommand(command); + SwitchAccessCommand command = command_for_key_code_[event->key_code()]; + delegate_->SendSwitchAccessCommand(command); } } diff --git a/ash/events/switch_access_event_handler.h b/ash/events/switch_access_event_handler.h index 200f1c40ac53ea..23f1fcef5dd046 100644 --- a/ash/events/switch_access_event_handler.h +++ b/ash/events/switch_access_event_handler.h @@ -5,19 +5,23 @@ #ifndef ASH_EVENTS_SWITCH_ACCESS_EVENT_HANDLER_H_ #define ASH_EVENTS_SWITCH_ACCESS_EVENT_HANDLER_H_ +#include +#include + #include "ash/ash_export.h" -#include "ash/public/interfaces/accessibility_controller.mojom.h" #include "base/macros.h" #include "ui/events/event_handler.h" namespace ash { +enum class SwitchAccessCommand; +class SwitchAccessEventHandlerDelegate; + // SwitchAccessEventHandler sends events to the Switch Access extension // (via the delegate) when it is enabled. class ASH_EXPORT SwitchAccessEventHandler : public ui::EventHandler { public: - explicit SwitchAccessEventHandler( - mojom::SwitchAccessEventHandlerDelegatePtr delegate_ptr); + explicit SwitchAccessEventHandler(SwitchAccessEventHandlerDelegate* delegate); ~SwitchAccessEventHandler() override; // Sets the keys that are captured by Switch Access. @@ -28,7 +32,7 @@ class ASH_EXPORT SwitchAccessEventHandler : public ui::EventHandler { // Sets what key_codes are captured for a given command. bool SetKeyCodesForCommand(std::set key_codes, - mojom::SwitchAccessCommand command); + SwitchAccessCommand command); // Sets whether virtual key events should be ignored. void set_ignore_virtual_key_events(bool should_ignore) { @@ -42,12 +46,10 @@ class ASH_EXPORT SwitchAccessEventHandler : public ui::EventHandler { } // For testing usage only. - void FlushMojoForTest(); const std::set key_codes_to_capture_for_test() { return key_codes_to_capture_; } - const std::map - command_for_key_code_map_for_test() { + const std::map command_for_key_code_map_for_test() { return command_for_key_code_; } @@ -58,13 +60,13 @@ class ASH_EXPORT SwitchAccessEventHandler : public ui::EventHandler { bool ShouldForwardEvent(const ui::KeyEvent& event) const; // The delegate used to send key events to the Switch Access extension. - mojom::SwitchAccessEventHandlerDelegatePtr delegate_ptr_; + SwitchAccessEventHandlerDelegate* delegate_; // TODO(anastasi): Remove this once the settings migration is complete. std::set keys_to_capture_; std::set key_codes_to_capture_; - std::map command_for_key_code_; + std::map command_for_key_code_; bool forward_key_events_ = false; bool ignore_virtual_key_events_ = true; diff --git a/ash/events/switch_access_event_handler_unittest.cc b/ash/events/switch_access_event_handler_unittest.cc index d56110c28176c1..ca1fcdc312136e 100644 --- a/ash/events/switch_access_event_handler_unittest.cc +++ b/ash/events/switch_access_event_handler_unittest.cc @@ -4,13 +4,12 @@ #include "ash/events/switch_access_event_handler.h" -#include "ash/accessibility/accessibility_controller.h" -#include "ash/public/interfaces/accessibility_controller.mojom.h" +#include "ash/accessibility/accessibility_controller_impl.h" +#include "ash/public/cpp/switch_access_event_handler_delegate.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "base/command_line.h" #include "base/macros.h" -#include "mojo/public/cpp/bindings/binding.h" #include "ui/accessibility/accessibility_switches.h" #include "ui/aura/env.h" #include "ui/events/event.h" @@ -33,7 +32,7 @@ class EventCapturer : public ui::EventHandler { private: void OnKeyEvent(ui::KeyEvent* event) override { - last_key_event_.reset(new ui::KeyEvent(*event)); + last_key_event_ = std::make_unique(*event); } std::unique_ptr last_key_event_; @@ -41,29 +40,20 @@ class EventCapturer : public ui::EventHandler { DISALLOW_COPY_AND_ASSIGN(EventCapturer); }; -class TestDelegate : public mojom::SwitchAccessEventHandlerDelegate { +class TestDelegate : public SwitchAccessEventHandlerDelegate { public: - TestDelegate() : binding_(this) {} - ~TestDelegate() override = default; - - mojom::SwitchAccessEventHandlerDelegatePtr BindInterface() { - mojom::SwitchAccessEventHandlerDelegatePtr ptr; - binding_.Bind(MakeRequest(&ptr)); - return ptr; - } + TestDelegate() = default; + virtual ~TestDelegate() = default; ui::KeyEvent* last_key_event() { return key_events_.back().get(); } private: // SwitchAccessEventHandlerDelegate: - void DispatchKeyEvent(std::unique_ptr event) override { - DCHECK(event->IsKeyEvent()); - key_events_.push_back(std::make_unique(event->AsKeyEvent())); + void DispatchKeyEvent(const ui::KeyEvent& event) override { + key_events_.push_back(std::make_unique(event)); } + void SendSwitchAccessCommand(SwitchAccessCommand command) override {} - void SendSwitchAccessCommand(mojom::SwitchAccessCommand command) override {} - - mojo::Binding binding_; std::vector> key_events_; DISALLOW_COPY_AND_ASSIGN(TestDelegate); @@ -90,8 +80,7 @@ class SwitchAccessEventHandlerTest : public AshTestBase { base::CommandLine::ForCurrentProcess()->AppendSwitch( switches::kEnableExperimentalAccessibilitySwitchAccess); controller_->SetSwitchAccessEnabled(true); - controller_->SetSwitchAccessEventHandlerDelegate( - delegate_->BindInterface()); + controller_->SetSwitchAccessEventHandlerDelegate(delegate_.get()); controller_->SetSwitchAccessIgnoreVirtualKeyEvent(false); } @@ -102,12 +91,6 @@ class SwitchAccessEventHandlerTest : public AshTestBase { AshTestBase::TearDown(); } - // Flush messages to the delegate before callers check its state. - TestDelegate* GetDelegate() { - controller_->FlushMojoForTest(); - return delegate_.get(); - } - const std::set GetKeyCodesToCapture() { SwitchAccessEventHandler* handler = controller_->GetSwitchAccessEventHandlerForTest(); @@ -116,22 +99,21 @@ class SwitchAccessEventHandlerTest : public AshTestBase { return std::set(); } - const std::map GetCommandForKeyCodeMap() { + const std::map GetCommandForKeyCodeMap() { SwitchAccessEventHandler* handler = controller_->GetSwitchAccessEventHandlerForTest(); if (handler) return handler->command_for_key_code_map_for_test(); - return std::map(); + return std::map(); } protected: ui::test::EventGenerator* generator_ = nullptr; EventCapturer event_capturer_; - AccessibilityController* controller_ = nullptr; - - private: + AccessibilityControllerImpl* controller_ = nullptr; std::unique_ptr delegate_; + private: DISALLOW_COPY_AND_ASSIGN(SwitchAccessEventHandlerTest); }; @@ -147,7 +129,7 @@ TEST_F(SwitchAccessEventHandlerTest, CaptureSpecifiedKeys) { // The event was handled by SwitchAccessEventHandler. EXPECT_FALSE(event_capturer_.last_key_event()); - ui::KeyEvent* key_event_1 = GetDelegate()->last_key_event(); + ui::KeyEvent* key_event_1 = delegate_->last_key_event(); EXPECT_TRUE(key_event_1); // Press the "2" key. @@ -155,11 +137,11 @@ TEST_F(SwitchAccessEventHandlerTest, CaptureSpecifiedKeys) { generator_->ReleaseKey(ui::VKEY_2, ui::EF_NONE); // We received a new event. - EXPECT_NE(GetDelegate()->last_key_event(), key_event_1); + EXPECT_NE(delegate_->last_key_event(), key_event_1); // The event was handled by SwitchAccessEventHandler. EXPECT_FALSE(event_capturer_.last_key_event()); - ui::KeyEvent* key_event_2 = GetDelegate()->last_key_event(); + ui::KeyEvent* key_event_2 = delegate_->last_key_event(); EXPECT_TRUE(key_event_2); // Press the "3" key. @@ -167,11 +149,11 @@ TEST_F(SwitchAccessEventHandlerTest, CaptureSpecifiedKeys) { generator_->ReleaseKey(ui::VKEY_3, ui::EF_NONE); // We received a new event. - EXPECT_NE(GetDelegate()->last_key_event(), key_event_2); + EXPECT_NE(delegate_->last_key_event(), key_event_2); // The event was handled by SwitchAccessEventHandler. EXPECT_FALSE(event_capturer_.last_key_event()); - ui::KeyEvent* key_event_3 = GetDelegate()->last_key_event(); + ui::KeyEvent* key_event_3 = delegate_->last_key_event(); EXPECT_TRUE(key_event_3); } @@ -204,7 +186,7 @@ TEST_F(SwitchAccessEventHandlerTest, KeysNoLongerCaptureAfterUpdate) { // The event was handled by SwitchAccessEventHandler. EXPECT_FALSE(event_capturer_.last_key_event()); - ui::KeyEvent* key_event_1 = GetDelegate()->last_key_event(); + ui::KeyEvent* key_event_1 = delegate_->last_key_event(); EXPECT_TRUE(key_event_1); // Update the Switch Access keys to capture {2, 3, 4}. @@ -238,14 +220,14 @@ TEST_F(SwitchAccessEventHandlerTest, ForwardKeyEvents) { // The event should be handled by SwitchAccessEventHandler. EXPECT_FALSE(event_capturer_.last_key_event()); - EXPECT_TRUE(GetDelegate()->last_key_event()); + EXPECT_TRUE(delegate_->last_key_event()); // Release the "T" key. generator_->ReleaseKey(ui::VKEY_T, ui::EF_NONE); // The event should be handled by SwitchAccessEventHandler. EXPECT_FALSE(event_capturer_.last_key_event()); - EXPECT_TRUE(GetDelegate()->last_key_event()); + EXPECT_TRUE(delegate_->last_key_event()); // Tell the Switch Access Event Handler to stop forwarding key events. Shell::Get()->accessibility_controller()->ForwardKeyEventsToSwitchAccess( @@ -274,8 +256,7 @@ TEST_F(SwitchAccessEventHandlerTest, SetKeyCodesForCommand) { std::set new_key_codes; new_key_codes.insert(48 /* '0' */); new_key_codes.insert(83 /* 's' */); - handler->SetKeyCodesForCommand(new_key_codes, - mojom::SwitchAccessCommand::kSelect); + handler->SetKeyCodesForCommand(new_key_codes, SwitchAccessCommand::kSelect); // Check that values are added to both data structures. std::set kc_to_capture = GetKeyCodesToCapture(); @@ -283,18 +264,16 @@ TEST_F(SwitchAccessEventHandlerTest, SetKeyCodesForCommand) { EXPECT_EQ(1ul /* unsigned long */, kc_to_capture.count(48)); EXPECT_EQ(1ul /* unsigned long */, kc_to_capture.count(83)); - std::map command_map = - GetCommandForKeyCodeMap(); + std::map command_map = GetCommandForKeyCodeMap(); EXPECT_EQ(2ul /* unsigned long */, command_map.size()); - EXPECT_EQ(mojom::SwitchAccessCommand::kSelect, command_map.at(48)); - EXPECT_EQ(mojom::SwitchAccessCommand::kSelect, command_map.at(83)); + EXPECT_EQ(SwitchAccessCommand::kSelect, command_map.at(48)); + EXPECT_EQ(SwitchAccessCommand::kSelect, command_map.at(83)); // Set key codes for the Next command. new_key_codes.clear(); new_key_codes.insert(49 /* '1' */); new_key_codes.insert(78 /* 'n' */); - handler->SetKeyCodesForCommand(new_key_codes, - mojom::SwitchAccessCommand::kNext); + handler->SetKeyCodesForCommand(new_key_codes, SwitchAccessCommand::kNext); // Check that the new values are added and old values are not changed. kc_to_capture = GetKeyCodesToCapture(); @@ -304,15 +283,14 @@ TEST_F(SwitchAccessEventHandlerTest, SetKeyCodesForCommand) { command_map = GetCommandForKeyCodeMap(); EXPECT_EQ(4ul /* unsigned long */, command_map.size()); - EXPECT_EQ(mojom::SwitchAccessCommand::kNext, command_map.at(49)); - EXPECT_EQ(mojom::SwitchAccessCommand::kNext, command_map.at(78)); + EXPECT_EQ(SwitchAccessCommand::kNext, command_map.at(49)); + EXPECT_EQ(SwitchAccessCommand::kNext, command_map.at(78)); // Set key codes for the Previous command. Re-use a key code from above. new_key_codes.clear(); new_key_codes.insert(49 /* '1' */); new_key_codes.insert(80 /* 'p' */); - handler->SetKeyCodesForCommand(new_key_codes, - mojom::SwitchAccessCommand::kPrevious); + handler->SetKeyCodesForCommand(new_key_codes, SwitchAccessCommand::kPrevious); // Check that '1' has been remapped to Previous. kc_to_capture = GetKeyCodesToCapture(); @@ -322,16 +300,15 @@ TEST_F(SwitchAccessEventHandlerTest, SetKeyCodesForCommand) { command_map = GetCommandForKeyCodeMap(); EXPECT_EQ(5ul /* unsigned long */, command_map.size()); - EXPECT_EQ(mojom::SwitchAccessCommand::kPrevious, command_map.at(49)); - EXPECT_EQ(mojom::SwitchAccessCommand::kPrevious, command_map.at(80)); - EXPECT_EQ(mojom::SwitchAccessCommand::kNext, command_map.at(78)); + EXPECT_EQ(SwitchAccessCommand::kPrevious, command_map.at(49)); + EXPECT_EQ(SwitchAccessCommand::kPrevious, command_map.at(80)); + EXPECT_EQ(SwitchAccessCommand::kNext, command_map.at(78)); // Set a new key code for the Select command. new_key_codes.clear(); new_key_codes.insert(51 /* '3' */); new_key_codes.insert(83 /* 's' */); - handler->SetKeyCodesForCommand(new_key_codes, - mojom::SwitchAccessCommand::kSelect); + handler->SetKeyCodesForCommand(new_key_codes, SwitchAccessCommand::kSelect); // Check that the previously set values for Select have been cleared. kc_to_capture = GetKeyCodesToCapture(); @@ -342,8 +319,8 @@ TEST_F(SwitchAccessEventHandlerTest, SetKeyCodesForCommand) { command_map = GetCommandForKeyCodeMap(); EXPECT_EQ(5ul /* unsigned long */, command_map.size()); - EXPECT_EQ(mojom::SwitchAccessCommand::kSelect, command_map.at(51)); - EXPECT_EQ(mojom::SwitchAccessCommand::kSelect, command_map.at(83)); + EXPECT_EQ(SwitchAccessCommand::kSelect, command_map.at(51)); + EXPECT_EQ(SwitchAccessCommand::kSelect, command_map.at(83)); EXPECT_EQ(command_map.end(), command_map.find(48)); } diff --git a/ash/keyboard/virtual_keyboard_controller.cc b/ash/keyboard/virtual_keyboard_controller.cc index 59ba837309600d..80b8fcf772718f 100644 --- a/ash/keyboard/virtual_keyboard_controller.cc +++ b/ash/keyboard/virtual_keyboard_controller.cc @@ -6,7 +6,6 @@ #include -#include "ash/accessibility/accessibility_controller.h" #include "ash/ime/ime_controller.h" #include "ash/keyboard/ash_keyboard_controller.h" #include "ash/keyboard/ui/keyboard_controller.h" diff --git a/ash/keyboard/virtual_keyboard_controller_unittest.cc b/ash/keyboard/virtual_keyboard_controller_unittest.cc index 25deb8c5143b57..59bd3c0551e004 100644 --- a/ash/keyboard/virtual_keyboard_controller_unittest.cc +++ b/ash/keyboard/virtual_keyboard_controller_unittest.cc @@ -7,7 +7,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/ime/ime_controller.h" #include "ash/ime/test_ime_controller_client.h" #include "ash/keyboard/ash_keyboard_controller.h" @@ -86,7 +86,7 @@ TEST_F(VirtualKeyboardControllerTest, RestoreKeyboardDevices) { TEST_F(VirtualKeyboardControllerTest, ForceToShowKeyboardWithKeysetWhenAccessibilityKeyboardIsEnabled) { - AccessibilityController* accessibility_controller = + AccessibilityControllerImpl* accessibility_controller = Shell::Get()->accessibility_controller(); accessibility_controller->SetVirtualKeyboardEnabled(true); ASSERT_TRUE(accessibility_controller->virtual_keyboard_enabled()); diff --git a/ash/lock_screen_action/lock_screen_note_display_state_handler_unittest.cc b/ash/lock_screen_action/lock_screen_note_display_state_handler_unittest.cc index c83a77d1b1c17d..a7bc435b34a7ed 100644 --- a/ash/lock_screen_action/lock_screen_note_display_state_handler_unittest.cc +++ b/ash/lock_screen_action/lock_screen_note_display_state_handler_unittest.cc @@ -8,7 +8,6 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/test_accessibility_controller_client.h" #include "ash/public/cpp/ash_switches.h" #include "ash/public/interfaces/tray_action.mojom.h" @@ -420,16 +419,9 @@ TEST_F(LockScreenNoteDisplayStateHandlerTest, TEST_F(LockScreenNoteDisplayStateHandlerTest, ScreenA11yAlerts) { TestAccessibilityControllerClient a11y_client; - AccessibilityController* a11y_controller = - Shell::Get()->accessibility_controller(); - a11y_controller->SetClient(a11y_client.CreateInterfacePtrAndBind()); - SimulatePowerButtonPress(); ASSERT_TRUE(power_manager_client()->backlights_forced_off()); - - a11y_controller->FlushMojoForTest(); - EXPECT_EQ(mojom::AccessibilityAlert::SCREEN_OFF, - a11y_client.last_a11y_alert()); + EXPECT_EQ(AccessibilityAlert::SCREEN_OFF, a11y_client.last_a11y_alert()); ui::DeviceDataManagerTestApi devices_test_api; devices_test_api.NotifyObserversStylusStateChanged(ui::StylusState::REMOVED); @@ -441,18 +433,14 @@ TEST_F(LockScreenNoteDisplayStateHandlerTest, ScreenA11yAlerts) { // Screen ON alert is delayed until the screen is turned on after lock screen // note launch. - a11y_controller->FlushMojoForTest(); - EXPECT_EQ(mojom::AccessibilityAlert::SCREEN_OFF, - a11y_client.last_a11y_alert()); + EXPECT_EQ(AccessibilityAlert::SCREEN_OFF, a11y_client.last_a11y_alert()); Shell::Get()->tray_action()->UpdateLockScreenNoteState( mojom::TrayActionState::kActive); base::RunLoop().RunUntilIdle(); // Verify that screen on a11y alert has been sent. - a11y_controller->FlushMojoForTest(); - EXPECT_EQ(mojom::AccessibilityAlert::SCREEN_ON, - a11y_client.last_a11y_alert()); + EXPECT_EQ(AccessibilityAlert::SCREEN_ON, a11y_client.last_a11y_alert()); } TEST_F(LockScreenNoteDisplayStateHandlerTest, diff --git a/ash/magnifier/docked_magnifier_controller_impl.cc b/ash/magnifier/docked_magnifier_controller_impl.cc index 8fac759d02fc51..3685e4dfdf9193 100644 --- a/ash/magnifier/docked_magnifier_controller_impl.cc +++ b/ash/magnifier/docked_magnifier_controller_impl.cc @@ -6,7 +6,7 @@ #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/host/ash_window_tree_host.h" #include "ash/magnifier/magnifier_utils.h" #include "ash/public/cpp/ash_pref_names.h" diff --git a/ash/magnifier/docked_magnifier_controller_impl_unittest.cc b/ash/magnifier/docked_magnifier_controller_impl_unittest.cc index b3b5f2b9827fd9..ca18f6a6228e76 100644 --- a/ash/magnifier/docked_magnifier_controller_impl_unittest.cc +++ b/ash/magnifier/docked_magnifier_controller_impl_unittest.cc @@ -7,7 +7,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/display/display_util.h" #include "ash/display/window_tree_host_manager.h" #include "ash/host/ash_window_tree_host.h" diff --git a/ash/metrics/user_metrics_recorder.cc b/ash/metrics/user_metrics_recorder.cc index d0386cea59f036..b563b4fdd10077 100644 --- a/ash/metrics/user_metrics_recorder.cc +++ b/ash/metrics/user_metrics_recorder.cc @@ -11,10 +11,10 @@ #include "ash/metrics/demo_session_metrics_recorder.h" #include "ash/metrics/desktop_task_switch_metric_recorder.h" #include "ash/metrics/pointer_metrics_recorder.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "ash/public/cpp/shelf_item.h" #include "ash/public/cpp/shelf_model.h" #include "ash/public/cpp/shell_window_ids.h" -#include "ash/public/interfaces/accessibility_controller.mojom-shared.h" #include "ash/session/session_controller_impl.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_view.h" @@ -209,7 +209,7 @@ void UserMetricsRecorder::RecordUserClickOnShelfButton( // static void UserMetricsRecorder::RecordUserToggleDictation( - mojom::DictationToggleSource source) { + DictationToggleSource source) { UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosDictation.ToggleDictationMethod", source); } diff --git a/ash/metrics/user_metrics_recorder.h b/ash/metrics/user_metrics_recorder.h index 4c8a4f73aa733b..7f42c1a3a42c33 100644 --- a/ash/metrics/user_metrics_recorder.h +++ b/ash/metrics/user_metrics_recorder.h @@ -16,12 +16,9 @@ namespace ash { -namespace mojom { -enum class DictationToggleSource; -} // namespace mojom - class DemoSessionMetricsRecorder; class DesktopTaskSwitchMetricRecorder; +enum class DictationToggleSource; class PointerMetricsRecorder; // User Metrics Recorder provides a repeating callback (RecordPeriodicMetrics) @@ -46,7 +43,7 @@ class ASH_EXPORT UserMetricsRecorder { LoginMetricsRecorder::ShelfButtonClickTarget target); // Record the method used to activate dictation. - static void RecordUserToggleDictation(mojom::DictationToggleSource source); + static void RecordUserToggleDictation(DictationToggleSource source); // Records an Ash owned user action. void RecordUserMetricsAction(UserMetricsAction action); diff --git a/ash/mojo_interface_factory.cc b/ash/mojo_interface_factory.cc index 2f9624eae0fd40..52e29c220e889e 100644 --- a/ash/mojo_interface_factory.cc +++ b/ash/mojo_interface_factory.cc @@ -6,7 +6,6 @@ #include -#include "ash/accessibility/accessibility_controller.h" #include "ash/app_list/app_list_controller_impl.h" #include "ash/assistant/assistant_alarm_timer_controller.h" #include "ash/assistant/assistant_controller.h" @@ -36,12 +35,6 @@ namespace { base::LazyInstance::Leaky g_register_interfaces_callback = LAZY_INSTANCE_INITIALIZER; -void BindAccessibilityControllerRequestOnMainThread( - mojom::AccessibilityControllerRequest request) { - if (Shell::HasInstance()) - Shell::Get()->accessibility_controller()->BindRequest(std::move(request)); -} - void BindAssistantAlarmTimerControllerRequestOnMainThread( mojom::AssistantAlarmTimerControllerRequest request) { if (Shell::HasInstance()) { @@ -120,9 +113,6 @@ void BindVpnListRequestOnMainThread(mojom::VpnListRequest request) { void RegisterInterfaces( service_manager::BinderRegistry* registry, scoped_refptr main_thread_task_runner) { - registry->AddInterface( - base::BindRepeating(&BindAccessibilityControllerRequestOnMainThread), - main_thread_task_runner); if (chromeos::switches::IsAssistantEnabled()) { registry->AddInterface( base::BindRepeating( diff --git a/ash/public/cpp/BUILD.gn b/ash/public/cpp/BUILD.gn index 04b66a1c7b46ae..07f587281529f0 100644 --- a/ash/public/cpp/BUILD.gn +++ b/ash/public/cpp/BUILD.gn @@ -9,6 +9,10 @@ component("cpp") { sources = [ "accelerators.cc", "accelerators.h", + "accessibility_controller.cc", + "accessibility_controller.h", + "accessibility_controller_client.h", + "accessibility_controller_enums.h", "accessibility_focus_ring_controller.cc", "accessibility_focus_ring_controller.h", "accessibility_focus_ring_info.cc", @@ -149,6 +153,7 @@ component("cpp") { "rounded_corner_decorator.h", "scale_utility.cc", "scale_utility.h", + "select_to_speak_event_handler_delegate.h", "session/session_activation_observer.h", "session/session_controller.cc", "session/session_controller.h", @@ -177,6 +182,7 @@ component("cpp") { "spoken_feedback_event_rewriter_delegate.h", "stylus_utils.cc", "stylus_utils.h", + "switch_access_event_handler_delegate.h", "system_tray.cc", "system_tray.h", "system_tray_client.h", diff --git a/ash/public/cpp/accessibility_controller.cc b/ash/public/cpp/accessibility_controller.cc new file mode 100644 index 00000000000000..81fd87be0fcab6 --- /dev/null +++ b/ash/public/cpp/accessibility_controller.cc @@ -0,0 +1,29 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/public/cpp/accessibility_controller.h" + +#include "base/logging.h" + +namespace ash { + +namespace { +AccessibilityController* g_instance = nullptr; +} + +AccessibilityController* AccessibilityController::Get() { + return g_instance; +} + +AccessibilityController::AccessibilityController() { + DCHECK_EQ(nullptr, g_instance); + g_instance = this; +} + +AccessibilityController::~AccessibilityController() { + DCHECK_EQ(this, g_instance); + g_instance = nullptr; +} + +} // namespace ash diff --git a/ash/public/cpp/accessibility_controller.h b/ash/public/cpp/accessibility_controller.h new file mode 100644 index 00000000000000..9812d46d488e68 --- /dev/null +++ b/ash/public/cpp/accessibility_controller.h @@ -0,0 +1,108 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_PUBLIC_CPP_ACCESSIBILITY_CONTROLLER_H_ +#define ASH_PUBLIC_CPP_ACCESSIBILITY_CONTROLLER_H_ + +#include + +#include "ash/public/cpp/ash_public_export.h" +#include "base/macros.h" +#include "base/strings/string16.h" + +namespace gfx { +class Rect; +} // namespace gfx + +namespace ash { + +class AccessibilityControllerClient; +enum class AccessibilityPanelState; +enum class DictationToggleSource; +class SelectToSpeakEventHandlerDelegate; +enum class SelectToSpeakState; +class SwitchAccessEventHandlerDelegate; + +// Interface for ash client (e.g. Chrome) to control and query accessibility +// features. +class ASH_PUBLIC_EXPORT AccessibilityController { + public: + static AccessibilityController* Get(); + + // Sets the client interface. + virtual void SetClient(AccessibilityControllerClient* client) = 0; + + // Starts or stops darkening the screen (e.g. to allow chrome a11y extensions + // to darken the screen). + virtual void SetDarkenScreen(bool darken) = 0; + + // Called when braille display state is changed. + virtual void BrailleDisplayStateChanged(bool connected) = 0; + + // Sets the focus highlight rect using |bounds_in_screen|. Called when focus + // changed in page and a11y focus highlight feature is enabled. + virtual void SetFocusHighlightRect(const gfx::Rect& bounds_in_screen) = 0; + + // Sets the text input caret bounds used to draw the caret highlight effect. + // For effciency, only sent when the caret highlight feature is enabled. + // Setting off-screen or empty bounds suppresses the highlight. + virtual void SetCaretBounds(const gfx::Rect& bounds_in_screen) = 0; + + // Sets whether the accessibility panel should always be visible, regardless + // of whether the window is fullscreen. + virtual void SetAccessibilityPanelAlwaysVisible(bool always_visible) = 0; + + // Sets the bounds for the accessibility panel. Overrides current + // configuration (i.e. fullscreen, full-width). + virtual void SetAccessibilityPanelBounds(const gfx::Rect& bounds, + AccessibilityPanelState state) = 0; + + // Sets the current Select-to-Speak state. This should be used by the Select- + // to-Speak extension to inform ash of its updated state. + virtual void SetSelectToSpeakState(SelectToSpeakState state) = 0; + + // Set the delegate used by the Select-to-Speak event handler. + virtual void SetSelectToSpeakEventHandlerDelegate( + SelectToSpeakEventHandlerDelegate* delegate) = 0; + + // Sets the key codes that Switch Access should capture. + virtual void SetSwitchAccessKeysToCapture( + const std::vector& keys_to_capture) = 0; + + // Set the delegate used by the Switch Access event handler. + virtual void SetSwitchAccessEventHandlerDelegate( + SwitchAccessEventHandlerDelegate* delegate) = 0; + + // Set whether dictation is active. + virtual void SetDictationActive(bool is_active) = 0; + + // Starts or stops dictation. Records metrics for toggling via SwitchAccess. + virtual void ToggleDictationFromSource(DictationToggleSource source) = 0; + + // Tells the Switch Access Event Handler whether to forward all key events to + // the Switch Access extension. + virtual void ForwardKeyEventsToSwitchAccess(bool should_forward) = 0; + + // Retrieves a string description of the current battery status. + virtual base::string16 GetBatteryDescription() const = 0; + + // Shows or hides the virtual keyboard. + virtual void SetVirtualKeyboardVisible(bool is_visible) = 0; + + // Notify observers that the accessibility status has changed. This is part of + // the public interface because a11y features like screen magnifier are + // managed outside of this accessibility controller. + virtual void NotifyAccessibilityStatusChanged() = 0; + + protected: + AccessibilityController(); + virtual ~AccessibilityController(); + + private: + DISALLOW_COPY_AND_ASSIGN(AccessibilityController); +}; + +} // namespace ash + +#endif // ASH_PUBLIC_CPP_ACCESSIBILITY_CONTROLLER_H_ \ No newline at end of file diff --git a/ash/public/cpp/accessibility_controller_client.h b/ash/public/cpp/accessibility_controller_client.h new file mode 100644 index 00000000000000..2931489bd36e07 --- /dev/null +++ b/ash/public/cpp/accessibility_controller_client.h @@ -0,0 +1,73 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_PUBLIC_CPP_ACCESSIBILITY_CONTROLLER_CLIENT_H_ +#define ASH_PUBLIC_CPP_ACCESSIBILITY_CONTROLLER_CLIENT_H_ + +#include "ash/public/cpp/ash_public_export.h" +#include "base/time/time.h" + +namespace ax { +namespace mojom { +enum class Gesture; +} // namespace mojom +} // namespace ax + +namespace ash { + +enum class AccessibilityAlert; + +// Interface for Ash to request accessibility service from its client, Chrome. +class ASH_PUBLIC_EXPORT AccessibilityControllerClient { + public: + // Triggers an accessibility alert to give the user feedback. + virtual void TriggerAccessibilityAlert(AccessibilityAlert alert) = 0; + + // Plays an earcon. Earcons are brief and distinctive sounds that indicate + // that their mapped event has occurred. The |sound_key| enums can be found in + // chromeos/audio/chromeos_sounds.h. This method exists because the browser + // owns all media playback. + virtual void PlayEarcon(int sound_key) = 0; + + // Initiates play of shutdown sound and returns sound duration. This method + // exists because the browser owns all media playback. + virtual base::TimeDelta PlayShutdownSound() = 0; + + // Forwards an accessibility gesture from the touch exploration controller to + // ChromeVox. + virtual void HandleAccessibilityGesture(ax::mojom::Gesture gesture) = 0; + + // Starts or stops dictation (type what you speak). + // Returns the new dictation state after the toggle. + virtual bool ToggleDictation() = 0; + + // Cancels all current and queued speech immediately. + virtual void SilenceSpokenFeedback() = 0; + + // Called when we first detect two fingers are held down, which can be used to + // toggle spoken feedback on some touch-only devices. + virtual void OnTwoFingerTouchStart() = 0; + + // Called when the user is no longer holding down two fingers (including + // releasing one, holding down three, or moving them). + virtual void OnTwoFingerTouchStop() = 0; + + // Whether or not to enable toggling spoken feedback via holding down two + // fingers on the screen. + virtual bool ShouldToggleSpokenFeedbackViaTouch() const = 0; + + // Plays tick sound indicating spoken feedback will be toggled after + // countdown. + virtual void PlaySpokenFeedbackToggleCountdown(int tick_count) = 0; + + // Requests the Select-to-Speak extension to change its state. This lets users + // do the same things in tablet mode as with a keyboard. Specifically, if + // Select-to-Speak is not speaking, move to capturing state; if + // Select-to-Speak is speaking, cancel speaking and move to inactive state. + virtual void RequestSelectToSpeakStateChange() = 0; +}; + +} // namespace ash + +#endif // ASH_PUBLIC_CPP_ACCESSIBILITY_CONTROLLER_CLIENT_H_ \ No newline at end of file diff --git a/ash/public/interfaces/accessibility_controller_enums.mojom b/ash/public/cpp/accessibility_controller_enums.h similarity index 87% rename from ash/public/interfaces/accessibility_controller_enums.mojom rename to ash/public/cpp/accessibility_controller_enums.h index f495a36194d213..2d9c7b8cd484b4 100644 --- a/ash/public/interfaces/accessibility_controller_enums.mojom +++ b/ash/public/cpp/accessibility_controller_enums.h @@ -2,10 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -module ash.mojom; +#ifndef ASH_PUBLIC_CPP_ACCESSIBILITY_CONTROLLER_ENUMS_H_ +#define ASH_PUBLIC_CPP_ACCESSIBILITY_CONTROLLER_ENUMS_H_ + +namespace ash { // Alert sent to the accessibility api. -enum AccessibilityAlert { +enum class AccessibilityAlert { // Default value, indicates no accessibility alert. NONE, @@ -39,7 +42,7 @@ enum AccessibilityAlert { WORKSPACE_FULLSCREEN_STATE_EXITED }; -enum AccessibilityPanelState { +enum class AccessibilityPanelState { // Window bounds are set explicitly. BOUNDED, @@ -52,7 +55,7 @@ enum AccessibilityPanelState { // These values are persisted to logs and should not be renumbered or re-used. // See tools/metrics/histograms/enums.xml. -enum DictationToggleSource { +enum class DictationToggleSource { // Toggled by the keyboard command (Search + D). kKeyboard, @@ -63,10 +66,12 @@ enum DictationToggleSource { kSwitchAccess, // Chromevox chrome extension. - kChromevox + kChromevox, + + kMaxValue = kChromevox }; -enum SelectToSpeakState { +enum class SelectToSpeakState { // Select to Speak is not actively selecting text or speaking. kSelectToSpeakStateInactive, @@ -78,7 +83,7 @@ enum SelectToSpeakState { kSelectToSpeakStateSpeaking, }; -enum SwitchAccessCommand { +enum class SwitchAccessCommand { // Do not perform a command. kNone, // Command to select the focused element. @@ -93,7 +98,7 @@ enum SwitchAccessCommand { // dwelling. These values are written to prefs and correspond to // AutoclickActionType in enums.xml, so should not be changed. New values // should be added at the end. -enum AutoclickEventType { +enum class AutoclickEventType { // Perform a left click. kLeftClick = 0, @@ -113,12 +118,14 @@ enum AutoclickEventType { // A mousewheel scroll action. An additional menu will be shown for the user // to pick whether they want to scroll up/down/left/right. kScroll = 5, + + kMaxValue = kScroll }; // The Automatic Clicks feature's on-screen menu display location. These values // are written to prefs so they should not be changed. New values should be // added at the end. -enum AutoclickMenuPosition { +enum class AutoclickMenuPosition { // The bottom right of the screen. kBottomRight, @@ -136,3 +143,7 @@ enum AutoclickMenuPosition { // a position it will no longer change with language direction. kSystemDefault, }; + +} // namespace ash + +#endif // ASH_PUBLIC_CPP_ACCESSIBILITY_CONTROLLER_ENUMS_H_ diff --git a/ash/public/cpp/ash_constants.h b/ash/public/cpp/ash_constants.h index 0fcba907096865..5d84972b89f9e9 100644 --- a/ash/public/cpp/ash_constants.h +++ b/ash/public/cpp/ash_constants.h @@ -5,7 +5,8 @@ #ifndef ASH_PUBLIC_CPP_ASH_CONSTANTS_H_ #define ASH_PUBLIC_CPP_ASH_CONSTANTS_H_ -#include "ash/public/interfaces/accessibility_controller_enums.mojom.h" +#include "ash/public/cpp/accessibility_controller_enums.h" +#include "base/time/time.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/color_palette.h" @@ -49,16 +50,16 @@ constexpr base::TimeDelta kDefaultSwitchAccessAutoScanSpeed = // The default wait time between last mouse movement and sending autoclick. constexpr int kDefaultAutoclickDelayMs = 1000; -constexpr mojom::AutoclickEventType kDefaultAutoclickEventType = - mojom::AutoclickEventType::kLeftClick; +constexpr AutoclickEventType kDefaultAutoclickEventType = + AutoclickEventType::kLeftClick; // The default threshold of mouse movement, measured in DIP, that will initiate // a new autoclick. constexpr int kDefaultAutoclickMovementThreshold = 20; // The default automatic click menu position. -constexpr mojom::AutoclickMenuPosition kDefaultAutoclickMenuPosition = - mojom::AutoclickMenuPosition::kSystemDefault; +constexpr AutoclickMenuPosition kDefaultAutoclickMenuPosition = + AutoclickMenuPosition::kSystemDefault; // The default frame color. constexpr SkColor kDefaultFrameColor = SkColorSetRGB(0xFD, 0xFE, 0xFF); diff --git a/ash/public/cpp/ash_pref_names.cc b/ash/public/cpp/ash_pref_names.cc index cf3bfbd0ad3da3..bb761721ac1eb7 100644 --- a/ash/public/cpp/ash_pref_names.cc +++ b/ash/public/cpp/ash_pref_names.cc @@ -65,7 +65,7 @@ const char kAccessibilityAutoclickStabilizePosition[] = // a new autoclick. const char kAccessibilityAutoclickMovementThreshold[] = "settings.a11y.autoclick_movement_threshold"; -// The Autoclick menu position on the screen, an mojom::AutoclickMenuPosition. +// The Autoclick menu position on the screen, an AutoclickMenuPosition. const char kAccessibilityAutoclickMenuPosition[] = "settings.a11y.autoclick_menu_position"; // A boolean pref which determines whether caret highlighting is enabled. diff --git a/ash/public/cpp/manifest.cc b/ash/public/cpp/manifest.cc index 8d1fd86b1efa26..9a68fb2259713d 100644 --- a/ash/public/cpp/manifest.cc +++ b/ash/public/cpp/manifest.cc @@ -4,7 +4,6 @@ #include "ash/public/cpp/manifest.h" -#include "ash/public/interfaces/accessibility_controller.mojom.h" #include "ash/public/interfaces/assistant_controller.mojom.h" #include "ash/public/interfaces/assistant_volume_control.mojom.h" #include "ash/public/interfaces/constants.mojom.h" @@ -45,7 +44,6 @@ const service_manager::Manifest& GetManifest() { .ExposeCapability( "system_ui", service_manager::Manifest::InterfaceList< - mojom::AccessibilityController, mojom::AssistantAlarmTimerController, mojom::AssistantController, mojom::AssistantNotificationController, diff --git a/ash/public/cpp/select_to_speak_event_handler_delegate.h b/ash/public/cpp/select_to_speak_event_handler_delegate.h new file mode 100644 index 00000000000000..51a4300b3028aa --- /dev/null +++ b/ash/public/cpp/select_to_speak_event_handler_delegate.h @@ -0,0 +1,33 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_PUBLIC_CPP_SELECT_TO_SPEAK_EVENT_HANDLER_DELEGATE_H_ +#define ASH_PUBLIC_CPP_SELECT_TO_SPEAK_EVENT_HANDLER_DELEGATE_H_ + +#include + +#include "ash/public/cpp/ash_public_export.h" + +namespace ui { +class KeyEvent; +class MouseEvent; +} // namespace ui + +namespace ash { + +// Allows a client to implement Select-to-Speak. +// TODO(katie): Consider combining DispatchMouseEvent and DispatchKeyEvent +// into a single DispatchEvent function. +class ASH_PUBLIC_EXPORT SelectToSpeakEventHandlerDelegate { + public: + // Sends a KeyEvent to the Select-to-Speak extension in Chrome. + virtual void DispatchKeyEvent(const ui::KeyEvent& event) = 0; + + // Sends a MouseEvent to the Select-to-Speak extension in Chrome. + virtual void DispatchMouseEvent(const ui::MouseEvent& event) = 0; +}; + +} // namespace ash + +#endif // ASH_PUBLIC_CPP_SELECT_TO_SPEAK_EVENT_HANDLER_DELEGATE_H_ \ No newline at end of file diff --git a/ash/public/cpp/switch_access_event_handler_delegate.h b/ash/public/cpp/switch_access_event_handler_delegate.h new file mode 100644 index 00000000000000..6571b627acedfa --- /dev/null +++ b/ash/public/cpp/switch_access_event_handler_delegate.h @@ -0,0 +1,34 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_PUBLIC_CPP_SWITCH_ACCESS_EVENT_HANDLER_DELEGATE_H_ +#define ASH_PUBLIC_CPP_SWITCH_ACCESS_EVENT_HANDLER_DELEGATE_H_ + +#include + +#include "ash/public/cpp/ash_public_export.h" + +namespace ui { +class KeyEvent; +} + +namespace ash { + +enum class SwitchAccessCommand; + +// Allows a client to implement Switch Access. +class ASH_PUBLIC_EXPORT SwitchAccessEventHandlerDelegate { + public: + // Sends a KeyEvent to the Switch Access extension in Chrome. + // TODO(anastasi): Remove once settings migration is complete. + virtual void DispatchKeyEvent(const ui::KeyEvent& event) = 0; + + // Sends a command to Switch Access, based on what key was pressed and the + // user's settings. + virtual void SendSwitchAccessCommand(SwitchAccessCommand command) = 0; +}; + +} // namespace ash + +#endif // ASH_PUBLIC_CPP_SWITCH_ACCESS_EVENT_HANDLER_DELEGATE_H_ \ No newline at end of file diff --git a/ash/public/interfaces/BUILD.gn b/ash/public/interfaces/BUILD.gn index 8b8556e362e19d..5de5b570a692f9 100644 --- a/ash/public/interfaces/BUILD.gn +++ b/ash/public/interfaces/BUILD.gn @@ -8,8 +8,6 @@ mojom("interfaces") { disable_variants = true sources = [ - "accessibility_controller.mojom", - "accessibility_controller_enums.mojom", "assistant_controller.mojom", "assistant_volume_control.mojom", "constants.mojom", @@ -31,11 +29,9 @@ mojom("interfaces") { "//services/content/public/mojom", "//services/preferences/public/mojom", "//skia/public/interfaces", - "//ui/accessibility:ax_enums_mojo", "//ui/base/ime/chromeos/public/interfaces", "//ui/base/mojo", "//ui/display/mojo:interfaces", - "//ui/events/mojo:interfaces", "//ui/gfx/geometry/mojo", "//ui/gfx/image/mojo:interfaces", "//ui/gfx/range/mojo", diff --git a/ash/public/interfaces/accessibility_controller.mojom b/ash/public/interfaces/accessibility_controller.mojom deleted file mode 100644 index 699d655e6bd5e8..00000000000000 --- a/ash/public/interfaces/accessibility_controller.mojom +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -module ash.mojom; - -import "ash/public/interfaces/accessibility_controller_enums.mojom"; -import "mojo/public/mojom/base/string16.mojom"; -import "mojo/public/mojom/base/time.mojom"; -import "ui/accessibility/ax_enums.mojom"; -import "ui/events/mojo/event.mojom"; -import "ui/gfx/geometry/mojo/geometry.mojom"; - -// Allows a client to implement Select-to-Speak. -// TODO(katie): Consider combining DispatchMouseEvent and DispatchKeyEvent -// into a single DispatchEvent function. -interface SelectToSpeakEventHandlerDelegate { - // Sends a KeyEvent to the Select-to-Speak extension in Chrome. The event - // is cast to a key event with a type CHECK. - DispatchKeyEvent(ui.mojom.Event event); - - // Sends a MouseEvent to the Select-to-Speak extension in Chrome. The event - // is cast to a mouse event with a type CHECK. - DispatchMouseEvent(ui.mojom.Event event); -}; - -// Allows a client to implement Switch Access. -interface SwitchAccessEventHandlerDelegate { - // Sends a KeyEvent to the Switch Access extension in Chrome. The event - // is cast to a key event with a type CHECK. - // TODO(anastasi): Remove once settings migration is complete. - DispatchKeyEvent(ui.mojom.Event event); - - // Sends a command to Switch Access, based on what key was pressed and the - // user's settings. - SendSwitchAccessCommand(SwitchAccessCommand command); -}; - -// Interface for ash client (e.g. Chrome) to control and query accessibility -// features. -interface AccessibilityController { - // Sets the client interface. - SetClient(AccessibilityControllerClient client); - - // Starts or stops darkening the screen (e.g. to allow chrome a11y extensions - // to darken the screen). - SetDarkenScreen(bool darken); - - // Called when braille display state is changed. - BrailleDisplayStateChanged(bool connected); - - // Sets the focus highlight rect using |bounds_in_screen|. Called when focus - // changed in page and a11y focus highlight feature is enabled. - SetFocusHighlightRect(gfx.mojom.Rect bounds_in_screen); - - // Sets the text input caret bounds used to draw the caret highlight effect. - // For effciency, only sent when the caret highlight feature is enabled. - // Setting off-screen or empty bounds suppresses the highlight. - SetCaretBounds(gfx.mojom.Rect bounds_in_screen); - - // Sets whether the accessibility panel should always be visible, regardless - // of whether the window is fullscreen. - SetAccessibilityPanelAlwaysVisible(bool always_visible); - - // Sets the bounds for the accessibility panel. Overrides current - // configuration (i.e. fullscreen, full-width). - SetAccessibilityPanelBounds(gfx.mojom.Rect bounds, - AccessibilityPanelState state); - - // Sets the current Select-to-Speak state. This should be used by the Select- - // to-Speak extension to inform ash of its updated state. - SetSelectToSpeakState(SelectToSpeakState state); - - // Set the delegate used by the Select-to-Speak event handler. - SetSelectToSpeakEventHandlerDelegate( - SelectToSpeakEventHandlerDelegate delegate); - - // Sets the key codes that Switch Access should capture. - SetSwitchAccessKeysToCapture(array keys_to_capture); - - // Set the delegate used by the Switch Access event handler. - SetSwitchAccessEventHandlerDelegate( - SwitchAccessEventHandlerDelegate delegate); - - // Starts or stops dictation. Records metrics for toggling via SwitchAccess. - ToggleDictationFromSource(DictationToggleSource source); - - // Tells the Switch Access Event Handler whether to forward all key events to - // the Switch Access extension. - ForwardKeyEventsToSwitchAccess(bool should_forward); - - // Retrieves a string description of the current battery status. - GetBatteryDescription() - => (mojo_base.mojom.String16 battery_description); - - // Shows or hides the virtual keyboard. - SetVirtualKeyboardVisible(bool is_visible); -}; - -// Interface for ash to request accessibility service from its client (e.g. -// Chrome). -interface AccessibilityControllerClient { - // Triggers an accessibility alert to give the user feedback. - TriggerAccessibilityAlert(AccessibilityAlert alert); - - // Plays an earcon. Earcons are brief and distinctive sounds that indicate - // that their mapped event has occurred. The |sound_key| enums can be found in - // chromeos/audio/chromeos_sounds.h. This method exists because the browser - // owns all media playback. - PlayEarcon(int32 sound_key); - - // Initiates play of shutdown sound and returns sound duration. This method - // exists because the browser owns all media playback. - PlayShutdownSound() => (mojo_base.mojom.TimeDelta sound_duration); - - // Forwards an accessibility gesture from the touch exploration controller to - // ChromeVox. - HandleAccessibilityGesture(ax.mojom.Gesture gesture); - - // Starts or stops dictation (type what you speak). - // Returns the new dictation state after the toggle. - ToggleDictation() => (bool dictation_on); - - // Cancels all current and queued speech immediately. - SilenceSpokenFeedback(); - - // Called when we first detect two fingers are held down, which can be used to - // toggle spoken feedback on some touch-only devices. - OnTwoFingerTouchStart(); - - // Called when the user is no longer holding down two fingers (including - // releasing one, holding down three, or moving them). - OnTwoFingerTouchStop(); - - // Whether or not to enable toggling spoken feedback via holding down two - // fingers on the screen. - ShouldToggleSpokenFeedbackViaTouch() => (bool should_toggle); - - // Plays tick sound indicating spoken feedback will be toggled after - // countdown. - PlaySpokenFeedbackToggleCountdown(int32 tick_count); - - // Requests the Select-to-Speak extension to change its state. This lets users - // do the same things in tablet mode as with a keyboard. Specifically, if - // Select-to-Speak is not speaking, move to capturing state; if - // Select-to-Speak is speaking, cancel speaking and move to inactive state. - RequestSelectToSpeakStateChange(); -}; diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc index 07625b5d8ec744..be0961ced399c1 100644 --- a/ash/shelf/shelf_layout_manager.cc +++ b/ash/shelf/shelf_layout_manager.cc @@ -8,7 +8,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/animation/animation_change_type.h" #include "ash/app_list/app_list_controller_impl.h" #include "ash/app_list/app_list_metrics.h" @@ -1876,13 +1876,13 @@ void ShelfLayoutManager::SendA11yAlertForFullscreenWorkspaceState( current_workspace_window_state == wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN) { Shell::Get()->accessibility_controller()->TriggerAccessibilityAlert( - mojom::AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_ENTERED); + AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_ENTERED); } else if (previous_workspace_window_state_ == wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN && current_workspace_window_state != wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN) { Shell::Get()->accessibility_controller()->TriggerAccessibilityAlert( - mojom::AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_EXITED); + AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_EXITED); } previous_workspace_window_state_ = current_workspace_window_state; } diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc index fd1d8a91527e3b..4b1cd0d3e5f4a3 100644 --- a/ash/shelf/shelf_layout_manager_unittest.cc +++ b/ash/shelf/shelf_layout_manager_unittest.cc @@ -9,7 +9,6 @@ #include "ash/accelerators/accelerator_controller_impl.h" #include "ash/accelerators/accelerator_table.h" -#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/test_accessibility_controller_client.h" #include "ash/app_list/app_list_controller_impl.h" #include "ash/app_list/test/app_list_test_helper.h" @@ -3038,14 +3037,11 @@ TEST_F(ShelfLayoutManagerTest, TapShelfItemInAutoHideShelf) { // Tests the a11y feedback for entering/exiting fullscreen workspace state. TEST_F(ShelfLayoutManagerTest, A11yAlertOnWorkspaceState) { TestAccessibilityControllerClient client; - AccessibilityController* controller = - Shell::Get()->accessibility_controller(); - controller->SetClient(client.CreateInterfacePtrAndBind()); std::unique_ptr window1( AshTestBase::CreateToplevelTestWindow()); std::unique_ptr window2( AshTestBase::CreateToplevelTestWindow()); - EXPECT_NE(mojom::AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_ENTERED, + EXPECT_NE(AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_ENTERED, client.last_a11y_alert()); // Toggle the current normal window in workspace to fullscreen should send the @@ -3053,38 +3049,33 @@ TEST_F(ShelfLayoutManagerTest, A11yAlertOnWorkspaceState) { const wm::WMEvent fullscreen(wm::WM_EVENT_TOGGLE_FULLSCREEN); wm::WindowState* window_state2 = wm::GetWindowState(window2.get()); window_state2->OnWMEvent(&fullscreen); - controller->FlushMojoForTest(); EXPECT_TRUE(window_state2->IsFullscreen()); - EXPECT_EQ(mojom::AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_ENTERED, + EXPECT_EQ(AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_ENTERED, client.last_a11y_alert()); // Toggle the current fullscreen'ed window in workspace to exit fullscreen // should send the EXITED alert. window_state2->OnWMEvent(&fullscreen); - controller->FlushMojoForTest(); EXPECT_FALSE(window_state2->IsFullscreen()); - EXPECT_EQ(mojom::AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_EXITED, + EXPECT_EQ(AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_EXITED, client.last_a11y_alert()); // Fullscreen the |window2| again to prepare for the following tests. window_state2->OnWMEvent(&fullscreen); - controller->FlushMojoForTest(); EXPECT_TRUE(window_state2->IsFullscreen()); - EXPECT_EQ(mojom::AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_ENTERED, + EXPECT_EQ(AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_ENTERED, client.last_a11y_alert()); // Changes the current window in workspace from a fullscreen window to a // normal window should send the EXITD alert. window_state2->Minimize(); - controller->FlushMojoForTest(); - EXPECT_EQ(mojom::AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_EXITED, + EXPECT_EQ(AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_EXITED, client.last_a11y_alert()); // Changes the current window in workspace from a normal window to fullscreen // window should send ENTERED alert. window_state2->Unminimize(); EXPECT_TRUE(window_state2->IsFullscreen()); - controller->FlushMojoForTest(); - EXPECT_EQ(mojom::AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_ENTERED, + EXPECT_EQ(AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_ENTERED, client.last_a11y_alert()); } diff --git a/ash/shell.cc b/ash/shell.cc index 22c17579009e68..9add2d3ede7d06 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -15,7 +15,7 @@ #include "ash/accelerators/pre_target_accelerator_handler.h" #include "ash/accelerators/spoken_feedback_toggler.h" #include "ash/accelerometer/accelerometer_reader.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/accessibility/accessibility_delegate.h" #include "ash/accessibility/accessibility_focus_ring_controller_impl.h" #include "ash/accessibility/key_accessibility_enabler.h" @@ -899,7 +899,7 @@ void Shell::Init( accessibility_focus_ring_controller_ = std::make_unique(); accessibility_delegate_.reset(shell_delegate_->CreateAccessibilityDelegate()); - accessibility_controller_ = std::make_unique(); + accessibility_controller_ = std::make_unique(); toast_manager_ = std::make_unique(); // Accelerometer file reader starts listening to tablet mode controller. diff --git a/ash/shell.h b/ash/shell.h index 6e1eceae359726..454cc8ff841132 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -88,7 +88,7 @@ class WindowModalityController; namespace ash { class AcceleratorControllerImpl; -class AccessibilityController; +class AccessibilityControllerImpl; class AccessibilityDelegate; class AccessibilityFocusRingControllerImpl; class AshDBusHelper; @@ -296,7 +296,7 @@ class ASH_EXPORT Shell : public SessionObserver, AcceleratorControllerImpl* accelerator_controller() { return accelerator_controller_.get(); } - AccessibilityController* accessibility_controller() { + AccessibilityControllerImpl* accessibility_controller() { return accessibility_controller_.get(); } AccessibilityDelegate* accessibility_delegate() { @@ -637,7 +637,7 @@ class ASH_EXPORT Shell : public SessionObserver, std::unique_ptr window_positioner_; std::unique_ptr accelerator_controller_; - std::unique_ptr accessibility_controller_; + std::unique_ptr accessibility_controller_; std::unique_ptr accessibility_delegate_; std::unique_ptr accessibility_focus_ring_controller_; diff --git a/ash/system/accessibility/autoclick_menu_bubble_controller.cc b/ash/system/accessibility/autoclick_menu_bubble_controller.cc index d95edba6d78a48..3eee0b6ae943ea 100644 --- a/ash/system/accessibility/autoclick_menu_bubble_controller.cc +++ b/ash/system/accessibility/autoclick_menu_bubble_controller.cc @@ -32,34 +32,34 @@ const int kAutoclickMenuWidth = 319; const int kAutoclickMenuWidthWithScroll = 369; const int kAutoclickMenuHeight = 64; -mojom::AutoclickMenuPosition DefaultSystemPosition() { - return base::i18n::IsRTL() ? mojom::AutoclickMenuPosition::kBottomLeft - : mojom::AutoclickMenuPosition::kBottomRight; +AutoclickMenuPosition DefaultSystemPosition() { + return base::i18n::IsRTL() ? AutoclickMenuPosition::kBottomLeft + : AutoclickMenuPosition::kBottomRight; } views::BubbleBorder::Arrow GetScrollAnchorAlignmentForPosition( - mojom::AutoclickMenuPosition position) { + AutoclickMenuPosition position) { // If this is the default system position, pick the position based on the // language direction. - if (position == mojom::AutoclickMenuPosition::kSystemDefault) { + if (position == AutoclickMenuPosition::kSystemDefault) { position = DefaultSystemPosition(); } // Mirror arrow in RTL languages so that it always stays near the screen // edge. switch (position) { - case mojom::AutoclickMenuPosition::kBottomLeft: + case AutoclickMenuPosition::kBottomLeft: return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::TOP_RIGHT : views::BubbleBorder::Arrow::TOP_LEFT; - case mojom::AutoclickMenuPosition::kTopLeft: + case AutoclickMenuPosition::kTopLeft: return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::BOTTOM_RIGHT : views::BubbleBorder::Arrow::BOTTOM_LEFT; - case mojom::AutoclickMenuPosition::kBottomRight: + case AutoclickMenuPosition::kBottomRight: return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::TOP_LEFT : views::BubbleBorder::Arrow::TOP_RIGHT; - case mojom::AutoclickMenuPosition::kTopRight: + case AutoclickMenuPosition::kTopRight: return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::BOTTOM_LEFT : views::BubbleBorder::Arrow::BOTTOM_RIGHT; - case mojom::AutoclickMenuPosition::kSystemDefault: + case AutoclickMenuPosition::kSystemDefault: // It's not possible for position to be kSystemDefault here because we've // set it via DefaultSystemPosition() above if it was kSystemDefault. NOTREACHED(); @@ -80,13 +80,11 @@ AutoclickMenuBubbleController::~AutoclickMenuBubbleController() { scroll_bubble_controller_.reset(); } -void AutoclickMenuBubbleController::SetEventType( - mojom::AutoclickEventType type) { - if (menu_view_) { +void AutoclickMenuBubbleController::SetEventType(AutoclickEventType type) { + if (menu_view_) menu_view_->UpdateEventType(type); - } - if (type == mojom::AutoclickEventType::kScroll) { + if (type == AutoclickEventType::kScroll) { // If the type is scroll, show the scroll bubble using the // scroll_bubble_controller_. if (!scroll_bubble_controller_) { @@ -107,23 +105,22 @@ void AutoclickMenuBubbleController::SetEventType( } void AutoclickMenuBubbleController::SetPosition( - mojom::AutoclickMenuPosition new_position) { + AutoclickMenuPosition new_position) { if (!menu_view_ || !bubble_view_ || !bubble_widget_) return; // Update the menu view's UX if the position has changed, or if it's not the // default position (because that can change with language direction). if (position_ != new_position || - new_position == mojom::AutoclickMenuPosition::kSystemDefault) { + new_position == AutoclickMenuPosition::kSystemDefault) { menu_view_->UpdatePosition(new_position); } position_ = new_position; // If this is the default system position, pick the position based on the // language direction. - if (new_position == mojom::AutoclickMenuPosition::kSystemDefault) { + if (new_position == AutoclickMenuPosition::kSystemDefault) new_position = DefaultSystemPosition(); - } // Calculates the ideal bounds. // TODO(katie): Support multiple displays: draw the menu on whichever display @@ -137,17 +134,17 @@ void AutoclickMenuBubbleController::SetPosition( : kAutoclickMenuWidth; gfx::Rect new_bounds; switch (new_position) { - case mojom::AutoclickMenuPosition::kBottomRight: + case AutoclickMenuPosition::kBottomRight: new_bounds = gfx::Rect(work_area.right() - width, work_area.bottom() - kAutoclickMenuHeight, width, kAutoclickMenuHeight); break; - case mojom::AutoclickMenuPosition::kBottomLeft: + case AutoclickMenuPosition::kBottomLeft: new_bounds = gfx::Rect(work_area.x(), work_area.bottom() - kAutoclickMenuHeight, width, kAutoclickMenuHeight); break; - case mojom::AutoclickMenuPosition::kTopLeft: + case AutoclickMenuPosition::kTopLeft: // Because there is no inset at the top of the widget, add // 2 * kCollisionWindowWorkAreaInsetsDp to the top of the work area. // to ensure correct padding. @@ -155,7 +152,7 @@ void AutoclickMenuBubbleController::SetPosition( work_area.x(), work_area.y() + 2 * kCollisionWindowWorkAreaInsetsDp, width, kAutoclickMenuHeight); break; - case mojom::AutoclickMenuPosition::kTopRight: + case AutoclickMenuPosition::kTopRight: // Because there is no inset at the top of the widget, add // 2 * kCollisionWindowWorkAreaInsetsDp to the top of the work area. // to ensure correct padding. @@ -164,7 +161,7 @@ void AutoclickMenuBubbleController::SetPosition( work_area.y() + 2 * kCollisionWindowWorkAreaInsetsDp, width, kAutoclickMenuHeight); break; - case mojom::AutoclickMenuPosition::kSystemDefault: + case AutoclickMenuPosition::kSystemDefault: return; } @@ -202,9 +199,8 @@ void AutoclickMenuBubbleController::SetScrollPoint( scroll_bubble_controller_->SetScrollPoint(scroll_location_in_dips); } -void AutoclickMenuBubbleController::ShowBubble( - mojom::AutoclickEventType type, - mojom::AutoclickMenuPosition position) { +void AutoclickMenuBubbleController::ShowBubble(AutoclickEventType type, + AutoclickMenuPosition position) { // Ignore if bubble widget already exists. if (bubble_widget_) return; @@ -330,7 +326,7 @@ void AutoclickMenuBubbleController::BubbleViewDestroyed() { void AutoclickMenuBubbleController::OnLocaleChanged() { // Layout update is needed when language changes between LTR and RTL, if the // position is the system default. - if (position_ == mojom::AutoclickMenuPosition::kSystemDefault) + if (position_ == AutoclickMenuPosition::kSystemDefault) SetPosition(position_); } diff --git a/ash/system/accessibility/autoclick_menu_bubble_controller.h b/ash/system/accessibility/autoclick_menu_bubble_controller.h index c667468b955440..ec3e904f0d49e1 100644 --- a/ash/system/accessibility/autoclick_menu_bubble_controller.h +++ b/ash/system/accessibility/autoclick_menu_bubble_controller.h @@ -24,16 +24,16 @@ class ASH_EXPORT AutoclickMenuBubbleController ~AutoclickMenuBubbleController() override; // Sets the currently selected event type. - void SetEventType(mojom::AutoclickEventType type); + void SetEventType(AutoclickEventType type); // Sets the menu's position on the screen. - void SetPosition(mojom::AutoclickMenuPosition position); + void SetPosition(AutoclickMenuPosition position); // Set the scroll menu's position on the screen. void SetScrollPoint(gfx::Point scroll_location_in_dips); - void ShowBubble(mojom::AutoclickEventType event_type, - mojom::AutoclickMenuPosition position); + void ShowBubble(AutoclickEventType event_type, + AutoclickMenuPosition position); void CloseBubble(); @@ -66,7 +66,7 @@ class ASH_EXPORT AutoclickMenuBubbleController // Owned by views hierarchy. AutoclickMenuBubbleView* bubble_view_ = nullptr; AutoclickMenuView* menu_view_ = nullptr; - mojom::AutoclickMenuPosition position_ = kDefaultAutoclickMenuPosition; + AutoclickMenuPosition position_ = kDefaultAutoclickMenuPosition; views::Widget* bubble_widget_ = nullptr; diff --git a/ash/system/accessibility/autoclick_menu_bubble_controller_unittest.cc b/ash/system/accessibility/autoclick_menu_bubble_controller_unittest.cc index 0e78f12525a645..ff7f6aac08ac7f 100644 --- a/ash/system/accessibility/autoclick_menu_bubble_controller_unittest.cc +++ b/ash/system/accessibility/autoclick_menu_bubble_controller_unittest.cc @@ -4,7 +4,7 @@ #include "ash/system/accessibility/autoclick_menu_bubble_controller.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/autoclick/autoclick_controller.h" #include "ash/shelf/shelf.h" #include "ash/shell.h" @@ -109,27 +109,24 @@ TEST_F(AutoclickMenuBubbleControllerTest, ExistsOnlyWhenAutoclickIsRunning) { } TEST_F(AutoclickMenuBubbleControllerTest, CanSelectAutoclickTypeFromBubble) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); // Set to a different event type than the first event in kTestCases. - controller->SetAutoclickEventType(mojom::AutoclickEventType::kRightClick); + controller->SetAutoclickEventType(AutoclickEventType::kRightClick); const struct { AutoclickMenuView::ButtonId view_id; - mojom::AutoclickEventType expected_event_type; + AutoclickEventType expected_event_type; } kTestCases[] = { - {AutoclickMenuView::ButtonId::kLeftClick, - mojom::AutoclickEventType::kLeftClick}, + {AutoclickMenuView::ButtonId::kLeftClick, AutoclickEventType::kLeftClick}, {AutoclickMenuView::ButtonId::kRightClick, - mojom::AutoclickEventType::kRightClick}, + AutoclickEventType::kRightClick}, {AutoclickMenuView::ButtonId::kDoubleClick, - mojom::AutoclickEventType::kDoubleClick}, + AutoclickEventType::kDoubleClick}, {AutoclickMenuView::ButtonId::kDragAndDrop, - mojom::AutoclickEventType::kDragAndDrop}, - {AutoclickMenuView::ButtonId::kScroll, - mojom::AutoclickEventType::kScroll}, - {AutoclickMenuView::ButtonId::kPause, - mojom::AutoclickEventType::kNoAction}, + AutoclickEventType::kDragAndDrop}, + {AutoclickMenuView::ButtonId::kScroll, AutoclickEventType::kScroll}, + {AutoclickMenuView::ButtonId::kPause, AutoclickEventType::kNoAction}, }; for (const auto& test : kTestCases) { @@ -147,20 +144,18 @@ TEST_F(AutoclickMenuBubbleControllerTest, CanSelectAutoclickTypeFromBubble) { } TEST_F(AutoclickMenuBubbleControllerTest, UnpausesWhenPauseAlreadySelected) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); views::View* pause_button = GetMenuButton(AutoclickMenuView::ButtonId::kPause); ui::GestureEvent event = CreateTapEvent(); const struct { - mojom::AutoclickEventType event_type; + AutoclickEventType event_type; } kTestCases[]{ - {mojom::AutoclickEventType::kRightClick}, - {mojom::AutoclickEventType::kLeftClick}, - {mojom::AutoclickEventType::kDoubleClick}, - {mojom::AutoclickEventType::kDragAndDrop}, - {mojom::AutoclickEventType::kScroll}, + {AutoclickEventType::kRightClick}, {AutoclickEventType::kLeftClick}, + {AutoclickEventType::kDoubleClick}, {AutoclickEventType::kDragAndDrop}, + {AutoclickEventType::kScroll}, }; for (const auto& test : kTestCases) { @@ -168,7 +163,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, UnpausesWhenPauseAlreadySelected) { // First tap pauses. pause_button->OnGestureEvent(&event); - EXPECT_EQ(mojom::AutoclickEventType::kNoAction, + EXPECT_EQ(AutoclickEventType::kNoAction, controller->GetAutoclickEventType()); // Second tap unpauses and reverts to previous state. @@ -178,11 +173,11 @@ TEST_F(AutoclickMenuBubbleControllerTest, UnpausesWhenPauseAlreadySelected) { } TEST_F(AutoclickMenuBubbleControllerTest, CanChangePosition) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); // Set to a known position for than the first event in kTestCases. - controller->SetAutoclickMenuPosition(mojom::AutoclickMenuPosition::kTopRight); + controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kTopRight); // Get the full root window bounds to test the position. gfx::Rect window_bounds = Shell::GetPrimaryRootWindow()->bounds(); @@ -190,15 +185,14 @@ TEST_F(AutoclickMenuBubbleControllerTest, CanChangePosition) { // Test cases rotate clockwise. const struct { gfx::Point expected_location; - mojom::AutoclickMenuPosition expected_position; + AutoclickMenuPosition expected_position; } kTestCases[] = { {gfx::Point(window_bounds.width(), window_bounds.height()), - mojom::AutoclickMenuPosition::kBottomRight}, + AutoclickMenuPosition::kBottomRight}, {gfx::Point(0, window_bounds.height()), - mojom::AutoclickMenuPosition::kBottomLeft}, - {gfx::Point(0, 0), mojom::AutoclickMenuPosition::kTopLeft}, - {gfx::Point(window_bounds.width(), 0), - mojom::AutoclickMenuPosition::kTopRight}, + AutoclickMenuPosition::kBottomLeft}, + {gfx::Point(0, 0), AutoclickMenuPosition::kTopLeft}, + {gfx::Point(window_bounds.width(), 0), AutoclickMenuPosition::kTopRight}, }; // Find the autoclick menu position button. @@ -224,7 +218,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, CanChangePosition) { } TEST_F(AutoclickMenuBubbleControllerTest, DefaultChangesWithTextDirection) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); gfx::Rect window_bounds = Shell::GetPrimaryRootWindow()->bounds(); @@ -246,14 +240,14 @@ TEST_F(AutoclickMenuBubbleControllerTest, DefaultChangesWithTextDirection) { } TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleShowsAndCloses) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); - controller->SetAutoclickEventType(mojom::AutoclickEventType::kLeftClick); + controller->SetAutoclickEventType(AutoclickEventType::kLeftClick); // No scroll view yet. EXPECT_FALSE(GetScrollView()); // Scroll type should cause the scroll view to be shown. - controller->SetAutoclickEventType(mojom::AutoclickEventType::kScroll); + controller->SetAutoclickEventType(AutoclickEventType::kScroll); EXPECT_TRUE(GetScrollView()); // Clicking the scroll close button resets to left click. @@ -262,14 +256,14 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleShowsAndCloses) { ui::GestureEvent event = CreateTapEvent(); close_button->OnGestureEvent(&event); EXPECT_FALSE(GetScrollView()); - EXPECT_EQ(mojom::AutoclickEventType::kLeftClick, + EXPECT_EQ(AutoclickEventType::kLeftClick, controller->GetAutoclickEventType()); } TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); - controller->SetAutoclickEventType(mojom::AutoclickEventType::kScroll); + controller->SetAutoclickEventType(AutoclickEventType::kScroll); const struct { bool is_RTL; } kTestCases[] = {{true}, {false}}; for (auto& test : kTestCases) { @@ -279,8 +273,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) { // When the menu is in the top right, the scroll view should be directly // under it and along the right side of the screen. - controller->SetAutoclickMenuPosition( - mojom::AutoclickMenuPosition::kTopRight); + controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kTopRight); EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint( GetMenuViewBounds().bottom_center()), kMenuViewBoundsBuffer); @@ -288,8 +281,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) { // When the menu is in the bottom right, the scroll view is directly above // it and along the right side of the screen. - controller->SetAutoclickMenuPosition( - mojom::AutoclickMenuPosition::kBottomRight); + controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kBottomRight); EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint( GetMenuViewBounds().top_center()), kMenuViewBoundsBuffer); @@ -297,8 +289,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) { // When the menu is on the bottom left, the scroll view is directly above it // and along the left side of the screen. - controller->SetAutoclickMenuPosition( - mojom::AutoclickMenuPosition::kBottomLeft); + controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kBottomLeft); EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint( GetMenuViewBounds().top_center()), kMenuViewBoundsBuffer); @@ -306,8 +297,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) { // When the menu is on the top left, the scroll view is directly below it // and along the left side of the screen. - controller->SetAutoclickMenuPosition( - mojom::AutoclickMenuPosition::kTopLeft); + controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kTopLeft); EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint( GetMenuViewBounds().bottom_center()), kMenuViewBoundsBuffer); @@ -317,15 +307,14 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) { TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleManualPositioning) { UpdateDisplay("1000x800"); - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); - controller->SetAutoclickEventType(mojom::AutoclickEventType::kScroll); + controller->SetAutoclickEventType(AutoclickEventType::kScroll); const struct { bool is_RTL; } kTestCases[] = {{true}, {false}}; for (auto& test : kTestCases) { base::i18n::SetRTLForTesting(test.is_RTL); - controller->SetAutoclickMenuPosition( - mojom::AutoclickMenuPosition::kTopRight); + controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kTopRight); // Start with a point no where near the autoclick menu. gfx::Point point = gfx::Point(400, 400); @@ -347,8 +336,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleManualPositioning) { // Moving the autoclick bubble doesn't impact the scroll bubble once it // has been manually set. gfx::Rect scroll_bounds = GetScrollViewBounds(); - controller->SetAutoclickMenuPosition( - mojom::AutoclickMenuPosition::kBottomRight); + controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kBottomRight); EXPECT_EQ(scroll_bounds, GetScrollViewBounds()); // If we position it by the edge of the screen, it should stay on-screen, diff --git a/ash/system/accessibility/autoclick_menu_view.cc b/ash/system/accessibility/autoclick_menu_view.cc index 29e11ea590518d..998d914cbcced6 100644 --- a/ash/system/accessibility/autoclick_menu_view.cc +++ b/ash/system/accessibility/autoclick_menu_view.cc @@ -4,7 +4,7 @@ #include "ash/system/accessibility/autoclick_menu_view.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/shell.h" #include "ash/strings/grit/ash_strings.h" @@ -155,8 +155,8 @@ const char* AutoclickMenuBubbleView::GetClassName() const { // ------ AutoclickMenuView ------ // -AutoclickMenuView::AutoclickMenuView(mojom::AutoclickEventType type, - mojom::AutoclickMenuPosition position) +AutoclickMenuView::AutoclickMenuView(AutoclickEventType type, + AutoclickMenuPosition position) : left_click_button_( new AutoclickMenuButton(this, kAutoclickLeftClickIcon, @@ -242,35 +242,33 @@ AutoclickMenuView::AutoclickMenuView(mojom::AutoclickEventType type, UpdatePosition(position); } -void AutoclickMenuView::UpdateEventType(mojom::AutoclickEventType type) { - left_click_button_->SetToggled(type == mojom::AutoclickEventType::kLeftClick); - right_click_button_->SetToggled(type == - mojom::AutoclickEventType::kRightClick); - double_click_button_->SetToggled(type == - mojom::AutoclickEventType::kDoubleClick); - drag_button_->SetToggled(type == mojom::AutoclickEventType::kDragAndDrop); +void AutoclickMenuView::UpdateEventType(AutoclickEventType type) { + left_click_button_->SetToggled(type == AutoclickEventType::kLeftClick); + right_click_button_->SetToggled(type == AutoclickEventType::kRightClick); + double_click_button_->SetToggled(type == AutoclickEventType::kDoubleClick); + drag_button_->SetToggled(type == AutoclickEventType::kDragAndDrop); if (scroll_button_) - scroll_button_->SetToggled(type == mojom::AutoclickEventType::kScroll); - pause_button_->SetToggled(type == mojom::AutoclickEventType::kNoAction); - if (type != mojom::AutoclickEventType::kNoAction) + scroll_button_->SetToggled(type == AutoclickEventType::kScroll); + pause_button_->SetToggled(type == AutoclickEventType::kNoAction); + if (type != AutoclickEventType::kNoAction) event_type_ = type; } -void AutoclickMenuView::UpdatePosition(mojom::AutoclickMenuPosition position) { +void AutoclickMenuView::UpdatePosition(AutoclickMenuPosition position) { switch (position) { - case mojom::AutoclickMenuPosition::kBottomRight: + case AutoclickMenuPosition::kBottomRight: position_button_->SetVectorIcon(kAutoclickPositionBottomRightIcon); return; - case mojom::AutoclickMenuPosition::kBottomLeft: + case AutoclickMenuPosition::kBottomLeft: position_button_->SetVectorIcon(kAutoclickPositionBottomLeftIcon); return; - case mojom::AutoclickMenuPosition::kTopLeft: + case AutoclickMenuPosition::kTopLeft: position_button_->SetVectorIcon(kAutoclickPositionTopLeftIcon); return; - case mojom::AutoclickMenuPosition::kTopRight: + case AutoclickMenuPosition::kTopRight: position_button_->SetVectorIcon(kAutoclickPositionTopRightIcon); return; - case mojom::AutoclickMenuPosition::kSystemDefault: + case AutoclickMenuPosition::kSystemDefault: position_button_->SetVectorIcon(base::i18n::IsRTL() ? kAutoclickPositionBottomLeftIcon : kAutoclickPositionBottomRightIcon); @@ -281,26 +279,25 @@ void AutoclickMenuView::UpdatePosition(mojom::AutoclickMenuPosition position) { void AutoclickMenuView::ButtonPressed(views::Button* sender, const ui::Event& event) { if (sender == position_button_) { - mojom::AutoclickMenuPosition new_position; + AutoclickMenuPosition new_position; // Rotate clockwise throughout the screen positions. switch ( Shell::Get()->accessibility_controller()->GetAutoclickMenuPosition()) { - case mojom::AutoclickMenuPosition::kBottomRight: - new_position = mojom::AutoclickMenuPosition::kBottomLeft; + case AutoclickMenuPosition::kBottomRight: + new_position = AutoclickMenuPosition::kBottomLeft; break; - case mojom::AutoclickMenuPosition::kBottomLeft: - new_position = mojom::AutoclickMenuPosition::kTopLeft; + case AutoclickMenuPosition::kBottomLeft: + new_position = AutoclickMenuPosition::kTopLeft; break; - case mojom::AutoclickMenuPosition::kTopLeft: - new_position = mojom::AutoclickMenuPosition::kTopRight; + case AutoclickMenuPosition::kTopLeft: + new_position = AutoclickMenuPosition::kTopRight; break; - case mojom::AutoclickMenuPosition::kTopRight: - new_position = mojom::AutoclickMenuPosition::kBottomRight; + case AutoclickMenuPosition::kTopRight: + new_position = AutoclickMenuPosition::kBottomRight; break; - case mojom::AutoclickMenuPosition::kSystemDefault: - new_position = base::i18n::IsRTL() - ? mojom::AutoclickMenuPosition::kTopLeft - : mojom::AutoclickMenuPosition::kBottomLeft; + case AutoclickMenuPosition::kSystemDefault: + new_position = base::i18n::IsRTL() ? AutoclickMenuPosition::kTopLeft + : AutoclickMenuPosition::kBottomLeft; break; } Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( @@ -309,24 +306,24 @@ void AutoclickMenuView::ButtonPressed(views::Button* sender, "Accessibility.CrosAutoclick.TrayMenu.ChangePosition")); return; } - mojom::AutoclickEventType type; + AutoclickEventType type; if (sender == left_click_button_) { - type = mojom::AutoclickEventType::kLeftClick; + type = AutoclickEventType::kLeftClick; } else if (sender == right_click_button_) { - type = mojom::AutoclickEventType::kRightClick; + type = AutoclickEventType::kRightClick; } else if (sender == double_click_button_) { - type = mojom::AutoclickEventType::kDoubleClick; + type = AutoclickEventType::kDoubleClick; } else if (sender == drag_button_) { - type = mojom::AutoclickEventType::kDragAndDrop; + type = AutoclickEventType::kDragAndDrop; } else if (sender == scroll_button_) { - type = mojom::AutoclickEventType::kScroll; + type = AutoclickEventType::kScroll; } else if (sender == pause_button_) { // If the pause button was already selected, tapping it again turns off // pause and returns to the previous type. if (pause_button_->IsToggled()) type = event_type_; else - type = mojom::AutoclickEventType::kNoAction; + type = AutoclickEventType::kNoAction; } else { return; } diff --git a/ash/system/accessibility/autoclick_menu_view.h b/ash/system/accessibility/autoclick_menu_view.h index 3cd5ac98845088..4e3f3f50a7fe56 100644 --- a/ash/system/accessibility/autoclick_menu_view.h +++ b/ash/system/accessibility/autoclick_menu_view.h @@ -5,7 +5,7 @@ #ifndef ASH_SYSTEM_ACCESSIBILITY_AUTOCLICK_MENU_VIEW_H_ #define ASH_SYSTEM_ACCESSIBILITY_AUTOCLICK_MENU_VIEW_H_ -#include "ash/public/interfaces/accessibility_controller_enums.mojom.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "ash/system/tray/tray_bubble_view.h" #include "ui/views/controls/button/button.h" @@ -45,12 +45,11 @@ class AutoclickMenuView : public views::View, public views::ButtonListener { kPause = 7, }; - AutoclickMenuView(mojom::AutoclickEventType type, - mojom::AutoclickMenuPosition position); + AutoclickMenuView(AutoclickEventType type, AutoclickMenuPosition position); ~AutoclickMenuView() override = default; - void UpdateEventType(mojom::AutoclickEventType type); - void UpdatePosition(mojom::AutoclickMenuPosition position); + void UpdateEventType(AutoclickEventType type); + void UpdatePosition(AutoclickMenuPosition position); // views::ButtonListener: void ButtonPressed(views::Button* sender, const ui::Event& event) override; @@ -71,7 +70,7 @@ class AutoclickMenuView : public views::View, public views::ButtonListener { // The most recently selected event_type_ excluding kNoAction. This is used // when the pause button is selected in order to unpause and reset to the // previous state. - mojom::AutoclickEventType event_type_ = mojom::AutoclickEventType::kLeftClick; + AutoclickEventType event_type_ = AutoclickEventType::kLeftClick; DISALLOW_COPY_AND_ASSIGN(AutoclickMenuView); }; diff --git a/ash/system/accessibility/dictation_button_tray.cc b/ash/system/accessibility/dictation_button_tray.cc index b99fd70cc0b138..4d97375cd7ddb6 100644 --- a/ash/system/accessibility/dictation_button_tray.cc +++ b/ash/system/accessibility/dictation_button_tray.cc @@ -4,9 +4,9 @@ #include "ash/system/accessibility/dictation_button_tray.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/metrics/user_metrics_recorder.h" -#include "ash/public/interfaces/accessibility_controller_enums.mojom.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/shelf/shelf_constants.h" #include "ash/shell.h" @@ -48,7 +48,7 @@ DictationButtonTray::~DictationButtonTray() { bool DictationButtonTray::PerformAction(const ui::Event& event) { Shell::Get()->accessibility_controller()->ToggleDictationFromSource( - mojom::DictationToggleSource::kButton); + DictationToggleSource::kButton); CheckDictationStatusAndUpdateIcon(); return true; diff --git a/ash/system/accessibility/dictation_button_tray_unittest.cc b/ash/system/accessibility/dictation_button_tray_unittest.cc index fa9254860ea026..fabf91b3b0bcf1 100644 --- a/ash/system/accessibility/dictation_button_tray_unittest.cc +++ b/ash/system/accessibility/dictation_button_tray_unittest.cc @@ -4,7 +4,7 @@ #include "ash/system/accessibility/dictation_button_tray.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/accessibility/test_accessibility_controller_client.h" #include "ash/display/window_tree_host_manager.h" #include "ash/login_status.h" @@ -77,7 +77,7 @@ class DictationButtonTrayTest : public AshTestBase { // Ensures that creation doesn't cause any crashes and adds the image icon. // Also checks that the tray is visible. TEST_F(DictationButtonTrayTest, BasicConstruction) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); controller->SetDictationAcceleratorDialogAccepted(); controller->SetDictationEnabled(true); @@ -87,27 +87,23 @@ TEST_F(DictationButtonTrayTest, BasicConstruction) { // Test that clicking the button activates dictation. TEST_F(DictationButtonTrayTest, ButtonActivatesDictation) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); + TestAccessibilityControllerClient client; controller->SetDictationAcceleratorDialogAccepted(); controller->SetDictationEnabled(true); - TestAccessibilityControllerClient client; - controller->SetClient(client.CreateInterfacePtrAndBind()); - EXPECT_FALSE(controller->dictation_active()); GetTray()->PerformAction(CreateTapEvent()); - controller->FlushMojoForTest(); EXPECT_TRUE(controller->dictation_active()); GetTray()->PerformAction(CreateTapEvent()); - controller->FlushMojoForTest(); EXPECT_FALSE(controller->dictation_active()); } // Test that activating dictation causes the button to activate. TEST_F(DictationButtonTrayTest, ActivatingDictationActivatesButton) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); controller->SetDictationAcceleratorDialogAccepted(); controller->SetDictationEnabled(true); @@ -121,27 +117,23 @@ TEST_F(DictationButtonTrayTest, ActivatingDictationActivatesButton) { // Tests that the tray only renders as active while dictation is listening. Any // termination of dictation clears the active state. TEST_F(DictationButtonTrayTest, ActiveStateOnlyDuringDictation) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); + TestAccessibilityControllerClient client; controller->SetDictationAcceleratorDialogAccepted(); controller->SetDictationEnabled(true); - TestAccessibilityControllerClient client; - controller->SetClient(client.CreateInterfacePtrAndBind()); - controller->FlushMojoForTest(); ASSERT_FALSE(controller->dictation_active()); ASSERT_FALSE(GetTray()->is_active()); Shell::Get()->accelerator_controller()->PerformActionIfEnabled( AcceleratorAction::TOGGLE_DICTATION, {}); - controller->FlushMojoForTest(); - EXPECT_TRUE(Shell::Get()->accessibility_controller()->dictation_active()); + EXPECT_TRUE(controller->dictation_active()); EXPECT_TRUE(GetTray()->is_active()); Shell::Get()->accelerator_controller()->PerformActionIfEnabled( AcceleratorAction::TOGGLE_DICTATION, {}); - controller->FlushMojoForTest(); - EXPECT_FALSE(Shell::Get()->accessibility_controller()->dictation_active()); + EXPECT_FALSE(controller->dictation_active()); EXPECT_FALSE(GetTray()->is_active()); } diff --git a/ash/system/accessibility/select_to_speak_tray.cc b/ash/system/accessibility/select_to_speak_tray.cc index a5dff64a5f1fb6..23cc6156a0e381 100644 --- a/ash/system/accessibility/select_to_speak_tray.cc +++ b/ash/system/accessibility/select_to_speak_tray.cc @@ -4,7 +4,7 @@ #include "ash/system/accessibility/select_to_speak_tray.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/session/session_controller_impl.h" #include "ash/shelf/shelf_constants.h" @@ -95,19 +95,19 @@ void SelectToSpeakTray::CheckStatusAndUpdateIcon() { return; } - ash::mojom::SelectToSpeakState state = + ash::SelectToSpeakState state = Shell::Get()->accessibility_controller()->GetSelectToSpeakState(); switch (state) { - case ash::mojom::SelectToSpeakState::kSelectToSpeakStateInactive: + case ash::SelectToSpeakState::kSelectToSpeakStateInactive: icon_->SetImage(inactive_image_); SetIsActive(false); break; - case ash::mojom::SelectToSpeakState::kSelectToSpeakStateSelecting: + case ash::SelectToSpeakState::kSelectToSpeakStateSelecting: // Activate the start selection button during selection. icon_->SetImage(selecting_image_); SetIsActive(true); break; - case ash::mojom::SelectToSpeakState::kSelectToSpeakStateSpeaking: + case ash::SelectToSpeakState::kSelectToSpeakStateSpeaking: icon_->SetImage(speaking_image_); SetIsActive(true); break; diff --git a/ash/system/accessibility/select_to_speak_tray_unittest.cc b/ash/system/accessibility/select_to_speak_tray_unittest.cc index 90ea0369ddf9e3..32f1f3623b3d90 100644 --- a/ash/system/accessibility/select_to_speak_tray_unittest.cc +++ b/ash/system/accessibility/select_to_speak_tray_unittest.cc @@ -5,7 +5,7 @@ #include "ash/system/accessibility/select_to_speak_tray.h" #include "ash/accelerators/accelerator_controller_impl.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/accessibility/test_accessibility_controller_client.h" #include "ash/shell.h" #include "ash/system/status_area_widget.h" @@ -84,41 +84,35 @@ TEST_F(SelectToSpeakTrayTest, ShowsAndHidesWithSelectToSpeakEnabled) { // Test that clicking the button sends a Select to Speak state change request. TEST_F(SelectToSpeakTrayTest, ButtonRequestsSelectToSpeakStateChange) { - AccessibilityController* controller = - Shell::Get()->accessibility_controller(); TestAccessibilityControllerClient client; - controller->SetClient(client.CreateInterfacePtrAndBind()); - EXPECT_EQ(0, client.select_to_speak_change_change_requests()); GetTray()->PerformAction(CreateTapEvent()); - controller->FlushMojoForTest(); EXPECT_EQ(1, client.select_to_speak_change_change_requests()); GetTray()->PerformAction(CreateTapEvent()); - controller->FlushMojoForTest(); EXPECT_EQ(2, client.select_to_speak_change_change_requests()); } // Test that changing the SelectToSpeakState in the AccessibilityController // results in a change of icon and activation in the tray. TEST_F(SelectToSpeakTrayTest, SelectToSpeakStateImpactsImageAndActivation) { - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); controller->SetSelectToSpeakState( - ash::mojom::SelectToSpeakState::kSelectToSpeakStateSelecting); + SelectToSpeakState::kSelectToSpeakStateSelecting); EXPECT_TRUE(IsTrayBackgroundActive()); EXPECT_TRUE( GetSelectingImage().BackedBySameObjectAs(GetImageView()->GetImage())); controller->SetSelectToSpeakState( - ash::mojom::SelectToSpeakState::kSelectToSpeakStateSpeaking); + SelectToSpeakState::kSelectToSpeakStateSpeaking); EXPECT_TRUE(IsTrayBackgroundActive()); EXPECT_TRUE( GetSpeakingImage().BackedBySameObjectAs(GetImageView()->GetImage())); controller->SetSelectToSpeakState( - ash::mojom::SelectToSpeakState::kSelectToSpeakStateInactive); + SelectToSpeakState::kSelectToSpeakStateInactive); EXPECT_FALSE(IsTrayBackgroundActive()); EXPECT_TRUE( GetInactiveImage().BackedBySameObjectAs(GetImageView()->GetImage())); diff --git a/ash/system/accessibility/tray_accessibility.cc b/ash/system/accessibility/tray_accessibility.cc index 1ba417fe070779..167f0e7834984f 100644 --- a/ash/system/accessibility/tray_accessibility.cc +++ b/ash/system/accessibility/tray_accessibility.cc @@ -7,7 +7,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/accessibility/accessibility_delegate.h" #include "ash/magnifier/docked_magnifier_controller_impl.h" #include "ash/public/cpp/ash_features.h" @@ -69,7 +69,7 @@ AccessibilityDetailedView::AccessibilityDetailedView( void AccessibilityDetailedView::OnAccessibilityStatusChanged() { AccessibilityDelegate* delegate = Shell::Get()->accessibility_delegate(); - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); spoken_feedback_enabled_ = controller->spoken_feedback_enabled(); @@ -146,7 +146,7 @@ void AccessibilityDetailedView::AppendAccessibilityList() { CreateScrollableList(); AccessibilityDelegate* delegate = Shell::Get()->accessibility_delegate(); - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); spoken_feedback_enabled_ = controller->spoken_feedback_enabled(); @@ -261,7 +261,7 @@ void AccessibilityDetailedView::AppendAccessibilityList() { void AccessibilityDetailedView::HandleViewClicked(views::View* view) { AccessibilityDelegate* delegate = Shell::Get()->accessibility_delegate(); - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); using base::RecordAction; using base::UserMetricsAction; diff --git a/ash/system/accessibility/tray_accessibility_unittest.cc b/ash/system/accessibility/tray_accessibility_unittest.cc index 3c677a9d15b290..bee606e7ad936f 100644 --- a/ash/system/accessibility/tray_accessibility_unittest.cc +++ b/ash/system/accessibility/tray_accessibility_unittest.cc @@ -4,7 +4,7 @@ #include "ash/system/accessibility/tray_accessibility.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_pref_names.h" #include "ash/session/session_controller_impl.h" @@ -321,7 +321,7 @@ TEST_F(TrayAccessibilityTest, CheckMenuVisibilityOnDetailMenu) { } TEST_F(TrayAccessibilityTest, ClickDetailMenu) { - AccessibilityController* accessibility_controller = + AccessibilityControllerImpl* accessibility_controller = Shell::Get()->accessibility_controller(); // Confirms that the check item toggles the spoken feedback. EXPECT_FALSE(accessibility_controller->spoken_feedback_enabled()); diff --git a/ash/system/accessibility/unified_accessibility_detailed_view_controller.cc b/ash/system/accessibility/unified_accessibility_detailed_view_controller.cc index a6016438df3349..a49c183b91f69b 100644 --- a/ash/system/accessibility/unified_accessibility_detailed_view_controller.cc +++ b/ash/system/accessibility/unified_accessibility_detailed_view_controller.cc @@ -4,7 +4,7 @@ #include "ash/system/accessibility/unified_accessibility_detailed_view_controller.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/shell.h" #include "ash/system/accessibility/tray_accessibility.h" #include "ash/system/tray/detailed_view_delegate.h" diff --git a/ash/system/caps_lock_notification_controller.cc b/ash/system/caps_lock_notification_controller.cc index 59450c9f703622..778f67b79880d4 100644 --- a/ash/system/caps_lock_notification_controller.cc +++ b/ash/system/caps_lock_notification_controller.cc @@ -4,7 +4,7 @@ #include "ash/system/caps_lock_notification_controller.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/public/cpp/notification_utils.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/session/session_controller_impl.h" @@ -90,8 +90,7 @@ void CapsLockNotificationController::RegisterProfilePrefs( void CapsLockNotificationController::OnCapsLockChanged(bool enabled) { // Send an a11y alert. Shell::Get()->accessibility_controller()->TriggerAccessibilityAlert( - enabled ? mojom::AccessibilityAlert::CAPS_ON - : mojom::AccessibilityAlert::CAPS_OFF); + enabled ? AccessibilityAlert::CAPS_ON : AccessibilityAlert::CAPS_OFF); if (enabled) { Shell::Get()->metrics()->RecordUserMetricsAction( diff --git a/ash/system/caps_lock_notification_controller_unittest.cc b/ash/system/caps_lock_notification_controller_unittest.cc index a692cf54b8de73..74ceab7ff1bf91 100644 --- a/ash/system/caps_lock_notification_controller_unittest.cc +++ b/ash/system/caps_lock_notification_controller_unittest.cc @@ -4,8 +4,8 @@ #include "ash/system/caps_lock_notification_controller.h" -#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/test_accessibility_controller_client.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" @@ -16,21 +16,15 @@ using CapsLockNotificationControllerTest = AshTestBase; // Tests that a11y alert is sent on toggling caps lock. TEST_F(CapsLockNotificationControllerTest, A11yAlert) { auto caps_lock = std::make_unique(); - TestAccessibilityControllerClient client; - AccessibilityController* controller = - Shell::Get()->accessibility_controller(); - controller->SetClient(client.CreateInterfacePtrAndBind()); // Simulate turning on caps lock. caps_lock->OnCapsLockChanged(true); - controller->FlushMojoForTest(); - EXPECT_EQ(mojom::AccessibilityAlert::CAPS_ON, client.last_a11y_alert()); + EXPECT_EQ(AccessibilityAlert::CAPS_ON, client.last_a11y_alert()); // Simulate turning off caps lock. caps_lock->OnCapsLockChanged(false); - controller->FlushMojoForTest(); - EXPECT_EQ(mojom::AccessibilityAlert::CAPS_OFF, client.last_a11y_alert()); + EXPECT_EQ(AccessibilityAlert::CAPS_OFF, client.last_a11y_alert()); } } // namespace ash diff --git a/ash/system/ime/unified_ime_detailed_view_controller.cc b/ash/system/ime/unified_ime_detailed_view_controller.cc index 37c7190a612ebc..7950185e8b5336 100644 --- a/ash/system/ime/unified_ime_detailed_view_controller.cc +++ b/ash/system/ime/unified_ime_detailed_view_controller.cc @@ -4,7 +4,7 @@ #include "ash/system/ime/unified_ime_detailed_view_controller.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/ime/ime_controller.h" #include "ash/shell.h" #include "ash/system/ime/tray_ime_chromeos.h" diff --git a/ash/system/ime_menu/ime_menu_tray.cc b/ash/system/ime_menu/ime_menu_tray.cc index 5438d8948ac503..00771a15c30706 100644 --- a/ash/system/ime_menu/ime_menu_tray.cc +++ b/ash/system/ime_menu/ime_menu_tray.cc @@ -4,7 +4,7 @@ #include "ash/system/ime_menu/ime_menu_tray.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/ime/ime_controller.h" #include "ash/keyboard/ash_keyboard_controller.h" #include "ash/keyboard/ui/keyboard_controller.h" diff --git a/ash/system/ime_menu/ime_menu_tray_unittest.cc b/ash/system/ime_menu/ime_menu_tray_unittest.cc index a33f04eaf9df11..ee460204032f23 100644 --- a/ash/system/ime_menu/ime_menu_tray_unittest.cc +++ b/ash/system/ime_menu/ime_menu_tray_unittest.cc @@ -5,7 +5,6 @@ #include "ash/system/ime_menu/ime_menu_tray.h" #include "ash/accelerators/accelerator_controller_impl.h" -#include "ash/accessibility/accessibility_controller.h" #include "ash/ime/ime_controller.h" #include "ash/ime/test_ime_controller_client.h" #include "ash/public/interfaces/ime_info.mojom.h" diff --git a/ash/system/palette/palette_tray.cc b/ash/system/palette/palette_tray.cc index 4ccdc25501f32a..1deeb68d412233 100644 --- a/ash/system/palette/palette_tray.cc +++ b/ash/system/palette/palette_tray.cc @@ -6,7 +6,7 @@ #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/public/cpp/ash_pref_names.h" #include "ash/public/cpp/stylus_utils.h" #include "ash/public/cpp/system_tray_client.h" diff --git a/ash/system/power/power_button_controller_unittest.cc b/ash/system/power/power_button_controller_unittest.cc index 1917b933ab8eb3..97e310e6030ff7 100644 --- a/ash/system/power/power_button_controller_unittest.cc +++ b/ash/system/power/power_button_controller_unittest.cc @@ -4,7 +4,6 @@ #include "ash/system/power/power_button_controller.h" -#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/test_accessibility_controller_client.h" #include "ash/display/screen_orientation_controller.h" #include "ash/display/screen_orientation_controller_test_api.h" @@ -84,9 +83,6 @@ class PowerButtonControllerTest : public PowerButtonTestBase { // Run the event loop so that PowerButtonDisplayController can receive the // initial backlights-forced-off state. base::RunLoop().RunUntilIdle(); - - a11y_controller_ = Shell::Get()->accessibility_controller(); - a11y_controller_->SetClient(a11y_client_.CreateInterfacePtrAndBind()); } protected: @@ -149,9 +145,6 @@ class PowerButtonControllerTest : public PowerButtonTestBase { power_button_controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); } - AccessibilityController* a11y_controller_ = nullptr; // not owned - TestAccessibilityControllerClient a11y_client_; - private: DISALLOW_COPY_AND_ASSIGN(PowerButtonControllerTest); }; @@ -772,19 +765,17 @@ TEST_F(PowerButtonControllerTest, IgnoreForcingOffWhenDisplayIsTurningOn) { // Tests that a11y alert is sent on tablet power button induced screen state // change. TEST_F(PowerButtonControllerTest, A11yAlert) { + TestAccessibilityControllerClient a11y_client; + EnableTabletMode(true); PressPowerButton(); ReleasePowerButton(); SendBrightnessChange(0, kUserCause); - a11y_controller_->FlushMojoForTest(); - EXPECT_EQ(mojom::AccessibilityAlert::SCREEN_OFF, - a11y_client_.last_a11y_alert()); + EXPECT_EQ(AccessibilityAlert::SCREEN_OFF, a11y_client.last_a11y_alert()); PressPowerButton(); SendBrightnessChange(kNonZeroBrightness, kUserCause); - a11y_controller_->FlushMojoForTest(); - EXPECT_EQ(mojom::AccessibilityAlert::SCREEN_ON, - a11y_client_.last_a11y_alert()); + EXPECT_EQ(AccessibilityAlert::SCREEN_ON, a11y_client.last_a11y_alert()); ReleasePowerButton(); } @@ -1383,7 +1374,6 @@ TEST_F(PowerButtonControllerTest, LegacyPowerButtonIgnoreExtraPress) { EXPECT_EQ(menu_view_before, power_button_test_api_->GetPowerButtonMenuView()); // This is needed to simulate the shutdown sound having been played, // which blocks the shutdown timer. - a11y_controller_->FlushMojoForTest(); // Make sure that the second press did not trigger a shutdown. EXPECT_FALSE(lock_state_test_api_->real_shutdown_timer_is_running()); // Make sure that power menu is still in partially shown state. diff --git a/ash/system/power/power_button_display_controller.cc b/ash/system/power/power_button_display_controller.cc index 79f5a99ed68826..312bf7559235a8 100644 --- a/ash/system/power/power_button_display_controller.cc +++ b/ash/system/power/power_button_display_controller.cc @@ -4,7 +4,7 @@ #include "ash/system/power/power_button_display_controller.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/media/media_controller_impl.h" #include "ash/shell.h" #include "ash/system/power/scoped_backlights_forced_off.h" @@ -79,8 +79,8 @@ void PowerButtonDisplayController::OnBacklightsForcedOffChanged( bool forced_off) { if (send_accessibility_alert_on_backlights_forced_off_change_) { Shell::Get()->accessibility_controller()->TriggerAccessibilityAlert( - forced_off ? mojom::AccessibilityAlert::SCREEN_OFF - : mojom::AccessibilityAlert::SCREEN_ON); + forced_off ? AccessibilityAlert::SCREEN_OFF + : AccessibilityAlert::SCREEN_ON); } send_accessibility_alert_on_backlights_forced_off_change_ = false; } diff --git a/ash/system/unified/top_shortcuts_view.cc b/ash/system/unified/top_shortcuts_view.cc index 756cb83be8a4dd..86ff1ee94d2887 100644 --- a/ash/system/unified/top_shortcuts_view.cc +++ b/ash/system/unified/top_shortcuts_view.cc @@ -6,7 +6,7 @@ #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/kiosk_next/kiosk_next_shell_controller_impl.h" #include "ash/public/cpp/ash_view_ids.h" #include "ash/resources/vector_icons/vector_icons.h" diff --git a/ash/system/unified/unified_system_tray.cc b/ash/system/unified/unified_system_tray.cc index adcef6e9eb1125..90673a32a9b74c 100644 --- a/ash/system/unified/unified_system_tray.cc +++ b/ash/system/unified/unified_system_tray.cc @@ -4,7 +4,7 @@ #include "ash/system/unified/unified_system_tray.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/public/cpp/ash_features.h" #include "ash/session/session_controller_impl.h" #include "ash/shelf/shelf.h" diff --git a/ash/system/unified/unified_system_tray_model.cc b/ash/system/unified/unified_system_tray_model.cc index 41a1bb2bfe59f3..2f3122e980fd7b 100644 --- a/ash/system/unified/unified_system_tray_model.cc +++ b/ash/system/unified/unified_system_tray_model.cc @@ -4,7 +4,7 @@ #include "ash/system/unified/unified_system_tray_model.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/shell.h" #include "ash/system/brightness_control_delegate.h" #include "base/bind.h" diff --git a/ash/system/virtual_keyboard/virtual_keyboard_tray.cc b/ash/system/virtual_keyboard/virtual_keyboard_tray.cc index 7b6a373b41ddf5..75306dd0d0d030 100644 --- a/ash/system/virtual_keyboard/virtual_keyboard_tray.cc +++ b/ash/system/virtual_keyboard/virtual_keyboard_tray.cc @@ -6,7 +6,7 @@ #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/keyboard/ui/keyboard_controller.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/session/session_controller_impl.h" diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc index 59751fb74e811d..7a48300dde1c82 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -417,7 +417,7 @@ void AshTestBase::SetAccessibilityPanelHeight(int panel_height) { Shell::GetPrimaryRootWindowController() ->GetAccessibilityPanelLayoutManagerForTest() ->SetPanelBounds(gfx::Rect(0, 0, 0, panel_height), - mojom::AccessibilityPanelState::FULL_WIDTH); + AccessibilityPanelState::FULL_WIDTH); } void AshTestBase::ClearLogin() { diff --git a/ash/wm/base_state.cc b/ash/wm/base_state.cc index 66232b861d8547..2cc413fdc2abae 100644 --- a/ash/wm/base_state.cc +++ b/ash/wm/base_state.cc @@ -4,7 +4,6 @@ #include "ash/wm/base_state.h" -#include "ash/accessibility/accessibility_controller.h" #include "ash/public/cpp/window_animation_types.h" #include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_state_type.h" diff --git a/ash/wm/lock_state_controller.cc b/ash/wm/lock_state_controller.cc index 7b8cec5a7c313b..b3e09e9f124358 100644 --- a/ash/wm/lock_state_controller.cc +++ b/ash/wm/lock_state_controller.cc @@ -8,7 +8,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/cancel_mode.h" #include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shutdown_controller.h" @@ -315,20 +315,12 @@ void LockStateController::StartRealShutdownTimer(bool with_animation_time) { } // Play and get shutdown sound duration from chrome in |sound_duration|. And // start real shutdown after a delay of |duration|. - Shell::Get()->accessibility_controller()->PlayShutdownSound(base::BindOnce( - [](base::WeakPtr self, base::TimeDelta duration, - base::TimeDelta sound_duration) { - if (!self) - return; - sound_duration = std::min( - sound_duration, - base::TimeDelta::FromMilliseconds(kMaxShutdownSoundDurationMs)); - duration = std::max(duration, sound_duration); - self->real_shutdown_timer_.Start( - FROM_HERE, duration, self.get(), - &LockStateController::OnRealPowerTimeout); - }, - weak_ptr_factory_.GetWeakPtr(), duration)); + base::TimeDelta sound_duration = + std::min(Shell::Get()->accessibility_controller()->PlayShutdownSound(), + base::TimeDelta::FromMilliseconds(kMaxShutdownSoundDurationMs)); + duration = std::max(duration, sound_duration); + real_shutdown_timer_.Start(FROM_HERE, duration, this, + &LockStateController::OnRealPowerTimeout); } void LockStateController::OnRealPowerTimeout() { diff --git a/ash/wm/lock_state_controller_unittest.cc b/ash/wm/lock_state_controller_unittest.cc index 823a2f2dc00b1f..4592b6296ceb96 100644 --- a/ash/wm/lock_state_controller_unittest.cc +++ b/ash/wm/lock_state_controller_unittest.cc @@ -7,8 +7,6 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" -#include "ash/accessibility/test_accessibility_controller_client.h" #include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/shutdown_controller.h" #include "ash/session/session_controller_impl.h" @@ -89,9 +87,6 @@ class LockStateControllerTest : public PowerButtonTestBase { test_shutdown_controller_ = std::make_unique(); lock_state_test_api_->set_shutdown_controller( test_shutdown_controller_.get()); - - a11y_controller_ = Shell::Get()->accessibility_controller(); - a11y_controller_->SetClient(a11y_client_.CreateInterfacePtrAndBind()); } void TearDown() override { test_shutdown_controller_.reset(); @@ -296,15 +291,10 @@ class LockStateControllerTest : public PowerButtonTestBase { lock_state_controller_->OnLockScreenHide(closure); } - // Simulate that shutdown sound duration callback is done. - void ShutdownSoundPlayed() { a11y_controller_->FlushMojoForTest(); } - std::unique_ptr shutdown_controller_resetter_; std::unique_ptr test_shutdown_controller_; TestSessionStateAnimator* test_animator_ = nullptr; // not owned - AccessibilityController* a11y_controller_ = nullptr; // not owned - TestAccessibilityControllerClient a11y_client_; private: DISALLOW_COPY_AND_ASSIGN(LockStateControllerTest); @@ -341,7 +331,6 @@ TEST_F(LockStateControllerTest, LegacyShowMenuAndShutDown) { GenerateMouseMoveEvent(); EXPECT_FALSE(cursor_visible()); - ShutdownSoundPlayed(); EXPECT_TRUE(lock_state_test_api_->real_shutdown_timer_is_running()); lock_state_test_api_->trigger_real_shutdown_timeout(); EXPECT_EQ(1, NumShutdownRequests()); @@ -522,7 +511,6 @@ TEST_F(LockStateControllerTest, RequestShutdownFromLoginScreen) { EXPECT_FALSE(cursor_visible()); EXPECT_EQ(0, NumShutdownRequests()); - ShutdownSoundPlayed(); EXPECT_TRUE(lock_state_test_api_->real_shutdown_timer_is_running()); lock_state_test_api_->trigger_real_shutdown_timeout(); EXPECT_EQ(1, NumShutdownRequests()); @@ -546,7 +534,6 @@ TEST_F(LockStateControllerTest, RequestShutdownFromLockScreen) { EXPECT_FALSE(cursor_visible()); EXPECT_EQ(0, NumShutdownRequests()); - ShutdownSoundPlayed(); EXPECT_TRUE(lock_state_test_api_->real_shutdown_timer_is_running()); lock_state_test_api_->trigger_real_shutdown_timeout(); EXPECT_EQ(1, NumShutdownRequests()); @@ -700,7 +687,6 @@ TEST_F(LockStateControllerTest, ShutDownAfterShowPowerMenu) { ExpectShutdownAnimationFinished(); lock_state_test_api_->trigger_shutdown_timeout(); - ShutdownSoundPlayed(); EXPECT_TRUE(lock_state_test_api_->real_shutdown_timer_is_running()); EXPECT_EQ(0, NumShutdownRequests()); diff --git a/ash/wm/overview/overview_session.cc b/ash/wm/overview/overview_session.cc index 9f23cbb0a0fed8..5903542fb1bf2b 100644 --- a/ash/wm/overview/overview_session.cc +++ b/ash/wm/overview/overview_session.cc @@ -8,7 +8,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/app_list/app_list_controller_impl.h" #include "ash/metrics/user_metrics_recorder.h" #include "ash/public/cpp/ash_features.h" @@ -266,7 +266,7 @@ void OverviewSession::Init(const WindowList& windows, base::RecordAction(base::UserMetricsAction("WindowSelector_Overview")); // Send an a11y alert. Shell::Get()->accessibility_controller()->TriggerAccessibilityAlert( - mojom::AccessibilityAlert::WINDOW_OVERVIEW_MODE_ENTERED); + AccessibilityAlert::WINDOW_OVERVIEW_MODE_ENTERED); ignore_activations_ = false; } diff --git a/ash/wm/overview/overview_session_unittest.cc b/ash/wm/overview/overview_session_unittest.cc index d7f80544c1d8b9..de2ba30f9aa9d6 100644 --- a/ash/wm/overview/overview_session_unittest.cc +++ b/ash/wm/overview/overview_session_unittest.cc @@ -12,7 +12,6 @@ #include "ash/accelerators/accelerator_controller_impl.h" #include "ash/accelerators/exit_warning_handler.h" -#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/test_accessibility_controller_client.h" #include "ash/app_list/app_list_controller_impl.h" #include "ash/display/screen_orientation_controller.h" @@ -392,15 +391,11 @@ class OverviewSessionTest : public AshTestBase { // Tests that an a11y alert is sent on entering overview mode. TEST_F(OverviewSessionTest, A11yAlertOnOverviewMode) { TestAccessibilityControllerClient client; - AccessibilityController* controller = - Shell::Get()->accessibility_controller(); - controller->SetClient(client.CreateInterfacePtrAndBind()); std::unique_ptr window(CreateTestWindow()); - EXPECT_NE(mojom::AccessibilityAlert::WINDOW_OVERVIEW_MODE_ENTERED, + EXPECT_NE(AccessibilityAlert::WINDOW_OVERVIEW_MODE_ENTERED, client.last_a11y_alert()); ToggleOverview(); - controller->FlushMojoForTest(); - EXPECT_EQ(mojom::AccessibilityAlert::WINDOW_OVERVIEW_MODE_ENTERED, + EXPECT_EQ(AccessibilityAlert::WINDOW_OVERVIEW_MODE_ENTERED, client.last_a11y_alert()); } diff --git a/ash/wm/splitview/split_view_controller.cc b/ash/wm/splitview/split_view_controller.cc index c20eee4e42839f..8c4fd34787ad03 100644 --- a/ash/wm/splitview/split_view_controller.cc +++ b/ash/wm/splitview/split_view_controller.cc @@ -7,7 +7,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/display/screen_orientation_controller.h" #include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/presentation_time_recorder.h" diff --git a/ash/wm/splitview/split_view_utils.cc b/ash/wm/splitview/split_view_utils.cc index 7f6b46781119b6..bdd00e45ae6807 100644 --- a/ash/wm/splitview/split_view_utils.cc +++ b/ash/wm/splitview/split_view_utils.cc @@ -4,7 +4,7 @@ #include "ash/wm/splitview/split_view_utils.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/display/screen_orientation_controller.h" #include "ash/kiosk_next/kiosk_next_shell_controller_impl.h" #include "ash/public/cpp/ash_features.h" diff --git a/ash/wm/workspace/backdrop_controller.cc b/ash/wm/workspace/backdrop_controller.cc index 2bb615a0a92dc9..1ab3c932c69ad7 100644 --- a/ash/wm/workspace/backdrop_controller.cc +++ b/ash/wm/workspace/backdrop_controller.cc @@ -7,7 +7,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/accessibility/accessibility_delegate.h" #include "ash/public/cpp/app_types.h" #include "ash/public/cpp/shell_window_ids.h" diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc index fda30d88e72c73..724f2e49bb3cb9 100644 --- a/ash/wm/workspace/workspace_layout_manager.cc +++ b/ash/wm/workspace/workspace_layout_manager.cc @@ -7,7 +7,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/autoclick/autoclick_controller.h" #include "ash/keyboard/ui/keyboard_controller.h" #include "ash/public/cpp/keyboard/keyboard_controller_observer.h" diff --git a/ash/wm/workspace/workspace_layout_manager_unittest.cc b/ash/wm/workspace/workspace_layout_manager_unittest.cc index d6e5bb25421a6b..a2fe7535cb9d63 100644 --- a/ash/wm/workspace/workspace_layout_manager_unittest.cc +++ b/ash/wm/workspace/workspace_layout_manager_unittest.cc @@ -7,7 +7,7 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/accessibility/test_accessibility_controller_client.h" #include "ash/app_list/test/app_list_test_helper.h" #include "ash/frame/non_client_frame_view_ash.h" @@ -139,7 +139,7 @@ class ScopedStickyKeyboardEnabler { } private: - AccessibilityController* accessibility_controller_; + AccessibilityControllerImpl* accessibility_controller_; const bool enabled_; DISALLOW_COPY_AND_ASSIGN(ScopedStickyKeyboardEnabler); @@ -1487,10 +1487,9 @@ TEST_F(WorkspaceLayoutManagerBackdropTest, TEST_F(WorkspaceLayoutManagerBackdropTest, SpokenFeedbackFullscreenBackground) { WorkspaceController* wc = ShellTestApi().workspace_controller(); WorkspaceControllerTestApi test_helper(wc); - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); TestAccessibilityControllerClient client; - controller->SetClient(client.CreateInterfacePtrAndBind()); aura::test::TestWindowDelegate delegate; std::unique_ptr window(CreateTestWindowInShellWithDelegate( @@ -1504,12 +1503,10 @@ TEST_F(WorkspaceLayoutManagerBackdropTest, SpokenFeedbackFullscreenBackground) { generator->MoveMouseTo(300, 300); generator->ClickLeftButton(); - controller->FlushMojoForTest(); EXPECT_EQ(kNoSoundKey, client.GetPlayedEarconAndReset()); generator->MoveMouseRelativeTo(window.get(), 10, 10); generator->ClickLeftButton(); - controller->FlushMojoForTest(); EXPECT_EQ(kNoSoundKey, client.GetPlayedEarconAndReset()); // Enable spoken feedback. @@ -1518,12 +1515,10 @@ TEST_F(WorkspaceLayoutManagerBackdropTest, SpokenFeedbackFullscreenBackground) { generator->MoveMouseTo(300, 300); generator->ClickLeftButton(); - controller->FlushMojoForTest(); EXPECT_EQ(chromeos::SOUND_VOLUME_ADJUST, client.GetPlayedEarconAndReset()); generator->MoveMouseRelativeTo(window.get(), 10, 10); generator->ClickLeftButton(); - controller->FlushMojoForTest(); EXPECT_EQ(kNoSoundKey, client.GetPlayedEarconAndReset()); // Disable spoken feedback. Shadow underlay is restored. @@ -1532,12 +1527,10 @@ TEST_F(WorkspaceLayoutManagerBackdropTest, SpokenFeedbackFullscreenBackground) { generator->MoveMouseTo(300, 300); generator->ClickLeftButton(); - controller->FlushMojoForTest(); EXPECT_EQ(kNoSoundKey, client.GetPlayedEarconAndReset()); generator->MoveMouseTo(70, 70); generator->ClickLeftButton(); - controller->FlushMojoForTest(); EXPECT_EQ(kNoSoundKey, client.GetPlayedEarconAndReset()); } @@ -1571,10 +1564,9 @@ TEST_F(WorkspaceLayoutManagerBackdropTest, DISABLED_OpenAppListInOverviewMode) { TEST_F(WorkspaceLayoutManagerBackdropTest, SpokenFeedbackForArc) { WorkspaceController* wc = ShellTestApi().workspace_controller(); WorkspaceControllerTestApi test_helper(wc); - AccessibilityController* controller = + AccessibilityControllerImpl* controller = Shell::Get()->accessibility_controller(); TestAccessibilityControllerClient client; - controller->SetClient(client.CreateInterfacePtrAndBind()); controller->SetSpokenFeedbackEnabled(true, A11Y_NOTIFICATION_NONE); EXPECT_TRUE(controller->spoken_feedback_enabled()); @@ -1606,12 +1598,10 @@ TEST_F(WorkspaceLayoutManagerBackdropTest, SpokenFeedbackForArc) { ui::test::EventGenerator* generator = GetEventGenerator(); generator->MoveMouseTo(300, 300); generator->ClickLeftButton(); - controller->FlushMojoForTest(); EXPECT_EQ(chromeos::SOUND_VOLUME_ADJUST, client.GetPlayedEarconAndReset()); generator->MoveMouseTo(70, 70); generator->ClickLeftButton(); - controller->FlushMojoForTest(); EXPECT_EQ(kNoSoundKey, client.GetPlayedEarconAndReset()); } diff --git a/chrome/browser/accessibility/accessibility_extension_api.cc b/chrome/browser/accessibility/accessibility_extension_api.cc index 2bac4d694c7aa5..e6947318d0f91d 100644 --- a/chrome/browser/accessibility/accessibility_extension_api.cc +++ b/chrome/browser/accessibility/accessibility_extension_api.cc @@ -36,6 +36,8 @@ #include "ui/events/keycodes/keyboard_codes.h" #if defined(OS_CHROMEOS) +#include "ash/public/cpp/accessibility_controller.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "ash/public/cpp/accessibility_focus_ring_info.h" #include "ash/public/cpp/event_rewriter_controller.h" #include "ash/public/cpp/window_tree_host_lookup.h" @@ -57,14 +59,6 @@ const char kErrorNotSupported[] = "This API is not supported on this platform."; #if defined(OS_CHROMEOS) constexpr int kBackButtonWidth = 45; constexpr int kBackButtonHeight = 45; - -ash::mojom::AccessibilityControllerPtr GetAccessibilityController() { - // Connect to the accessibility mojo interface in ash. - ash::mojom::AccessibilityControllerPtr accessibility_controller; - content::GetSystemConnector()->BindInterface(ash::mojom::kServiceName, - &accessibility_controller); - return accessibility_controller; -} #endif } // namespace @@ -226,7 +220,8 @@ AccessibilityPrivateSetSwitchAccessKeysFunction::Run() { accessibility_private::SetSwitchAccessKeys::Params::Create(*args_); EXTENSION_FUNCTION_VALIDATE(params); - GetAccessibilityController()->SetSwitchAccessKeysToCapture(params->key_codes); + ash::AccessibilityController::Get()->SetSwitchAccessKeysToCapture( + params->key_codes); return RespondNow(NoArguments()); } @@ -359,20 +354,20 @@ AccessibilityPrivateOnSelectToSpeakStateChangedFunction::Run() { *args_); EXTENSION_FUNCTION_VALIDATE(params); accessibility_private::SelectToSpeakState params_state = params->state; - ash::mojom::SelectToSpeakState state; + ash::SelectToSpeakState state; switch (params_state) { case accessibility_private::SelectToSpeakState:: SELECT_TO_SPEAK_STATE_SELECTING: - state = ash::mojom::SelectToSpeakState::kSelectToSpeakStateSelecting; + state = ash::SelectToSpeakState::kSelectToSpeakStateSelecting; break; case accessibility_private::SelectToSpeakState:: SELECT_TO_SPEAK_STATE_SPEAKING: - state = ash::mojom::SelectToSpeakState::kSelectToSpeakStateSpeaking; + state = ash::SelectToSpeakState::kSelectToSpeakStateSpeaking; break; case accessibility_private::SelectToSpeakState:: SELECT_TO_SPEAK_STATE_INACTIVE: case accessibility_private::SelectToSpeakState::SELECT_TO_SPEAK_STATE_NONE: - state = ash::mojom::SelectToSpeakState::kSelectToSpeakStateInactive; + state = ash::SelectToSpeakState::kSelectToSpeakStateInactive; } auto* accessibility_manager = chromeos::AccessibilityManager::Get(); @@ -390,16 +385,15 @@ AccessibilityPrivateOnScrollableBoundsForPointFoundFunction::Run() { ExtensionFunction::ResponseAction AccessibilityPrivateToggleDictationFunction::Run() { - ash::mojom::DictationToggleSource source = - ash::mojom::DictationToggleSource::kChromevox; + ash::DictationToggleSource source = ash::DictationToggleSource::kChromevox; if (extension()->id() == extension_misc::kSwitchAccessExtensionId) - source = ash::mojom::DictationToggleSource::kSwitchAccess; + source = ash::DictationToggleSource::kSwitchAccess; else if (extension()->id() == extension_misc::kChromeVoxExtensionId) - source = ash::mojom::DictationToggleSource::kChromevox; + source = ash::DictationToggleSource::kChromevox; else NOTREACHED(); - GetAccessibilityController()->ToggleDictationFromSource(source); + ash::AccessibilityController::Get()->ToggleDictationFromSource(source); return RespondNow(NoArguments()); } @@ -456,7 +450,7 @@ AccessibilityPrivateForwardKeyEventsToSwitchAccessFunction::Run() { *args_); EXTENSION_FUNCTION_VALIDATE(params); - GetAccessibilityController()->ForwardKeyEventsToSwitchAccess( + ash::AccessibilityController::Get()->ForwardKeyEventsToSwitchAccess( params->should_forward); return RespondNow(NoArguments()); @@ -470,24 +464,8 @@ AccessibilityPrivateGetBatteryDescriptionFunction:: ExtensionFunction::ResponseAction AccessibilityPrivateGetBatteryDescriptionFunction::Run() { - // Get AccessibilityControllerPtr; needs to exist for lifetime of this - // function and its callback. - controller_ = GetAccessibilityController(); - - // Get battery description from ash and return it via callback. - controller_->GetBatteryDescription( - base::BindOnce(&AccessibilityPrivateGetBatteryDescriptionFunction:: - OnGotBatteryDescription, - this)); - - return RespondLater(); -} - -void AccessibilityPrivateGetBatteryDescriptionFunction::OnGotBatteryDescription( - const base::string16& battery_description) { - // Send battery description to extension. - Respond(OneArgument(std::make_unique(battery_description))); - controller_.reset(); + return RespondNow(OneArgument(std::make_unique( + ash::AccessibilityController::Get()->GetBatteryDescription()))); } ExtensionFunction::ResponseAction @@ -497,7 +475,8 @@ AccessibilityPrivateSetVirtualKeyboardVisibleFunction::Run() { *args_); EXTENSION_FUNCTION_VALIDATE(params); - GetAccessibilityController()->SetVirtualKeyboardVisible(params->is_visible); + ash::AccessibilityController::Get()->SetVirtualKeyboardVisible( + params->is_visible); return RespondNow(NoArguments()); } diff --git a/chrome/browser/accessibility/accessibility_extension_api.h b/chrome/browser/accessibility/accessibility_extension_api.h index cd5d49de03c1c3..2733a1477dcd71 100644 --- a/chrome/browser/accessibility/accessibility_extension_api.h +++ b/chrome/browser/accessibility/accessibility_extension_api.h @@ -12,10 +12,6 @@ #include "extensions/browser/extension_function.h" #include "ui/accessibility/ax_enums.mojom.h" -#if defined(OS_CHROMEOS) -#include "ash/public/interfaces/accessibility_controller.mojom.h" -#endif - // API function that enables or disables web content accessibility support. class AccessibilityPrivateSetNativeAccessibilityEnabledFunction : public UIThreadExtensionFunction { @@ -166,13 +162,11 @@ class AccessibilityPrivateGetBatteryDescriptionFunction public: AccessibilityPrivateGetBatteryDescriptionFunction(); ResponseAction Run() override; - void OnGotBatteryDescription(const base::string16& battery_description); DECLARE_EXTENSION_FUNCTION("accessibilityPrivate.getBatteryDescription", ACCESSIBILITY_PRIVATE_GETBATTERYDESCRIPTION) private: ~AccessibilityPrivateGetBatteryDescriptionFunction() override; - ash::mojom::AccessibilityControllerPtr controller_ = nullptr; }; // API function that opens or closes the virtual keyboard. diff --git a/chrome/browser/chromeos/accessibility/DEPS b/chrome/browser/chromeos/accessibility/DEPS index d40c29d0e703c4..0aff112f15e3d8 100644 --- a/chrome/browser/chromeos/accessibility/DEPS +++ b/chrome/browser/chromeos/accessibility/DEPS @@ -1,7 +1,6 @@ specific_include_rules = { "accessibility_manager\.cc": [ # TODO(mash): Fix. https://crbug.com/594887 https://crbug.com/888145 - "+ash/accessibility/accessibility_controller.h", "+ash/root_window_controller.h", "+ash/shell.h", # TODO(mash): Fix. https://crbug.com/647781 diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.cc b/chrome/browser/chromeos/accessibility/accessibility_manager.cc index 34e1229a10f415..06f9b75ff03dde 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager.cc +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.cc @@ -11,8 +11,9 @@ #include #include -#include "ash/accessibility/accessibility_controller.h" #include "ash/public/cpp/accelerators.h" +#include "ash/public/cpp/accessibility_controller.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "ash/public/cpp/accessibility_focus_ring_controller.h" #include "ash/public/cpp/accessibility_focus_ring_info.h" #include "ash/public/cpp/ash_pref_names.h" @@ -328,10 +329,6 @@ AccessibilityManager::AccessibilityManager() base::BindRepeating(&AccessibilityManager::PostUnloadSwitchAccess, weak_ptr_factory_.GetWeakPtr()))); - // Connect to ash's AccessibilityController interface. - content::GetSystemConnector()->BindInterface(ash::mojom::kServiceName, - &accessibility_controller_); - // Connect to the media session service. content::GetSystemConnector()->BindInterface( media_session::mojom::kServiceName, &audio_focus_manager_ptr_); @@ -397,9 +394,7 @@ void AccessibilityManager::UpdateAlwaysShowMenuFromPref() { return; // Update system tray menu visibility. - ash::Shell::Get() - ->accessibility_controller() - ->NotifyAccessibilityStatusChanged(); + ash::AccessibilityController::Get()->NotifyAccessibilityStatusChanged(); } void AccessibilityManager::EnableLargeCursor(bool enabled) { @@ -552,7 +547,7 @@ void AccessibilityManager::OnLocaleChanged() { void AccessibilityManager::OnViewFocusedInArc( const gfx::Rect& bounds_in_screen) { - accessibility_controller_->SetFocusHighlightRect(bounds_in_screen); + ash::AccessibilityController::Get()->SetFocusHighlightRect(bounds_in_screen); } bool AccessibilityManager::PlayEarcon(int sound_key, PlaySoundOption option) { @@ -745,7 +740,7 @@ void AccessibilityManager::OnMonoAudioChanged() { } void AccessibilityManager::SetDarkenScreen(bool darken) { - accessibility_controller_->SetDarkenScreen(darken); + ash::AccessibilityController::Get()->SetDarkenScreen(darken); } void AccessibilityManager::SetCaretHighlightEnabled(bool enabled) { @@ -854,8 +849,8 @@ void AccessibilityManager::RequestSelectToSpeakStateChange() { } void AccessibilityManager::OnSelectToSpeakStateChanged( - ash::mojom::SelectToSpeakState state) { - accessibility_controller_->SetSelectToSpeakState(state); + ash::SelectToSpeakState state) { + ash::AccessibilityController::Get()->SetSelectToSpeakState(state); if (select_to_speak_state_observer_for_test_) select_to_speak_state_observer_for_test_.Run(); @@ -1196,11 +1191,8 @@ void AccessibilityManager::NotifyAccessibilityStatusChanged( callback_list_.Notify(details); if (details.notification_type == ACCESSIBILITY_TOGGLE_DICTATION) { - ash::Shell::Get()->accessibility_controller()->SetDictationActive( - details.enabled); - ash::Shell::Get() - ->accessibility_controller() - ->NotifyAccessibilityStatusChanged(); + ash::AccessibilityController::Get()->SetDictationActive(details.enabled); + ash::AccessibilityController::Get()->NotifyAccessibilityStatusChanged(); return; } @@ -1209,9 +1201,7 @@ void AccessibilityManager::NotifyAccessibilityStatusChanged( // chrome and ash). if (details.notification_type == ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER || details.notification_type == ACCESSIBILITY_TOGGLE_DICTATION) { - ash::Shell::Get() - ->accessibility_controller() - ->NotifyAccessibilityStatusChanged(); + ash::AccessibilityController::Get()->NotifyAccessibilityStatusChanged(); } } @@ -1319,7 +1309,7 @@ void AccessibilityManager::Observe( return; content::FocusedNodeDetails* node_details = content::Details(details).ptr(); - accessibility_controller_->SetFocusHighlightRect( + ash::AccessibilityController::Get()->SetFocusHighlightRect( node_details->node_bounds_in_screen); break; } @@ -1329,7 +1319,7 @@ void AccessibilityManager::Observe( void AccessibilityManager::OnBrailleDisplayStateChanged( const DisplayState& display_state) { braille_display_connected_ = display_state.available; - accessibility_controller_->BrailleDisplayStateChanged( + ash::AccessibilityController::Get()->BrailleDisplayStateChanged( braille_display_connected_); UpdateBrailleImeState(); } @@ -1591,7 +1581,7 @@ void AccessibilityManager::SetCaretBounds(const gfx::Rect& bounds_in_screen) { if (!IsCaretHighlightEnabled()) return; - accessibility_controller_->SetCaretBounds(bounds_in_screen); + ash::AccessibilityController::Get()->SetCaretBounds(bounds_in_screen); if (caret_bounds_observer_for_test_) caret_bounds_observer_for_test_.Run(bounds_in_screen); @@ -1659,10 +1649,6 @@ void AccessibilityManager::SetBrailleControllerForTest( g_braille_controller_for_test = controller; } -void AccessibilityManager::FlushForTesting() { - accessibility_controller_.FlushForTesting(); -} - void AccessibilityManager::SetFocusRingObserverForTest( base::RepeatingCallback observer) { focus_ring_observer_for_test_ = observer; diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.h b/chrome/browser/chromeos/accessibility/accessibility_manager.h index d52fc1165cf6f5..b7d7582561b2ce 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager.h +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.h @@ -11,7 +11,6 @@ #include #include -#include "ash/public/interfaces/accessibility_controller.mojom.h" #include "base/callback_forward.h" #include "base/callback_list.h" #include "base/macros.h" @@ -38,6 +37,7 @@ class SwitchAccessEventHandlerDelegate; namespace ash { struct AccessibilityFocusRingInfo; +enum class SelectToSpeakState; } // namespace ash namespace gfx { @@ -203,7 +203,7 @@ class AccessibilityManager void RequestSelectToSpeakStateChange(); // Called when the Select-to-Speak extension state has changed. - void OnSelectToSpeakStateChanged(ash::mojom::SelectToSpeakState state); + void OnSelectToSpeakStateChanged(ash::SelectToSpeakState state); // Invoked to enable or disable switch access. void SetSwitchAccessEnabled(bool enabled); @@ -341,7 +341,6 @@ class AccessibilityManager void SetProfileForTest(Profile* profile); static void SetBrailleControllerForTest( extensions::api::braille_display_private::BrailleController* controller); - void FlushForTesting(); void SetFocusRingObserverForTest(base::RepeatingCallback observer); void SetSelectToSpeakStateObserverForTest( base::RepeatingCallback observer); @@ -473,9 +472,6 @@ class AccessibilityManager std::unique_ptr switch_access_event_handler_delegate_; - // Ash's mojom::AccessibilityController used to request Ash's a11y feature. - ash::mojom::AccessibilityControllerPtr accessibility_controller_; - std::map> focus_ring_names_for_extension_id_; diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc b/chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc index f38c24fa6f1456..5dabecf24bdf1e 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc +++ b/chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc @@ -554,7 +554,6 @@ class AccessibilityManagerLoginTest : public OobeBaseTest { braille_controller_.SetAvailable(available); braille_controller_.GetObserver()->OnBrailleDisplayStateChanged( *braille_controller_.GetDisplayState()); - AccessibilityManager::Get()->FlushForTesting(); } int default_autoclick_delay_ = 0; @@ -677,7 +676,6 @@ class AccessibilityManagerUserTypeTest : public AccessibilityManagerTest, braille_controller_.SetAvailable(available); braille_controller_.GetObserver()->OnBrailleDisplayStateChanged( *braille_controller_.GetDisplayState()); - AccessibilityManager::Get()->FlushForTesting(); } MockBrailleController braille_controller_; diff --git a/chrome/browser/chromeos/accessibility/accessibility_panel.cc b/chrome/browser/chromeos/accessibility/accessibility_panel.cc index 10da994411c53c..ee413394184910 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_panel.cc +++ b/chrome/browser/chromeos/accessibility/accessibility_panel.cc @@ -5,7 +5,6 @@ #include "chrome/browser/chromeos/accessibility/accessibility_panel.h" #include "ash/public/cpp/shell_window_ids.h" -#include "ash/public/interfaces/accessibility_controller.mojom.h" #include "base/macros.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" @@ -73,16 +72,6 @@ AccessibilityPanel::AccessibilityPanel(content::BrowserContext* browser_context, AccessibilityPanel::~AccessibilityPanel() = default; -// static -ash::mojom::AccessibilityControllerPtr -AccessibilityPanel::GetAccessibilityController() { - // Connect to the accessibility mojo interface in ash. - ash::mojom::AccessibilityControllerPtr accessibility_controller; - content::GetSystemConnector()->BindInterface(ash::mojom::kServiceName, - &accessibility_controller); - return accessibility_controller; -} - void AccessibilityPanel::CloseNow() { widget_->CloseNow(); } diff --git a/chrome/browser/chromeos/accessibility/accessibility_panel.h b/chrome/browser/chromeos/accessibility/accessibility_panel.h index 6f39b0d0b13f59..06f1b3908bc4dc 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_panel.h +++ b/chrome/browser/chromeos/accessibility/accessibility_panel.h @@ -7,8 +7,6 @@ #include -#include "ash/public/interfaces/accessibility_controller.mojom.h" -#include "ash/public/interfaces/constants.mojom.h" #include "base/macros.h" #include "content/public/browser/web_contents_delegate.h" #include "ui/views/widget/widget_delegate.h" @@ -48,7 +46,6 @@ class AccessibilityPanel : public views::WidgetDelegate, protected: // Returns the web contents, so subclasses can monitor for changes. content::WebContents* GetWebContents(); - static ash::mojom::AccessibilityControllerPtr GetAccessibilityController(); private: class AccessibilityPanelWebContentsObserver; diff --git a/chrome/browser/chromeos/accessibility/chromevox_panel.cc b/chrome/browser/chromeos/accessibility/chromevox_panel.cc index 11cb323980cd5e..d3d7d2ef78c9e8 100644 --- a/chrome/browser/chromeos/accessibility/chromevox_panel.cc +++ b/chrome/browser/chromeos/accessibility/chromevox_panel.cc @@ -4,8 +4,8 @@ #include "chrome/browser/chromeos/accessibility/chromevox_panel.h" -#include "ash/public/interfaces/accessibility_controller.mojom.h" -#include "ash/public/interfaces/constants.mojom.h" +#include "ash/public/cpp/accessibility_controller.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/common/service_manager_connection.h" @@ -82,9 +82,10 @@ void ChromeVoxPanel::Focus() { void ChromeVoxPanel::SetAccessibilityPanelFullscreen(bool fullscreen) { gfx::Rect bounds(0, 0, 0, kPanelHeight); - auto state = fullscreen ? ash::mojom::AccessibilityPanelState::FULLSCREEN - : ash::mojom::AccessibilityPanelState::FULL_WIDTH; - GetAccessibilityController()->SetAccessibilityPanelBounds(bounds, state); + auto state = fullscreen ? ash::AccessibilityPanelState::FULLSCREEN + : ash::AccessibilityPanelState::FULL_WIDTH; + ash::AccessibilityController::Get()->SetAccessibilityPanelBounds(bounds, + state); } std::string ChromeVoxPanel::GetUrlForContent() { diff --git a/chrome/browser/chromeos/accessibility/select_to_speak_event_handler_delegate.cc b/chrome/browser/chromeos/accessibility/select_to_speak_event_handler_delegate.cc index ee7603d37e9753..664c560b0c5e3e 100644 --- a/chrome/browser/chromeos/accessibility/select_to_speak_event_handler_delegate.cc +++ b/chrome/browser/chromeos/accessibility/select_to_speak_event_handler_delegate.cc @@ -6,18 +6,15 @@ #include -#include "ash/public/interfaces/constants.mojom.h" -#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" +#include "ash/public/cpp/accessibility_controller.h" #include "chrome/browser/chromeos/accessibility/event_handler_common.h" #include "chrome/common/extensions/extension_constants.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host.h" -#include "content/public/browser/system_connector.h" #include "content/public/browser/web_contents.h" #include "extensions/browser/event_router.h" #include "extensions/browser/extension_host.h" -#include "services/service_manager/public/cpp/connector.h" #include "third_party/blink/public/platform/web_mouse_event.h" #include "ui/content_accelerators/accelerator_util.h" #include "ui/events/blink/web_input_event.h" @@ -25,43 +22,38 @@ namespace chromeos { -SelectToSpeakEventHandlerDelegate::SelectToSpeakEventHandlerDelegate() - : binding_(this) { - // Connect to ash's AccessibilityController interface. - ash::mojom::AccessibilityControllerPtr accessibility_controller; - content::GetSystemConnector()->BindInterface(ash::mojom::kServiceName, - &accessibility_controller); - +SelectToSpeakEventHandlerDelegate::SelectToSpeakEventHandlerDelegate() { // Set this object as the SelectToSpeakEventHandlerDelegate. - ash::mojom::SelectToSpeakEventHandlerDelegatePtr ptr; - binding_.Bind(mojo::MakeRequest(&ptr)); - accessibility_controller->SetSelectToSpeakEventHandlerDelegate( - std::move(ptr)); + ash::AccessibilityController::Get()->SetSelectToSpeakEventHandlerDelegate( + this); } -SelectToSpeakEventHandlerDelegate::~SelectToSpeakEventHandlerDelegate() = - default; +SelectToSpeakEventHandlerDelegate::~SelectToSpeakEventHandlerDelegate() { + if (auto* controller = ash::AccessibilityController::Get()) + controller->SetSelectToSpeakEventHandlerDelegate(nullptr); +} void SelectToSpeakEventHandlerDelegate::DispatchKeyEvent( - std::unique_ptr event) { + const ui::KeyEvent& event) { // We can only call the STS extension on the UI thread, make sure we // don't ever try to run this code on some other thread. DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - DCHECK(event->IsKeyEvent()); extensions::ExtensionHost* host = chromeos::GetAccessibilityExtensionHost( extension_misc::kSelectToSpeakExtensionId); if (!host) return; - const ui::KeyEvent* key_event = event->AsKeyEvent(); + const ui::KeyEvent* key_event = event.AsKeyEvent(); chromeos::ForwardKeyToExtension(*key_event, host); } void SelectToSpeakEventHandlerDelegate::DispatchMouseEvent( - std::unique_ptr event) { + const ui::MouseEvent& event) { + // We can only call the STS extension on the UI thread, make sure we + // don't ever try to run this code on some other thread. DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - DCHECK(event->IsMouseEvent()); + extensions::ExtensionHost* host = chromeos::GetAccessibilityExtensionHost( extension_misc::kSelectToSpeakExtensionId); if (!host) @@ -71,8 +63,7 @@ void SelectToSpeakEventHandlerDelegate::DispatchMouseEvent( if (!rvh) return; - const ui::MouseEvent* mouse_event = event->AsMouseEvent(); - rvh->GetWidget()->ForwardMouseEvent(ui::MakeWebMouseEvent(*mouse_event)); + rvh->GetWidget()->ForwardMouseEvent(ui::MakeWebMouseEvent(event)); } } // namespace chromeos diff --git a/chrome/browser/chromeos/accessibility/select_to_speak_event_handler_delegate.h b/chrome/browser/chromeos/accessibility/select_to_speak_event_handler_delegate.h index f90ca43e25bcb2..37b375dec6e11c 100644 --- a/chrome/browser/chromeos/accessibility/select_to_speak_event_handler_delegate.h +++ b/chrome/browser/chromeos/accessibility/select_to_speak_event_handler_delegate.h @@ -5,32 +5,23 @@ #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SELECT_TO_SPEAK_EVENT_HANDLER_DELEGATE_H_ #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SELECT_TO_SPEAK_EVENT_HANDLER_DELEGATE_H_ -#include - -#include "ash/public/interfaces/accessibility_controller.mojom.h" +#include "ash/public/cpp/select_to_speak_event_handler_delegate.h" #include "base/macros.h" -#include "mojo/public/cpp/bindings/binding.h" -#include "ui/events/event.h" namespace chromeos { -// SelectToSpeakEventHandlerDelegate receives mouse and key events and forwards -// them to the Select-to-Speak extension in Chrome. The -// SelectToSpeakEventHandler in the Ash process handles events and passes them -// to this delegate via a Mojo interface defined in -// accessibility_controller.mojom. +// SelectToSpeakEventHandlerDelegate receives mouse and key events from Ash's +// event handler and forwards them to the Select-to-Speak extension in Chrome. class SelectToSpeakEventHandlerDelegate - : public ash::mojom::SelectToSpeakEventHandlerDelegate { + : public ash::SelectToSpeakEventHandlerDelegate { public: SelectToSpeakEventHandlerDelegate(); - ~SelectToSpeakEventHandlerDelegate() override; + virtual ~SelectToSpeakEventHandlerDelegate(); private: - // ash::mojom::SelectToSpeakEventHandlerDelegate: - void DispatchKeyEvent(std::unique_ptr event) override; - void DispatchMouseEvent(std::unique_ptr event) override; - - mojo::Binding binding_; + // ash::SelectToSpeakEventHandlerDelegate: + void DispatchKeyEvent(const ui::KeyEvent& event) override; + void DispatchMouseEvent(const ui::MouseEvent& event) override; DISALLOW_COPY_AND_ASSIGN(SelectToSpeakEventHandlerDelegate); }; diff --git a/chrome/browser/chromeos/accessibility/switch_access_browsertest.cc b/chrome/browser/chromeos/accessibility/switch_access_browsertest.cc index a57f8a2c9bcc72..64eb058e59f708 100644 --- a/chrome/browser/chromeos/accessibility/switch_access_browsertest.cc +++ b/chrome/browser/chromeos/accessibility/switch_access_browsertest.cc @@ -2,32 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/public/interfaces/accessibility_controller.mojom.h" +#include "ash/public/cpp/accessibility_controller.h" #include "base/command_line.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/interactive_test_utils.h" #include "chromeos/constants/chromeos_switches.h" -#include "content/public/browser/system_connector.h" #include "content/public/test/browser_test_utils.h" -#include "services/service_manager/public/cpp/connector.h" #include "ui/accessibility/accessibility_switches.h" namespace chromeos { -namespace { - -ash::mojom::AccessibilityControllerPtr GetAccessibilityController() { - // Connect to the accessibility mojo interface in ash. - ash::mojom::AccessibilityControllerPtr controller; - content::GetSystemConnector()->BindInterface(ash::mojom::kServiceName, - &controller); - return controller; -} - -} // namespace - class SwitchAccessTest : public InProcessBrowserTest { public: void SendVirtualKeyPress(ui::KeyboardCode key) { @@ -41,7 +27,8 @@ class SwitchAccessTest : public InProcessBrowserTest { AccessibilityManager* manager = AccessibilityManager::Get(); manager->SetSwitchAccessEnabled(true); - GetAccessibilityController()->SetSwitchAccessKeysToCapture(key_codes); + ash::AccessibilityController::Get()->SetSwitchAccessKeysToCapture( + key_codes); EXPECT_TRUE(manager->IsSwitchAccessEnabled()); } diff --git a/chrome/browser/chromeos/accessibility/switch_access_event_handler_delegate.cc b/chrome/browser/chromeos/accessibility/switch_access_event_handler_delegate.cc index 90523807584699..490c303bf6f926 100644 --- a/chrome/browser/chromeos/accessibility/switch_access_event_handler_delegate.cc +++ b/chrome/browser/chromeos/accessibility/switch_access_event_handler_delegate.cc @@ -6,35 +6,34 @@ #include -#include "ash/public/interfaces/constants.mojom.h" +#include "ash/public/cpp/accessibility_controller.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/accessibility/event_handler_common.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/common/extensions/api/accessibility_private.h" #include "chrome/common/extensions/extension_constants.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/system_connector.h" #include "extensions/browser/event_router.h" #include "extensions/browser/extension_host.h" -#include "services/service_manager/public/cpp/connector.h" #include "ui/events/event.h" namespace { std::string AccessibilityPrivateEnumForCommand( - ash::mojom::SwitchAccessCommand command) { + ash::SwitchAccessCommand command) { switch (command) { - case ash::mojom::SwitchAccessCommand::kSelect: + case ash::SwitchAccessCommand::kSelect: return extensions::api::accessibility_private::ToString( extensions::api::accessibility_private::SWITCH_ACCESS_COMMAND_SELECT); - case ash::mojom::SwitchAccessCommand::kNext: + case ash::SwitchAccessCommand::kNext: return extensions::api::accessibility_private::ToString( extensions::api::accessibility_private::SWITCH_ACCESS_COMMAND_NEXT); - case ash::mojom::SwitchAccessCommand::kPrevious: + case ash::SwitchAccessCommand::kPrevious: return extensions::api::accessibility_private::ToString( extensions::api::accessibility_private:: SWITCH_ACCESS_COMMAND_PREVIOUS); - case ash::mojom::SwitchAccessCommand::kNone: + case ash::SwitchAccessCommand::kNone: NOTREACHED(); return ""; } @@ -42,39 +41,32 @@ std::string AccessibilityPrivateEnumForCommand( } // namespace -SwitchAccessEventHandlerDelegate::SwitchAccessEventHandlerDelegate() - : binding_(this) { - // Connect to ash's AccessibilityController interface. - ash::mojom::AccessibilityControllerPtr accessibility_controller; - content::GetSystemConnector()->BindInterface(ash::mojom::kServiceName, - &accessibility_controller); - - // Set this object as the SwitchAccessEventHandlerDelegate. - ash::mojom::SwitchAccessEventHandlerDelegatePtr ptr; - binding_.Bind(mojo::MakeRequest(&ptr)); - accessibility_controller->SetSwitchAccessEventHandlerDelegate(std::move(ptr)); +SwitchAccessEventHandlerDelegate::SwitchAccessEventHandlerDelegate() { + ash::AccessibilityController::Get()->SetSwitchAccessEventHandlerDelegate( + this); } -SwitchAccessEventHandlerDelegate::~SwitchAccessEventHandlerDelegate() = default; +SwitchAccessEventHandlerDelegate::~SwitchAccessEventHandlerDelegate() { + if (auto* controller = ash::AccessibilityController::Get()) + controller->SetSwitchAccessEventHandlerDelegate(nullptr); +} void SwitchAccessEventHandlerDelegate::DispatchKeyEvent( - std::unique_ptr event) { + const ui::KeyEvent& event) { // We can only call the Switch Access extension on the UI thread, make sure we // don't ever try to run this code on some other thread. DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - DCHECK(event->IsKeyEvent()); extensions::ExtensionHost* host = chromeos::GetAccessibilityExtensionHost( extension_misc::kSwitchAccessExtensionId); if (!host) return; - const ui::KeyEvent* key_event = event->AsKeyEvent(); - chromeos::ForwardKeyToExtension(*key_event, host); + chromeos::ForwardKeyToExtension(event, host); } void SwitchAccessEventHandlerDelegate::SendSwitchAccessCommand( - ash::mojom::SwitchAccessCommand command) { + ash::SwitchAccessCommand command) { extensions::EventRouter* event_router = extensions::EventRouter::Get( chromeos::AccessibilityManager::Get()->profile()); diff --git a/chrome/browser/chromeos/accessibility/switch_access_event_handler_delegate.h b/chrome/browser/chromeos/accessibility/switch_access_event_handler_delegate.h index 07af077cc13b9a..062ed61851bdf4 100644 --- a/chrome/browser/chromeos/accessibility/switch_access_event_handler_delegate.h +++ b/chrome/browser/chromeos/accessibility/switch_access_event_handler_delegate.h @@ -5,28 +5,25 @@ #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SWITCH_ACCESS_EVENT_HANDLER_DELEGATE_H_ #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SWITCH_ACCESS_EVENT_HANDLER_DELEGATE_H_ -#include "ash/public/interfaces/accessibility_controller.mojom.h" +#include "ash/public/cpp/switch_access_event_handler_delegate.h" #include "base/macros.h" -#include "mojo/public/cpp/bindings/binding.h" -#include "ui/events/event.h" -// SwitchAccessEventHandlerDelegate receives mouse and key events and forwards -// them to the Switch Access extension in Chrome. The SwitchAccessEventHandler -// in the Ash process handles events and passes them to this delegate via a Mojo -// interface defined in accessibility_controller.mojom. +namespace ash { +enum class SwitchAccessCommand; +} + +// SwitchAccessEventHandlerDelegate receives mouse and key events from Ash's +// event handler and forwards them to the Switch Access extension in Chrome. class SwitchAccessEventHandlerDelegate - : public ash::mojom::SwitchAccessEventHandlerDelegate { + : public ash::SwitchAccessEventHandlerDelegate { public: SwitchAccessEventHandlerDelegate(); - ~SwitchAccessEventHandlerDelegate() override; + virtual ~SwitchAccessEventHandlerDelegate(); private: - // ash::mojom::SwitchAccessEventHandlerDelegate: - void DispatchKeyEvent(std::unique_ptr event) override; - void SendSwitchAccessCommand( - ash::mojom::SwitchAccessCommand command) override; - - mojo::Binding binding_; + // ash::SwitchAccessEventHandlerDelegate: + void DispatchKeyEvent(const ui::KeyEvent& event) override; + void SendSwitchAccessCommand(ash::SwitchAccessCommand command) override; DISALLOW_COPY_AND_ASSIGN(SwitchAccessEventHandlerDelegate); }; diff --git a/chrome/browser/chromeos/accessibility/switch_access_panel.cc b/chrome/browser/chromeos/accessibility/switch_access_panel.cc index 03afc139d3e975..2eab16be124d3c 100644 --- a/chrome/browser/chromeos/accessibility/switch_access_panel.cc +++ b/chrome/browser/chromeos/accessibility/switch_access_panel.cc @@ -4,11 +4,9 @@ #include "chrome/browser/chromeos/accessibility/switch_access_panel.h" -#include "ash/public/interfaces/accessibility_controller.mojom.h" -#include "ash/public/interfaces/constants.mojom.h" +#include "ash/public/cpp/accessibility_controller.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "base/no_destructor.h" -#include "content/public/common/service_manager_connection.h" -#include "services/service_manager/public/cpp/connector.h" #include "ui/display/display.h" #include "ui/display/screen.h" #include "ui/views/widget/widget.h" @@ -52,16 +50,16 @@ void SwitchAccessPanel::Show(const gfx::Rect& element_bounds, CalculatePanelBounds(element_bounds, screen_bounds, width, height); } - GetAccessibilityController()->SetAccessibilityPanelBounds( - panel_bounds, ash::mojom::AccessibilityPanelState::BOUNDED); + ash::AccessibilityController::Get()->SetAccessibilityPanelBounds( + panel_bounds, ash::AccessibilityPanelState::BOUNDED); } void SwitchAccessPanel::Hide() { // This isn't set to (0, 0, 0, 0) because the drop shadow remains visible. // TODO(crbug/911344): Find the root cause and fix it. gfx::Rect bounds(-1, -1, 1, 1); - GetAccessibilityController()->SetAccessibilityPanelBounds( - bounds, ash::mojom::AccessibilityPanelState::BOUNDED); + ash::AccessibilityController::Get()->SetAccessibilityPanelBounds( + bounds, ash::AccessibilityPanelState::BOUNDED); } const gfx::Rect SwitchAccessPanel::CalculatePanelBounds( diff --git a/chrome/browser/ui/ash/accessibility/accessibility_controller_client.cc b/chrome/browser/ui/ash/accessibility/accessibility_controller_client.cc index befb4ee95c0a4d..c3c8c9a992eccf 100644 --- a/chrome/browser/ui/ash/accessibility/accessibility_controller_client.cc +++ b/chrome/browser/ui/ash/accessibility/accessibility_controller_client.cc @@ -4,14 +4,13 @@ #include "chrome/browser/ui/ash/accessibility/accessibility_controller_client.h" -#include "ash/public/interfaces/constants.mojom.h" +#include "ash/public/cpp/accessibility_controller.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" #include "chrome/grit/generated_resources.h" -#include "content/public/browser/system_connector.h" #include "content/public/browser/tts_controller.h" -#include "services/service_manager/public/cpp/connector.h" #include "ui/base/l10n/l10n_util.h" namespace { @@ -28,56 +27,53 @@ void SetAutomationManagerEnabled(content::BrowserContext* context, } // namespace -AccessibilityControllerClient::AccessibilityControllerClient() - : binding_(this) {} - -AccessibilityControllerClient::~AccessibilityControllerClient() = default; +AccessibilityControllerClient::AccessibilityControllerClient() { + ash::AccessibilityController::Get()->SetClient(this); +} -void AccessibilityControllerClient::Init() { - content::GetSystemConnector()->BindInterface(ash::mojom::kServiceName, - &accessibility_controller_); - BindAndSetClient(); +AccessibilityControllerClient::~AccessibilityControllerClient() { + ash::AccessibilityController::Get()->SetClient(nullptr); } void AccessibilityControllerClient::TriggerAccessibilityAlert( - ash::mojom::AccessibilityAlert alert) { + ash::AccessibilityAlert alert) { Profile* profile = ProfileManager::GetActiveUserProfile(); if (!profile) return; int msg = 0; switch (alert) { - case ash::mojom::AccessibilityAlert::CAPS_ON: + case ash::AccessibilityAlert::CAPS_ON: msg = IDS_A11Y_ALERT_CAPS_ON; break; - case ash::mojom::AccessibilityAlert::CAPS_OFF: + case ash::AccessibilityAlert::CAPS_OFF: msg = IDS_A11Y_ALERT_CAPS_OFF; break; - case ash::mojom::AccessibilityAlert::SCREEN_ON: + case ash::AccessibilityAlert::SCREEN_ON: // Enable automation manager when alert is screen-on, as it is // previously disabled by alert screen-off. SetAutomationManagerEnabled(profile, true); msg = IDS_A11Y_ALERT_SCREEN_ON; break; - case ash::mojom::AccessibilityAlert::SCREEN_OFF: + case ash::AccessibilityAlert::SCREEN_OFF: msg = IDS_A11Y_ALERT_SCREEN_OFF; break; - case ash::mojom::AccessibilityAlert::WINDOW_MOVED_TO_ANOTHER_DISPLAY: + case ash::AccessibilityAlert::WINDOW_MOVED_TO_ANOTHER_DISPLAY: msg = IDS_A11Y_ALERT_WINDOW_MOVED_TO_ANOTHER_DISPLAY; break; - case ash::mojom::AccessibilityAlert::WINDOW_NEEDED: + case ash::AccessibilityAlert::WINDOW_NEEDED: msg = IDS_A11Y_ALERT_WINDOW_NEEDED; break; - case ash::mojom::AccessibilityAlert::WINDOW_OVERVIEW_MODE_ENTERED: + case ash::AccessibilityAlert::WINDOW_OVERVIEW_MODE_ENTERED: msg = IDS_A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED; break; - case ash::mojom::AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_ENTERED: + case ash::AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_ENTERED: msg = IDS_A11Y_ALERT_WORKSPACE_FULLSCREEN_STATE_ENTERED; break; - case ash::mojom::AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_EXITED: + case ash::AccessibilityAlert::WORKSPACE_FULLSCREEN_STATE_EXITED: msg = IDS_A11Y_ALERT_WORKSPACE_FULLSCREEN_STATE_EXITED; break; - case ash::mojom::AccessibilityAlert::NONE: + case ash::AccessibilityAlert::NONE: msg = 0; break; } @@ -87,7 +83,7 @@ void AccessibilityControllerClient::TriggerAccessibilityAlert( l10n_util::GetStringUTF8(msg)); // After handling the alert, if the alert is screen-off, we should // disable automation manager to handle any following a11y events. - if (alert == ash::mojom::AccessibilityAlert::SCREEN_OFF) + if (alert == ash::AccessibilityAlert::SCREEN_OFF) SetAutomationManagerEnabled(profile, false); } } @@ -97,11 +93,8 @@ void AccessibilityControllerClient::PlayEarcon(int32_t sound_key) { sound_key, chromeos::PlaySoundOption::ONLY_IF_SPOKEN_FEEDBACK_ENABLED); } -void AccessibilityControllerClient::PlayShutdownSound( - PlayShutdownSoundCallback callback) { - base::TimeDelta sound_duration = - chromeos::AccessibilityManager::Get()->PlayShutdownSound(); - std::move(callback).Run(sound_duration); +base::TimeDelta AccessibilityControllerClient::PlayShutdownSound() { + return chromeos::AccessibilityManager::Get()->PlayShutdownSound(); } void AccessibilityControllerClient::HandleAccessibilityGesture( @@ -109,11 +102,8 @@ void AccessibilityControllerClient::HandleAccessibilityGesture( chromeos::AccessibilityManager::Get()->HandleAccessibilityGesture(gesture); } -void AccessibilityControllerClient::ToggleDictation( - ToggleDictationCallback callback) { - bool dictation_active = - chromeos::AccessibilityManager::Get()->ToggleDictation(); - std::move(callback).Run(dictation_active); +bool AccessibilityControllerClient::ToggleDictation() { + return chromeos::AccessibilityManager::Get()->ToggleDictation(); } void AccessibilityControllerClient::SilenceSpokenFeedback() { @@ -128,10 +118,9 @@ void AccessibilityControllerClient::OnTwoFingerTouchStop() { chromeos::AccessibilityManager::Get()->OnTwoFingerTouchStop(); } -void AccessibilityControllerClient::ShouldToggleSpokenFeedbackViaTouch( - ShouldToggleSpokenFeedbackViaTouchCallback callback) { - std::move(callback).Run(chromeos::AccessibilityManager::Get() - ->ShouldToggleSpokenFeedbackViaTouch()); +bool AccessibilityControllerClient::ShouldToggleSpokenFeedbackViaTouch() const { + return chromeos::AccessibilityManager::Get() + ->ShouldToggleSpokenFeedbackViaTouch(); } void AccessibilityControllerClient::PlaySpokenFeedbackToggleCountdown( @@ -143,13 +132,3 @@ void AccessibilityControllerClient::PlaySpokenFeedbackToggleCountdown( void AccessibilityControllerClient::RequestSelectToSpeakStateChange() { chromeos::AccessibilityManager::Get()->RequestSelectToSpeakStateChange(); } - -void AccessibilityControllerClient::FlushForTesting() { - accessibility_controller_.FlushForTesting(); -} - -void AccessibilityControllerClient::BindAndSetClient() { - ash::mojom::AccessibilityControllerClientPtr client; - binding_.Bind(mojo::MakeRequest(&client)); - accessibility_controller_->SetClient(std::move(client)); -} diff --git a/chrome/browser/ui/ash/accessibility/accessibility_controller_client.h b/chrome/browser/ui/ash/accessibility/accessibility_controller_client.h index 8ea9e4e35e4ef6..0057b14fae8038 100644 --- a/chrome/browser/ui/ash/accessibility/accessibility_controller_client.h +++ b/chrome/browser/ui/ash/accessibility/accessibility_controller_client.h @@ -5,49 +5,30 @@ #ifndef CHROME_BROWSER_UI_ASH_ACCESSIBILITY_ACCESSIBILITY_CONTROLLER_CLIENT_H_ #define CHROME_BROWSER_UI_ASH_ACCESSIBILITY_ACCESSIBILITY_CONTROLLER_CLIENT_H_ -#include "ash/public/interfaces/accessibility_controller.mojom.h" +#include "ash/public/cpp/accessibility_controller_client.h" #include "base/macros.h" -#include "mojo/public/cpp/bindings/binding.h" -#include "ui/accessibility/ax_enums.mojom.h" -// Handles method calls from ash to do accessibility related service in chrome. +// Handles method calls from ash to do accessibility-related work in chrome. class AccessibilityControllerClient - : public ash::mojom::AccessibilityControllerClient { + : public ash::AccessibilityControllerClient { public: AccessibilityControllerClient(); - ~AccessibilityControllerClient() override; + virtual ~AccessibilityControllerClient(); - // Initializes and connects to ash. - void Init(); - - // ash::mojom::AccessibilityControllerClient: - void TriggerAccessibilityAlert(ash::mojom::AccessibilityAlert alert) override; - void PlayEarcon(int32_t sound_key) override; - void PlayShutdownSound(PlayShutdownSoundCallback callback) override; + // ash::AccessibilityControllerClient: + void TriggerAccessibilityAlert(ash::AccessibilityAlert alert) override; + void PlayEarcon(int sound_key) override; + base::TimeDelta PlayShutdownSound() override; void HandleAccessibilityGesture(ax::mojom::Gesture gesture) override; - void ToggleDictation(ToggleDictationCallback callback) override; + bool ToggleDictation() override; void SilenceSpokenFeedback() override; void OnTwoFingerTouchStart() override; void OnTwoFingerTouchStop() override; - void ShouldToggleSpokenFeedbackViaTouch( - ShouldToggleSpokenFeedbackViaTouchCallback callback) override; + bool ShouldToggleSpokenFeedbackViaTouch() const override; void PlaySpokenFeedbackToggleCountdown(int tick_count) override; void RequestSelectToSpeakStateChange() override; - // Flushes the mojo pipe to ash. - void FlushForTesting(); - private: - // Binds this object to its mojo interface and sets it as the ash client. - void BindAndSetClient(); - - // Binds to the client interface. - mojo::Binding binding_; - - // AccessibilityController interface in ash. Holding the interface pointer - // keeps the pipe alive to receive mojo return values. - ash::mojom::AccessibilityControllerPtr accessibility_controller_; - DISALLOW_COPY_AND_ASSIGN(AccessibilityControllerClient); }; diff --git a/chrome/browser/ui/ash/accessibility/accessibility_controller_client_unittest.cc b/chrome/browser/ui/ash/accessibility/accessibility_controller_client_unittest.cc index f1b008520a4e19..22c02f1da4bafe 100644 --- a/chrome/browser/ui/ash/accessibility/accessibility_controller_client_unittest.cc +++ b/chrome/browser/ui/ash/accessibility/accessibility_controller_client_unittest.cc @@ -4,16 +4,13 @@ #include "chrome/browser/ui/ash/accessibility/accessibility_controller_client.h" -#include "ash/public/interfaces/accessibility_controller.mojom.h" -#include "base/bind.h" +#include "ash/public/cpp/accessibility_controller_enums.h" #include "base/macros.h" -#include "base/run_loop.h" #include "base/time/time.h" #include "chrome/browser/ui/ash/accessibility/fake_accessibility_controller.h" #include "chromeos/audio/chromeos_sounds.h" #include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_service_manager_context.h" -#include "mojo/public/cpp/bindings/binding.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/accessibility/ax_enums.mojom.h" @@ -28,48 +25,33 @@ class FakeAccessibilityControllerClient : public AccessibilityControllerClient { ~FakeAccessibilityControllerClient() override = default; // AccessibilityControllerClient: - void TriggerAccessibilityAlert( - ash::mojom::AccessibilityAlert alert) override { + void TriggerAccessibilityAlert(ash::AccessibilityAlert alert) override { last_a11y_alert_ = alert; } - void PlayEarcon(int32_t sound_key) override { last_sound_key_ = sound_key; } - - void PlayShutdownSound(PlayShutdownSoundCallback callback) override { - std::move(callback).Run(kShutdownSoundDuration); + base::TimeDelta PlayShutdownSound() override { + return kShutdownSoundDuration; } - void HandleAccessibilityGesture(ax::mojom::Gesture gesture) override { last_a11y_gesture_ = gesture; } - - void ToggleDictation(ToggleDictationCallback callback) override { + bool ToggleDictation() override { ++toggle_dictation_count_; dictation_on_ = !dictation_on_; - std::move(callback).Run(dictation_on_); + return dictation_on_; } - void SilenceSpokenFeedback() override { ++silence_spoken_feedback_count_; } - void OnTwoFingerTouchStart() override { ++on_two_finger_touch_start_count_; } - void OnTwoFingerTouchStop() override { ++on_two_finger_touch_stop_count_; } - - void ShouldToggleSpokenFeedbackViaTouch( - ShouldToggleSpokenFeedbackViaTouchCallback callback) override { - std::move(callback).Run(true); - } - + bool ShouldToggleSpokenFeedbackViaTouch() const override { return true; } void PlaySpokenFeedbackToggleCountdown(int tick_count) override { spoken_feedback_toggle_count_down_ = tick_count; } - void RequestSelectToSpeakStateChange() override { ++select_to_speak_state_changes_; } - ash::mojom::AccessibilityAlert last_a11y_alert_ = - ash::mojom::AccessibilityAlert::NONE; + ash::AccessibilityAlert last_a11y_alert_ = ash::AccessibilityAlert::NONE; int32_t last_sound_key_ = -1; ax::mojom::Gesture last_a11y_gesture_ = ax::mojom::Gesture::kNone; int toggle_dictation_count_ = 0; @@ -80,8 +62,8 @@ class FakeAccessibilityControllerClient : public AccessibilityControllerClient { int select_to_speak_state_changes_ = 0; private: - DISALLOW_COPY_AND_ASSIGN(FakeAccessibilityControllerClient); bool dictation_on_ = false; + DISALLOW_COPY_AND_ASSIGN(FakeAccessibilityControllerClient); }; } // namespace @@ -99,17 +81,14 @@ class AccessibilityControllerClientTest : public testing::Test { }; TEST_F(AccessibilityControllerClientTest, MethodCalls) { - FakeAccessibilityControllerClient client; FakeAccessibilityController controller; - client.Init(); - client.FlushForTesting(); + FakeAccessibilityControllerClient client; // Tests client is set. EXPECT_TRUE(controller.was_client_set()); // Tests TriggerAccessibilityAlert method call. - const ash::mojom::AccessibilityAlert alert = - ash::mojom::AccessibilityAlert::SCREEN_ON; + const ash::AccessibilityAlert alert = ash::AccessibilityAlert::SCREEN_ON; client.TriggerAccessibilityAlert(alert); EXPECT_EQ(alert, client.last_a11y_alert_); @@ -119,12 +98,7 @@ TEST_F(AccessibilityControllerClientTest, MethodCalls) { EXPECT_EQ(sound_key, client.last_sound_key_); // Tests PlayShutdownSound method call. - base::TimeDelta sound_duration; - client.PlayShutdownSound(base::BindOnce( - [](base::TimeDelta* dst, base::TimeDelta duration) { *dst = duration; }, - base::Unretained(&sound_duration))); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(kShutdownSoundDuration, sound_duration); + EXPECT_EQ(kShutdownSoundDuration, client.PlayShutdownSound()); // Tests HandleAccessibilityGesture method call. ax::mojom::Gesture gesture = ax::mojom::Gesture::kClick; @@ -133,7 +107,7 @@ TEST_F(AccessibilityControllerClientTest, MethodCalls) { // Tests ToggleDictation method call. EXPECT_EQ(0, client.toggle_dictation_count_); - client.ToggleDictation(base::BindOnce([](bool b) {})); + EXPECT_TRUE(client.ToggleDictation()); EXPECT_EQ(1, client.toggle_dictation_count_); EXPECT_EQ(0, client.silence_spoken_feedback_count_); @@ -151,12 +125,7 @@ TEST_F(AccessibilityControllerClientTest, MethodCalls) { EXPECT_EQ(1, client.on_two_finger_touch_stop_count_); // Tests ShouldToggleSpokenFeedbackViaTouch method call. - bool should_toggle = false; - client.ShouldToggleSpokenFeedbackViaTouch(base::BindOnce( - [](bool* dst, bool should_toggle) { *dst = should_toggle; }, - base::Unretained(&should_toggle))); - base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(should_toggle); + EXPECT_TRUE(client.ShouldToggleSpokenFeedbackViaTouch()); // Tests PlaySpokenFeedbackToggleCountdown method call. const int tick_count = 2; diff --git a/chrome/browser/ui/ash/accessibility/fake_accessibility_controller.cc b/chrome/browser/ui/ash/accessibility/fake_accessibility_controller.cc index 36798cc1968884..013c32597fcb06 100644 --- a/chrome/browser/ui/ash/accessibility/fake_accessibility_controller.cc +++ b/chrome/browser/ui/ash/accessibility/fake_accessibility_controller.cc @@ -4,35 +4,15 @@ #include "chrome/browser/ui/ash/accessibility/fake_accessibility_controller.h" -#include - -#include "ash/public/interfaces/constants.mojom.h" -#include "base/bind.h" -#include "content/public/browser/system_connector.h" -#include "services/service_manager/public/cpp/connector.h" -#include "services/service_manager/public/cpp/service_filter.h" - -FakeAccessibilityController::FakeAccessibilityController() { - CHECK(content::GetSystemConnector()) - << "ServiceManager is uninitialized. Did you forget to create a " - "content::TestServiceManagerContext?"; - content::GetSystemConnector()->OverrideBinderForTesting( - service_manager::ServiceFilter::ByName(ash::mojom::kServiceName), - ash::mojom::AccessibilityController::Name_, - base::BindRepeating(&FakeAccessibilityController::Bind, - base::Unretained(this))); -} +FakeAccessibilityController::FakeAccessibilityController() = default; -FakeAccessibilityController::~FakeAccessibilityController() { - content::GetSystemConnector()->ClearBinderOverrideForTesting( - service_manager::ServiceFilter::ByName(ash::mojom::kServiceName), - ash::mojom::AccessibilityController::Name_); -} +FakeAccessibilityController::~FakeAccessibilityController() = default; void FakeAccessibilityController::SetClient( - ash::mojom::AccessibilityControllerClientPtr client) { + ash::AccessibilityControllerClient* client) { was_client_set_ = true; } + void FakeAccessibilityController::SetDarkenScreen(bool darken) {} void FakeAccessibilityController::BrailleDisplayStateChanged(bool connected) {} @@ -48,31 +28,32 @@ void FakeAccessibilityController::SetAccessibilityPanelAlwaysVisible( void FakeAccessibilityController::SetAccessibilityPanelBounds( const gfx::Rect& bounds, - ash::mojom::AccessibilityPanelState state) {} + ash::AccessibilityPanelState state) {} void FakeAccessibilityController::SetSelectToSpeakState( - ash::mojom::SelectToSpeakState state) {} + ash::SelectToSpeakState state) {} void FakeAccessibilityController::SetSelectToSpeakEventHandlerDelegate( - ash::mojom::SelectToSpeakEventHandlerDelegatePtr delegate) {} + ash::SelectToSpeakEventHandlerDelegate* delegate) {} void FakeAccessibilityController::SetSwitchAccessEventHandlerDelegate( - ash::mojom::SwitchAccessEventHandlerDelegatePtr delegate) {} + ash::SwitchAccessEventHandlerDelegate* delegate) {} void FakeAccessibilityController::SetSwitchAccessKeysToCapture( const std::vector& keys_to_capture) {} +void FakeAccessibilityController::SetDictationActive(bool is_active) {} + void FakeAccessibilityController::ToggleDictationFromSource( - ash::mojom::DictationToggleSource source) {} + ash::DictationToggleSource source) {} void FakeAccessibilityController::ForwardKeyEventsToSwitchAccess( bool should_forward) {} -void FakeAccessibilityController::GetBatteryDescription( - GetBatteryDescriptionCallback callback) {} +base::string16 FakeAccessibilityController::GetBatteryDescription() const { + return base::string16(); +} void FakeAccessibilityController::SetVirtualKeyboardVisible(bool is_visible) {} -void FakeAccessibilityController::Bind(mojo::ScopedMessagePipeHandle handle) { - binding_.Bind(ash::mojom::AccessibilityControllerRequest(std::move(handle))); -} +void FakeAccessibilityController::NotifyAccessibilityStatusChanged() {} diff --git a/chrome/browser/ui/ash/accessibility/fake_accessibility_controller.h b/chrome/browser/ui/ash/accessibility/fake_accessibility_controller.h index e94bbc2c5147cf..b3a58f6ae988a4 100644 --- a/chrome/browser/ui/ash/accessibility/fake_accessibility_controller.h +++ b/chrome/browser/ui/ash/accessibility/fake_accessibility_controller.h @@ -5,11 +5,8 @@ #ifndef CHROME_BROWSER_UI_ASH_ACCESSIBILITY_FAKE_ACCESSIBILITY_CONTROLLER_H_ #define CHROME_BROWSER_UI_ASH_ACCESSIBILITY_FAKE_ACCESSIBILITY_CONTROLLER_H_ -#include - -#include "ash/public/interfaces/accessibility_controller.mojom.h" +#include "ash/public/cpp/accessibility_controller.h" #include "base/macros.h" -#include "mojo/public/cpp/bindings/binding.h" // Fake implementation of ash's mojo AccessibilityController interface. // @@ -18,40 +15,37 @@ // // Note: A ServiceManagerConnection must be initialized before constructing this // object. Consider using content::TestServiceManagerContext on your tests. -class FakeAccessibilityController : ash::mojom::AccessibilityController { +class FakeAccessibilityController : ash::AccessibilityController { public: FakeAccessibilityController(); ~FakeAccessibilityController() override; bool was_client_set() const { return was_client_set_; } - // ash::mojom::AccessibilityController: - void SetClient(ash::mojom::AccessibilityControllerClientPtr client) override; + // ash::AccessibilityController: + void SetClient(ash::AccessibilityControllerClient* client) override; void SetDarkenScreen(bool darken) override; void BrailleDisplayStateChanged(bool connected) override; void SetFocusHighlightRect(const gfx::Rect& bounds_in_screen) override; void SetCaretBounds(const gfx::Rect& bounds_in_screen) override; void SetAccessibilityPanelAlwaysVisible(bool always_visible) override; - void SetAccessibilityPanelBounds( - const gfx::Rect& bounds, - ash::mojom::AccessibilityPanelState state) override; - void SetSelectToSpeakState(ash::mojom::SelectToSpeakState state) override; + void SetAccessibilityPanelBounds(const gfx::Rect& bounds, + ash::AccessibilityPanelState state) override; + void SetSelectToSpeakState(ash::SelectToSpeakState state) override; void SetSelectToSpeakEventHandlerDelegate( - ash::mojom::SelectToSpeakEventHandlerDelegatePtr delegate) override; + ash::SelectToSpeakEventHandlerDelegate* delegate) override; void SetSwitchAccessEventHandlerDelegate( - ash::mojom::SwitchAccessEventHandlerDelegatePtr delegate) override; + ash::SwitchAccessEventHandlerDelegate* delegate) override; void SetSwitchAccessKeysToCapture( const std::vector& keys_to_capture) override; - void ToggleDictationFromSource( - ash::mojom::DictationToggleSource source) override; + void SetDictationActive(bool is_active) override; + void ToggleDictationFromSource(ash::DictationToggleSource source) override; void ForwardKeyEventsToSwitchAccess(bool should_forward) override; - void GetBatteryDescription(GetBatteryDescriptionCallback callback) override; + base::string16 GetBatteryDescription() const override; void SetVirtualKeyboardVisible(bool is_visible) override; + void NotifyAccessibilityStatusChanged() override; private: - void Bind(mojo::ScopedMessagePipeHandle handle); - - mojo::Binding binding_{this}; bool was_client_set_ = false; DISALLOW_COPY_AND_ASSIGN(FakeAccessibilityController); diff --git a/chrome/browser/ui/ash/chrome_browser_main_extra_parts_ash.cc b/chrome/browser/ui/ash/chrome_browser_main_extra_parts_ash.cc index ca32cb3bd0fa4a..ed5b9fe5bb93e6 100644 --- a/chrome/browser/ui/ash/chrome_browser_main_extra_parts_ash.cc +++ b/chrome/browser/ui/ash/chrome_browser_main_extra_parts_ash.cc @@ -133,7 +133,6 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { // Must be available at login screen, so initialize before profile. accessibility_controller_client_ = std::make_unique(); - accessibility_controller_client_->Init(); chrome_new_window_client_ = std::make_unique(); diff --git a/components/exo/keyboard_unittest.cc b/components/exo/keyboard_unittest.cc index 72e7310c912bf4..f458062727d910 100644 --- a/components/exo/keyboard_unittest.cc +++ b/components/exo/keyboard_unittest.cc @@ -4,7 +4,7 @@ #include "components/exo/keyboard.h" -#include "ash/accessibility/accessibility_controller.h" +#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/shell.h" #include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "base/macros.h" @@ -396,7 +396,7 @@ TEST_F(KeyboardTest, OnKeyboardTypeChanged_AccessibilityKeyboard) { keyboard->SetDeviceConfigurationDelegate(&configuration_delegate); EXPECT_TRUE(keyboard->HasDeviceConfigurationDelegate()); - ash::AccessibilityController* accessibility_controller = + ash::AccessibilityControllerImpl* accessibility_controller = ash::Shell::Get()->accessibility_controller(); // Enable a11y keyboard calls OnKeyboardTypeChanged() with false.