#ifndef SERVICES_ACCESSIBILITY_ASSISTIVE_TECHNOLOGY_CONTROLLER_IMPL_H_
#define SERVICES_ACCESSIBILITY_ASSISTIVE_TECHNOLOGY_CONTROLLER_IMPL_H_
#include <memory>
#include <set>
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/accessibility/public/mojom/accessibility_service.mojom.h"
namespace ax {
class V8Manager;
class AssistiveTechnologyControllerImpl
: public mojom::AssistiveTechnologyController,
public mojom::AccessibilityServiceClient {
public:
AssistiveTechnologyControllerImpl();
~AssistiveTechnologyControllerImpl() override;
AssistiveTechnologyControllerImpl(const AssistiveTechnologyControllerImpl&) =
delete;
AssistiveTechnologyControllerImpl& operator=(
const AssistiveTechnologyControllerImpl&) = delete;
void Bind(mojo::PendingReceiver<mojom::AssistiveTechnologyController>
at_controller_receiver);
void BindAccessibilityServiceClient(
mojo::PendingRemote<mojom::AccessibilityServiceClient>
accessibility_client_remote);
void BindAutomation(mojo::PendingRemote<mojom::Automation> automation,
mojo::PendingReceiver<mojom::AutomationClient>
automation_client) override;
void EnableAssistiveTechnology(
const std::vector<mojom::AssistiveTechnologyType>& enabled_features)
override;
bool IsFeatureEnabled(mojom::AssistiveTechnologyType type) const;
void RunScriptForTest(mojom::AssistiveTechnologyType type,
const std::string& script,
base::OnceClosure on_complete);
private:
scoped_refptr<V8Manager> GetOrMakeV8Manager(
mojom::AssistiveTechnologyType type);
std::map<mojom::AssistiveTechnologyType, scoped_refptr<V8Manager>>
enabled_ATs_;
bool v8_initialized_ = false;
mojo::Receiver<mojom::AssistiveTechnologyController> at_controller_receiver_{
this};
mojo::Remote<mojom::AccessibilityServiceClient>
accessibility_service_client_remote_;
base::WeakPtrFactory<AssistiveTechnologyControllerImpl> weak_ptr_factory_{
this};
};
}
#endif