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
   59

ash / wm / overview / birch / tab_app_selection_host.h [blame]

// Copyright 2024 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_WM_OVERVIEW_BIRCH_TAB_APP_SELECTION_HOST_H_
#define ASH_WM_OVERVIEW_BIRCH_TAB_APP_SELECTION_HOST_H_

#include "ui/views/widget/widget.h"

namespace ash {

class CoralChipButton;
class ScopedA11yOverrideWindowSetter;

// The host which contains the TabAppSelectionView. This widget slides in when
// shown.
class TabAppSelectionHost : public views::Widget {
 public:
  explicit TabAppSelectionHost(CoralChipButton* coral_chip);
  TabAppSelectionHost(const TabAppSelectionHost&) = delete;
  TabAppSelectionHost& operator=(const TabAppSelectionHost&) = delete;
  ~TabAppSelectionHost() override;

  void ProcessKeyEvent(ui::KeyEvent* event);

  // Called when an item is removed from the selection view. Reloads the chip
  // button image.
  void OnItemRemoved();

  // Slides the widget under `owner_` before hiding it.
  void SlideOut();

  // Removes an item associated with given `identifier` from selection view.
  void RemoveItem(std::string_view identifier);

  // views::Widget:
  void OnNativeWidgetVisibilityChanged(bool visible) override;

  const CoralChipButton* owner_for_testing() const { return owner_; }

 private:
  class SelectionHostHider;

  gfx::Rect GetDesiredBoundsInScreen();

  std::unique_ptr<SelectionHostHider> hider_;
  const raw_ptr<CoralChipButton> owner_;

  // Used for metrics.
  int number_of_removed_items_ = 0;

  // This widget isn't activatable so this is a way to force accessibility
  // features to focus on the underlying window.
  std::unique_ptr<ScopedA11yOverrideWindowSetter> scoped_a11y_overrider_;
};

}  // namespace ash

#endif  // ASH_WM_OVERVIEW_BIRCH_TAB_APP_SELECTION_HOST_H_