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 8 #include "ash/accessibility/accessibility_observer.h" 9 #include "ash/ash_export.h" 10 #include "ash/public/cpp/accessibility_controller_enums.h" 11 #include "ash/public/cpp/ash_constants.h" 12 #include "ash/system/accessibility/floating_accessibility_detailed_controller.h" 13 #include "ash/system/accessibility/floating_accessibility_view.h" 14 #include "ash/system/locale/locale_update_controller_impl.h" 15 16 namespace ash { 17 18 class AccessibilityControllerImpl; 19 class FloatingAccessibilityView; 20 21 // Controls the floating accessibility menu. 22 class ASH_EXPORT FloatingAccessibilityController 23 : public FloatingAccessibilityView::Delegate, 24 public FloatingAccessibilityDetailedController::Delegate, 25 public TrayBubbleView::Delegate, 26 public LocaleChangeObserver, 27 public AccessibilityObserver { 28 public: 29 explicit FloatingAccessibilityController( 30 AccessibilityControllerImpl* accessibility_controller); 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 41 // AccessibilityObserver: 42 void OnAccessibilityStatusChanged() override; 43 44 // Focuses on the first element in the floating menu. 45 void FocusOnMenu(); 46 47 private: 48 friend class FloatingAccessibilityControllerTest; 49 // FloatingAccessibilityView::Delegate: 50 void OnDetailedMenuEnabled(bool enabled) override; 51 void OnLayoutChanged() override; 52 // FloatingAccessibilityDetailedController::Delegate: 53 void OnDetailedMenuClosed() override; 54 views::Widget* GetBubbleWidget() override; 55 // TrayBubbleView::Delegate: 56 void BubbleViewDestroyed() override; 57 base::string16 GetAccessibleNameForBubble() override; 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 67 // Controller for the detailed view, exists only when visible. 68 std::unique_ptr<FloatingAccessibilityDetailedController> 69 detailed_menu_controller_; 70 71 FloatingMenuPosition position_ = kDefaultFloatingMenuPosition; 72 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. 77 }; 78 79 } // namespace ash 80 81 #endif // ASH_SYSTEM_ACCESSIBILITY_FLOATING_ACCESSIBILITY_CONTROLLER_H_ 82