#ifndef ASH_ANNOTATOR_ANNOTATOR_CONTROLLER_H_
#define ASH_ANNOTATOR_ANNOTATOR_CONTROLLER_H_
#include <memory>
#include <optional>
#include "ash/annotator/annotator_metrics.h"
#include "ash/ash_export.h"
#include "ash/public/cpp/annotator/annotator_controller_base.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "base/observer_list_types.h"
#include "third_party/skia/include/core/SkColor.h"
namespace aura {
class Window;
}
namespace gfx {
class Rect;
}
namespace ash {
struct AnnotatorTool;
class AnnotatorClient;
class AnnotationsOverlayView;
class AnnotationsOverlayController;
class AnnotationSourceWatcher;
class ASH_EXPORT AnnotatorController : public AnnotatorControllerBase {
public:
AnnotatorController();
AnnotatorController(const AnnotatorController&) = delete;
AnnotatorController& operator=(const AnnotatorController&) = delete;
~AnnotatorController() override;
class AnnotatorObserver : public base::CheckedObserver {
public:
virtual void OnAnnotatorStateChanged(bool enabled) {}
};
bool is_annotator_enabled() const { return annotator_enabled_; }
AnnotationSourceWatcher* annotation_source_watcher() {
return annotation_source_watcher_.get();
}
virtual void SetAnnotatorTool(const AnnotatorTool& tool);
void ResetTools();
void RegisterView(aura::Window* new_root);
void UnregisterView(aura::Window* current_root);
void UpdateRootView(aura::Window* new_root);
void EnableAnnotatorTool();
void DisableAnnotator();
void CreateAnnotationOverlayForWindow(
aura::Window* window,
std::optional<gfx::Rect> partial_region_bounds);
void CreateAnnotationOverlayForMarkerMode(aura::Window* window);
void SetToolClient(AnnotatorClient* client) override;
bool GetAnnotatorAvailability() const override;
void OnCanvasInitialized(bool success) override;
void ToggleAnnotationTray() override;
void OnUndoRedoAvailabilityChanged(bool undo_available,
bool redo_available) override;
std::unique_ptr<AnnotationsOverlayView> CreateAnnotationsOverlayView() const;
void UpdateAnnotationTrayAccessibleName(bool is_annotator_enabled);
void AddObserver(AnnotatorObserver* observer);
void RemoveObserver(AnnotatorObserver* observer);
void set_canvas_initialized_callback_for_test(base::OnceClosure callback) {
on_canvas_initialized_callback_for_test_ = std::move(callback);
}
private:
friend class CaptureModeTestApi;
void UpdateTrayEnabledState();
void ToggleAnnotatorCanvas();
void NotifyStateChanged();
raw_ptr<AnnotatorClient> client_ = nullptr;
std::optional<bool> canvas_initialized_state_;
bool annotator_enabled_ = false;
raw_ptr<aura::Window> current_root_ = nullptr;
base::OnceClosure on_canvas_initialized_callback_for_test_;
std::unique_ptr<AnnotationsOverlayController> annotations_overlay_controller_;
std::unique_ptr<AnnotationSourceWatcher> annotation_source_watcher_;
base::ObserverList<AnnotatorObserver> observers_;
};
}
#endif