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_DETAILED_CONTROLLER_H_ 6 #define ASH_SYSTEM_ACCESSIBILITY_FLOATING_ACCESSIBILITY_DETAILED_CONTROLLER_H_ 7 8 #include "ash/ash_export.h" 9 #include "ash/system/tray/detailed_view_delegate.h" 10 #include "ash/system/tray/tray_bubble_view.h" 11 #include "ui/views/bubble/bubble_border.h" 12 #include "ui/wm/public/activation_change_observer.h" 13 14 namespace ash { 15 16 namespace tray { 17 class AccessibilityDetailedView; 18 } 19 20 // Controller for the detailed view of accessibility floating menu. 21 class ASH_EXPORT FloatingAccessibilityDetailedController 22 : public TrayBubbleView::Delegate, 23 public DetailedViewDelegate, 24 public ::wm::ActivationChangeObserver { 25 public: 26 class Delegate { 27 public: OnDetailedMenuClosed()28 virtual void OnDetailedMenuClosed() {} 29 virtual views::Widget* GetBubbleWidget() = 0; 30 virtual ~Delegate() = default; 31 }; 32 33 explicit FloatingAccessibilityDetailedController(Delegate* delegate); 34 ~FloatingAccessibilityDetailedController() override; 35 36 void Show(gfx::Rect anchor_rect, views::BubbleBorder::Arrow alignment); 37 void UpdateAnchorRect(gfx::Rect anchor_rect, 38 views::BubbleBorder::Arrow alignment); 39 // DetailedViewDelegate: 40 void CloseBubble() override; 41 void TransitionToMainView(bool restore_focus) override; 42 base::string16 GetAccessibleNameForBubble() override; 43 44 void OnAccessibilityStatusChanged(); 45 46 private: 47 friend class FloatingAccessibilityControllerTest; 48 class DetailedBubbleView; 49 // DetailedViewDelegate: 50 views::Button* CreateBackButton( 51 views::Button::PressedCallback callback) override; 52 views::Button* CreateHelpButton( 53 views::Button::PressedCallback callback) override; 54 // TrayBubbleView::Delegate: 55 void BubbleViewDestroyed() override; 56 57 // ::wm::ActivationChangeObserver: 58 void OnWindowActivated(ActivationReason reason, 59 aura::Window* gained_active, 60 aura::Window* lost_active) override; 61 62 DetailedBubbleView* bubble_view_ = nullptr; 63 views::Widget* bubble_widget_ = nullptr; 64 tray::AccessibilityDetailedView* detailed_view_ = nullptr; 65 66 Delegate* const delegate_; // Owns us. 67 }; 68 69 } // namespace ash 70 71 #endif // ASH_SYSTEM_ACCESSIBILITY_FLOATING_ACCESSIBILITY_DETAILED_CONTROLLER_H 72