1 // Copyright 2019 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 5 #ifndef ASH_PUBLIC_CPP_ACCESSIBILITY_CONTROLLER_H_ 6 #define ASH_PUBLIC_CPP_ACCESSIBILITY_CONTROLLER_H_ 7 8 #include <vector> 9 10 #include "ash/public/cpp/accelerators.h" 11 #include "ash/public/cpp/ash_public_export.h" 12 #include "base/macros.h" 13 #include "base/strings/string16.h" 14 15 namespace gfx { 16 class Rect; 17 } // namespace gfx 18 19 namespace ash { 20 21 class AccessibilityControllerClient; 22 enum class AccessibilityPanelState; 23 enum class DictationToggleSource; 24 class SelectToSpeakEventHandlerDelegate; 25 enum class SelectToSpeakState; 26 27 // Interface for ash client (e.g. Chrome) to control and query accessibility 28 // features. 29 class ASH_PUBLIC_EXPORT AccessibilityController { 30 public: 31 static AccessibilityController* Get(); 32 33 // Sets the client interface. 34 virtual void SetClient(AccessibilityControllerClient* client) = 0; 35 36 // Starts or stops darkening the screen (e.g. to allow chrome a11y extensions 37 // to darken the screen). 38 virtual void SetDarkenScreen(bool darken) = 0; 39 40 // Called when braille display state is changed. 41 virtual void BrailleDisplayStateChanged(bool connected) = 0; 42 43 // Sets the focus highlight rect using |bounds_in_screen|. Called when focus 44 // changed in page and a11y focus highlight feature is enabled. 45 virtual void SetFocusHighlightRect(const gfx::Rect& bounds_in_screen) = 0; 46 47 // Sets the text input caret bounds used to draw the caret highlight effect. 48 // For effciency, only sent when the caret highlight feature is enabled. 49 // Setting off-screen or empty bounds suppresses the highlight. 50 virtual void SetCaretBounds(const gfx::Rect& bounds_in_screen) = 0; 51 52 // Sets whether the accessibility panel should always be visible, regardless 53 // of whether the window is fullscreen. 54 virtual void SetAccessibilityPanelAlwaysVisible(bool always_visible) = 0; 55 56 // Sets the bounds for the accessibility panel. Overrides current 57 // configuration (i.e. fullscreen, full-width). 58 virtual void SetAccessibilityPanelBounds(const gfx::Rect& bounds, 59 AccessibilityPanelState state) = 0; 60 61 // Sets the current Select-to-Speak state. This should be used by the Select- 62 // to-Speak extension to inform ash of its updated state. 63 virtual void SetSelectToSpeakState(SelectToSpeakState state) = 0; 64 65 // Set the delegate used by the Select-to-Speak event handler. 66 virtual void SetSelectToSpeakEventHandlerDelegate( 67 SelectToSpeakEventHandlerDelegate* delegate) = 0; 68 69 // Displays the Select-to-Speak panel. 70 virtual void ShowSelectToSpeakPanel(const gfx::Rect& anchor, 71 bool is_paused) = 0; 72 73 // Hides the Select-to-Speak panel. 74 virtual void HideSelectToSpeakPanel() = 0; 75 76 // Hides the Switch Access back button. 77 virtual void HideSwitchAccessBackButton() = 0; 78 79 // Hides the Switch Access menu. 80 virtual void HideSwitchAccessMenu() = 0; 81 82 // Show the Switch Access back button next to the specified rectangle. 83 virtual void ShowSwitchAccessBackButton(const gfx::Rect& bounds) = 0; 84 85 // Show the Switch Access menu with the specified actions. 86 virtual void ShowSwitchAccessMenu( 87 const gfx::Rect& bounds, 88 std::vector<std::string> actions_to_show) = 0; 89 90 // Activate point scanning in Switch Access. 91 virtual void ActivatePointScan() = 0; 92 93 // Set whether dictation is active. 94 virtual void SetDictationActive(bool is_active) = 0; 95 96 // Starts or stops dictation. Records metrics for toggling via SwitchAccess. 97 virtual void ToggleDictationFromSource(DictationToggleSource source) = 0; 98 99 // Called when the Automatic Clicks extension finds scrollable bounds. 100 virtual void HandleAutoclickScrollableBoundsFound( 101 gfx::Rect& bounds_in_screen) = 0; 102 103 // Retrieves a string description of the current battery status. 104 virtual base::string16 GetBatteryDescription() const = 0; 105 106 // Shows or hides the virtual keyboard. 107 virtual void SetVirtualKeyboardVisible(bool is_visible) = 0; 108 109 // Performs the given accelerator action. 110 virtual void PerformAcceleratorAction( 111 AcceleratorAction accelerator_action) = 0; 112 113 // Notify observers that the accessibility status has changed. This is part of 114 // the public interface because a11y features like screen magnifier are 115 // managed outside of this accessibility controller. 116 virtual void NotifyAccessibilityStatusChanged() = 0; 117 118 // Returns true if the |path| pref is being controlled by a policy which 119 // enforces turning it on or its not being controlled by any type of policy 120 // and false otherwise. 121 virtual bool IsAccessibilityFeatureVisibleInTrayMenu( 122 const std::string& path) = 0; 123 124 // Disables restoring of recommended policy values. DisablePolicyRecommendationRestorerForTesting()125 virtual void DisablePolicyRecommendationRestorerForTesting() {} 126 127 // Set to true to disable the dialog. 128 // Used in tests. 129 virtual void DisableSwitchAccessDisableConfirmationDialogTesting() = 0; 130 131 // Shows floating accessibility menu if it was enabled by policy. ShowFloatingMenuIfEnabled()132 virtual void ShowFloatingMenuIfEnabled() {} 133 134 protected: 135 AccessibilityController(); 136 virtual ~AccessibilityController(); 137 138 private: 139 DISALLOW_COPY_AND_ASSIGN(AccessibilityController); 140 }; 141 142 } // namespace ash 143 144 #endif // ASH_PUBLIC_CPP_ACCESSIBILITY_CONTROLLER_H_ 145