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_SWITCH_ACCESS_BACK_BUTTON_BUBBLE_CONTROLLER_H_
6 #define ASH_SYSTEM_ACCESSIBILITY_SWITCH_ACCESS_BACK_BUTTON_BUBBLE_CONTROLLER_H_
7 
8 #include "ash/system/tray/tray_bubble_view.h"
9 
10 namespace ash {
11 
12 class SwitchAccessBackButtonView;
13 
14 // Manages the Switch Access back button bubble.
15 class ASH_EXPORT SwitchAccessBackButtonBubbleController
16     : public TrayBubbleView::Delegate {
17  public:
18   SwitchAccessBackButtonBubbleController();
19   ~SwitchAccessBackButtonBubbleController() override;
20 
21   SwitchAccessBackButtonBubbleController(
22       const SwitchAccessBackButtonBubbleController&) = delete;
23   SwitchAccessBackButtonBubbleController& operator=(
24       const SwitchAccessBackButtonBubbleController&) = delete;
25 
26   // A different icon is used when showing for the menu.
27   void ShowBackButton(const gfx::Rect& anchor,
28                       bool show_focus_ring,
29                       bool for_menu);
30   void HideFocusRing();
31   void Hide();
32 
33   // TrayBubbleView::Delegate:
34   void BubbleViewDestroyed() override;
35 
36  private:
37   friend class SwitchAccessBackButtonBubbleControllerTest;
38   friend class SwitchAccessMenuBubbleControllerTest;
39 
40   gfx::Rect AdjustAnchorRect(const gfx::Rect& anchor);
41 
42   // Owned by views hierarchy.
43   SwitchAccessBackButtonView* back_button_view_ = nullptr;
44   TrayBubbleView* bubble_view_ = nullptr;
45 
46   views::Widget* widget_ = nullptr;
47 };
48 
49 }  // namespace ash
50 
51 #endif  // ASH_SYSTEM_ACCESSIBILITY_SWITCH_ACCESS_BACK_BUTTON_BUBBLE_CONTROLLER_H_
52