Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 1 | // Copyright 2020 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_SYSTEM_ACCESSIBILITY_FLOATING_ACCESSIBILITY_CONTROLLER_H_ |
| 6 | #define ASH_SYSTEM_ACCESSIBILITY_FLOATING_ACCESSIBILITY_CONTROLLER_H_ |
| 7 | |
Anatoliy Potapchuk | 5addce7 | 2020-04-23 14:20:38 | [diff] [blame] | 8 | #include "ash/accessibility/accessibility_observer.h" |
| 9 | #include "ash/ash_export.h" |
Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 10 | #include "ash/public/cpp/accessibility_controller_enums.h" |
| 11 | #include "ash/public/cpp/ash_constants.h" |
Anatoliy Potapchuk | 5addce7 | 2020-04-23 14:20:38 | [diff] [blame] | 12 | #include "ash/system/accessibility/floating_accessibility_detailed_controller.h" |
Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 13 | #include "ash/system/accessibility/floating_accessibility_view.h" |
| 14 | #include "ash/system/locale/locale_update_controller_impl.h" |
| 15 | |
| 16 | namespace ash { |
| 17 | |
Anatoliy Potapchuk | 5addce7 | 2020-04-23 14:20:38 | [diff] [blame] | 18 | class AccessibilityControllerImpl; |
Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 19 | class FloatingAccessibilityView; |
| 20 | |
| 21 | // Controls the floating accessibility menu. |
Anatoliy Potapchuk | 5addce7 | 2020-04-23 14:20:38 | [diff] [blame] | 22 | class ASH_EXPORT FloatingAccessibilityController |
Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 23 | : public FloatingAccessibilityView::Delegate, |
Anatoliy Potapchuk | 5addce7 | 2020-04-23 14:20:38 | [diff] [blame] | 24 | public FloatingAccessibilityDetailedController::Delegate, |
Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 25 | public TrayBubbleView::Delegate, |
Anatoliy Potapchuk | 5addce7 | 2020-04-23 14:20:38 | [diff] [blame] | 26 | public LocaleChangeObserver, |
| 27 | public AccessibilityObserver { |
Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 28 | public: |
Anatoliy Potapchuk | caa4ce4 | 2020-04-28 22:56:23 | [diff] [blame] | 29 | explicit FloatingAccessibilityController( |
| 30 | AccessibilityControllerImpl* accessibility_controller); |
Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 31 | FloatingAccessibilityController(const FloatingAccessibilityController&) = |
| 32 | delete; |
| 33 | FloatingAccessibilityController& operator=( |
| 34 | const FloatingAccessibilityController&) = delete; |
| 35 | ~FloatingAccessibilityController() override; |
| 36 | |
| 37 | // Starts showing the floating menu when called. |
| 38 | void Show(FloatingMenuPosition position); |
| 39 | void SetMenuPosition(FloatingMenuPosition new_position); |
| 40 | |
Anatoliy Potapchuk | 5addce7 | 2020-04-23 14:20:38 | [diff] [blame] | 41 | // AccessibilityObserver: |
| 42 | void OnAccessibilityStatusChanged() override; |
| 43 | |
Anatoliy Potapchuk | 535fa6b | 2020-05-11 23:41:28 | [diff] [blame] | 44 | // Focuses on the first element in the floating menu. |
| 45 | void FocusOnMenu(); |
| 46 | |
Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 47 | private: |
| 48 | friend class FloatingAccessibilityControllerTest; |
| 49 | // FloatingAccessibilityView::Delegate: |
| 50 | void OnDetailedMenuEnabled(bool enabled) override; |
Anatoliy Potapchuk | caa4ce4 | 2020-04-28 22:56:23 | [diff] [blame] | 51 | void OnLayoutChanged() override; |
Anatoliy Potapchuk | 5addce7 | 2020-04-23 14:20:38 | [diff] [blame] | 52 | // FloatingAccessibilityDetailedController::Delegate: |
| 53 | void OnDetailedMenuClosed() override; |
Anatoliy Potapchuk | 31128fa | 2020-05-08 20:00:14 | [diff] [blame] | 54 | views::Widget* GetBubbleWidget() override; |
Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 55 | // TrayBubbleView::Delegate: |
| 56 | void BubbleViewDestroyed() override; |
Jan Wilken Dörrie | 85285b0 | 2021-03-11 23:38:47 | [diff] [blame^] | 57 | std::u16string GetAccessibleNameForBubble() override; |
Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 58 | // LocaleChangeObserver: |
| 59 | void OnLocaleChanged() override; |
| 60 | |
| 61 | FloatingAccessibilityView* menu_view_ = nullptr; |
| 62 | FloatingAccessibilityBubbleView* bubble_view_ = nullptr; |
| 63 | views::Widget* bubble_widget_ = nullptr; |
| 64 | |
| 65 | bool detailed_view_shown_ = false; |
| 66 | |
Anatoliy Potapchuk | 5addce7 | 2020-04-23 14:20:38 | [diff] [blame] | 67 | // Controller for the detailed view, exists only when visible. |
| 68 | std::unique_ptr<FloatingAccessibilityDetailedController> |
| 69 | detailed_menu_controller_; |
| 70 | |
Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 71 | FloatingMenuPosition position_ = kDefaultFloatingMenuPosition; |
Anatoliy Potapchuk | 5addce7 | 2020-04-23 14:20:38 | [diff] [blame] | 72 | |
Anatoliy Potapchuk | caa4ce4 | 2020-04-28 22:56:23 | [diff] [blame] | 73 | // Used in tests to notify on the menu layout change events. |
| 74 | base::RepeatingClosure on_layout_change_; |
| 75 | |
| 76 | AccessibilityControllerImpl* const accessibility_controller_; // Owns us. |
Anatoliy Potapchuk | 8a96963 | 2020-04-14 13:25:55 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | } // namespace ash |
| 80 | |
| 81 | #endif // ASH_SYSTEM_ACCESSIBILITY_FLOATING_ACCESSIBILITY_CONTROLLER_H_ |