touch_exploration_manager.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_ACCESSIBILITY_CHROMEVOX_TOUCH_EXPLORATION_MANAGER_H_
  5. #define ASH_ACCESSIBILITY_CHROMEVOX_TOUCH_EXPLORATION_MANAGER_H_
  6. #include <memory>
  7. #include "ash/accessibility/accessibility_observer.h"
  8. #include "ash/accessibility/chromevox/touch_accessibility_enabler.h"
  9. #include "ash/accessibility/chromevox/touch_exploration_controller.h"
  10. #include "ash/ash_export.h"
  11. #include "ash/public/cpp/keyboard/keyboard_controller_observer.h"
  12. #include "ash/shell_observer.h"
  13. #include "ui/aura/window_observer.h"
  14. #include "ui/display/display_observer.h"
  15. #include "ui/wm/public/activation_change_observer.h"
  16. namespace ash {
  17. class CrasAudioHandler;
  18. class RootWindowController;
  19. // Responsible for initializing TouchExplorationController when spoken feedback
  20. // is on. Implements TouchExplorationControllerDelegate which allows touch
  21. // gestures to manipulate the system.
  22. //
  23. // TODO(jamescook): Move the TouchExplorationControllerDelegate methods into
  24. // TouchExplorationController. I suspect the delegate was added to support ash
  25. // on Windows, which we don't ship anymore.
  26. class ASH_EXPORT TouchExplorationManager
  27. : public AccessibilityObserver,
  28. public aura::WindowObserver,
  29. public TouchExplorationControllerDelegate,
  30. public TouchAccessibilityEnablerDelegate,
  31. public display::DisplayObserver,
  32. public ::wm::ActivationChangeObserver,
  33. public KeyboardControllerObserver,
  34. public ShellObserver {
  35. public:
  36. explicit TouchExplorationManager(
  37. RootWindowController* root_window_controller);
  38. TouchExplorationManager(const TouchExplorationManager&) = delete;
  39. TouchExplorationManager& operator=(const TouchExplorationManager&) = delete;
  40. ~TouchExplorationManager() override;
  41. // AccessibilityObserver overrides:
  42. void OnAccessibilityStatusChanged() override;
  43. void OnAccessibilityControllerShutdown() override;
  44. // aura::WindowObserver overrides:
  45. void OnWindowPropertyChanged(aura::Window* window,
  46. const void* key,
  47. intptr_t old) override;
  48. void OnWindowDestroying(aura::Window* window) override;
  49. // TouchExplorationControllerDelegate overrides:
  50. void SetOutputLevel(int volume) override;
  51. void SilenceSpokenFeedback() override;
  52. void PlayVolumeAdjustEarcon() override;
  53. void PlayPassthroughEarcon() override;
  54. void PlayLongPressRightClickEarcon() override;
  55. void PlayEnterScreenEarcon() override;
  56. void HandleAccessibilityGesture(ax::mojom::Gesture gesture,
  57. gfx::PointF location) override;
  58. // display::DisplayObserver overrides:
  59. void OnDisplayMetricsChanged(const display::Display& display,
  60. uint32_t changed_metrics) override;
  61. // TouchAccessibilityEnablerDelegate overrides:
  62. void OnTwoFingerTouchStart() override;
  63. void OnTwoFingerTouchStop() override;
  64. void PlaySpokenFeedbackToggleCountdown(int tick_count) override;
  65. void PlayTouchTypeEarcon() override;
  66. void ToggleSpokenFeedback() override;
  67. // wm::ActivationChangeObserver overrides:
  68. void OnWindowActivated(
  69. ::wm::ActivationChangeObserver::ActivationReason reason,
  70. aura::Window* gained_active,
  71. aura::Window* lost_active) override;
  72. // Update the touch exploration controller so that synthesized touch
  73. // events are anchored at this point.
  74. void SetTouchAccessibilityAnchorPoint(const gfx::Point& anchor_point);
  75. private:
  76. // KeyboardControllerObserver overrides:
  77. void OnKeyboardVisibleBoundsChanged(const gfx::Rect& new_bounds) override;
  78. void OnKeyboardEnabledChanged(bool is_enabled) override;
  79. void UpdateTouchExplorationState();
  80. bool VolumeAdjustSoundEnabled();
  81. std::unique_ptr<TouchExplorationController> touch_exploration_controller_;
  82. std::unique_ptr<TouchAccessibilityEnabler> touch_accessibility_enabler_;
  83. RootWindowController* root_window_controller_;
  84. CrasAudioHandler* audio_handler_;
  85. aura::Window* observing_window_;
  86. display::ScopedDisplayObserver display_observer_{this};
  87. };
  88. } // namespace ash
  89. #endif // ASH_ACCESSIBILITY_CHROMEVOX_TOUCH_EXPLORATION_MANAGER_H_