#ifndef ASH_WM_SPLITVIEW_SPLIT_VIEW_OVERVIEW_SESSION_H_
#define ASH_WM_SPLITVIEW_SPLIT_VIEW_OVERVIEW_SESSION_H_
#include <optional>
#include "ash/wm/overview/overview_metrics.h"
#include "ash/wm/overview/overview_types.h"
#include "ash/wm/window_state_observer.h"
#include "ash/wm/wm_metrics.h"
#include "base/scoped_observation.h"
#include "ui/aura/window_observer.h"
#include "ui/compositor/presentation_time_recorder.h"
namespace ui {
class LocatedEvent;
}
namespace ash {
enum class SplitViewOverviewSetupType {
kSnapThenAutomaticOverview,
kOverviewThenManualSnap,
kMaxValue = kOverviewThenManualSnap,
};
enum class SplitViewOverviewSessionExitPoint {
kCompleteByActivating,
kSkip,
kWindowDestroy,
kShutdown,
kUnspecified,
kTabletConversion,
kMaxValue = kTabletConversion,
};
class ASH_EXPORT SplitViewOverviewSession : public aura::WindowObserver,
public WindowStateObserver {
public:
SplitViewOverviewSession(aura::Window* window,
WindowSnapActionSource snap_action_source);
SplitViewOverviewSession(const SplitViewOverviewSession&) = delete;
SplitViewOverviewSession& operator=(const SplitViewOverviewSession&) = delete;
~SplitViewOverviewSession() override;
aura::Window* window() { return window_; }
SplitViewOverviewSetupType setup_type() const { return setup_type_; }
chromeos::WindowStateType GetWindowStateType() const;
void Init(std::optional<OverviewStartAction> action,
std::optional<OverviewEnterExitType> type);
void RecordSplitViewOverviewSessionExitPointMetrics(
SplitViewOverviewSessionExitPoint user_action);
void HandleClickOrTap(const ui::LocatedEvent& event);
void OnResizeLoopStarted(aura::Window* window) override;
void OnResizeLoopEnded(aura::Window* window) override;
void OnWindowBoundsChanged(aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds,
ui::PropertyChangeReason reason) override;
void OnWindowDestroying(aura::Window* window) override;
void OnPreWindowStateTypeChange(WindowState* window_state,
chromeos::WindowStateType old_type) override;
WindowSnapActionSource snap_action_source_for_testing() const {
return snap_action_source_;
}
private:
void MaybeEndOverview(SplitViewOverviewSessionExitPoint exit_point,
OverviewEnterExitType exit_type);
bool is_resizing_ = false;
std::unique_ptr<ui::PresentationTimeRecorder> presentation_time_recorder_;
const raw_ptr<aura::Window> window_;
SplitViewOverviewSetupType setup_type_ =
SplitViewOverviewSetupType::kSnapThenAutomaticOverview;
const WindowSnapActionSource snap_action_source_;
base::ScopedObservation<aura::Window, aura::WindowObserver>
window_observation_{this};
};
}
#endif