1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58

ash / system / accessibility / switch_access / switch_access_menu_bubble_controller.h [blame]

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_SYSTEM_ACCESSIBILITY_SWITCH_ACCESS_SWITCH_ACCESS_MENU_BUBBLE_CONTROLLER_H_
#define ASH_SYSTEM_ACCESSIBILITY_SWITCH_ACCESS_SWITCH_ACCESS_MENU_BUBBLE_CONTROLLER_H_

#include "ash/system/tray/tray_bubble_view.h"
#include "base/memory/raw_ptr.h"

namespace ash {

class SwitchAccessBackButtonBubbleController;
class SwitchAccessMenuView;

// Manages the Switch Access menu bubble.
class ASH_EXPORT SwitchAccessMenuBubbleController
    : public TrayBubbleView::Delegate {
 public:
  SwitchAccessMenuBubbleController();
  ~SwitchAccessMenuBubbleController() override;

  SwitchAccessMenuBubbleController(const SwitchAccessMenuBubbleController&) =
      delete;
  SwitchAccessMenuBubbleController& operator=(
      const SwitchAccessMenuBubbleController&) = delete;

  void ShowBackButton(const gfx::Rect& anchor);
  void HideBackButton();

  void ShowMenu(const gfx::Rect& anchor,
                const std::vector<std::string>& actions_to_show);
  void HideMenuBubble();

  // TrayBubbleView::Delegate:
  void BubbleViewDestroyed() override;
  void HideBubble(const TrayBubbleView* bubble_view) override;

 private:
  friend class SwitchAccessBackButtonBubbleControllerTest;
  friend class SwitchAccessMenuBubbleControllerTest;

  void ShowBackButtonForMenu();

  std::unique_ptr<SwitchAccessBackButtonBubbleController>
      back_button_controller_;
  bool menu_open_ = false;

  // Owned by views hierarchy.
  raw_ptr<SwitchAccessMenuView> menu_view_ = nullptr;
  raw_ptr<TrayBubbleView> bubble_view_ = nullptr;

  raw_ptr<views::Widget> widget_ = nullptr;
};

}  // namespace ash

#endif  // ASH_SYSTEM_ACCESSIBILITY_SWITCH_ACCESS_SWITCH_ACCESS_MENU_BUBBLE_CONTROLLER_H_