#ifndef ASH_APP_LIST_APP_LIST_BUBBLE_PRESENTER_H_
#define ASH_APP_LIST_APP_LIST_BUBBLE_PRESENTER_H_
#include <stdint.h>
#include <memory>
#include <optional>
#include "ash/ash_export.h"
#include "ash/public/cpp/app_list/app_list_types.h"
#include "ash/public/cpp/shelf_types.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observation.h"
#include "ui/display/display_observer.h"
#include "ui/views/widget/widget_observer.h"
#include "ui/wm/public/activation_change_observer.h"
namespace aura {
class Window;
}
namespace ui {
class LocatedEvent;
}
namespace ash {
class AppListBubbleEventFilter;
class AppListBubbleView;
class AppListControllerImpl;
enum class AppListSortOrder;
class ASH_EXPORT AppListBubblePresenter : public views::WidgetObserver,
public wm::ActivationChangeObserver,
public display::DisplayObserver {
public:
explicit AppListBubblePresenter(AppListControllerImpl* controller);
AppListBubblePresenter(const AppListBubblePresenter&) = delete;
AppListBubblePresenter& operator=(const AppListBubblePresenter&) = delete;
~AppListBubblePresenter() override;
void Shutdown();
void Show(int64_t display_id);
ShelfAction Toggle(int64_t display_id);
void Dismiss();
aura::Window* GetWindow() const;
bool IsShowing() const;
void UpdateContinueSectionVisibility();
void UpdateForNewSortingOrder(
const std::optional<AppListSortOrder>& new_order,
bool animate,
base::OnceClosure update_position_closure);
void OnWidgetDestroying(views::Widget* widget) override;
void OnWindowActivating(ActivationReason reason,
aura::Window* gaining_active,
aura::Window* losing_active) override {}
void OnWindowActivated(ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;
void OnDisplayMetricsChanged(const display::Display& display,
uint32_t changed_metrics) override;
int GetPreferredBubbleWidth(aura::Window* root_window) const;
views::Widget* bubble_widget_for_test() { return bubble_widget_; }
AppListBubbleView* bubble_view_for_test() { return bubble_view_; }
private:
void OnZeroStateSearchDone(int64_t display_id);
void OnPressOutsideBubble(const ui::LocatedEvent& event);
int64_t GetDisplayId() const;
void OnHideAnimationEnded();
const raw_ptr<AppListControllerImpl> controller_;
bool is_target_visibility_show_ = false;
raw_ptr<views::Widget> bubble_widget_ = nullptr;
raw_ptr<AppListBubbleView> bubble_view_ = nullptr;
AppListBubblePage target_page_ = AppListBubblePage::kApps;
std::unique_ptr<AppListBubbleEventFilter> bubble_event_filter_;
display::ScopedDisplayObserver display_observer_{this};
base::WeakPtrFactory<AppListBubblePresenter> weak_factory_{this};
};
}
#endif