RemoteControllableTarget.h [plain text]
#pragma once
#if ENABLE(REMOTE_INSPECTOR)
#include "JSExportMacros.h"
#include <wtf/TypeCasts.h>
#include <wtf/text/WTFString.h>
#if USE(CF)
#include <CoreFoundation/CFRunLoop.h>
#endif
namespace Inspector {
class FrontendChannel;
using TargetID = unsigned;
class JS_EXPORT_PRIVATE RemoteControllableTarget {
public:
virtual ~RemoteControllableTarget();
void init();
void update();
virtual void connect(FrontendChannel&, bool isAutomaticConnection = false, bool immediatelyPause = false) = 0;
virtual void disconnect(FrontendChannel&) = 0;
TargetID targetIdentifier() const { return m_identifier; }
void setTargetIdentifier(TargetID identifier) { m_identifier = identifier; }
enum class Type {
Automation,
ITML,
JavaScript,
Page,
ServiceWorker,
WebPage,
};
virtual Type type() const = 0;
virtual bool remoteControlAllowed() const = 0;
virtual void dispatchMessageFromRemote(const String& message) = 0;
#if USE(CF)
virtual CFRunLoopRef targetRunLoop() const { return nullptr; }
#endif
private:
TargetID m_identifier { 0 };
};
}
#define SPECIALIZE_TYPE_TRAITS_CONTROLLABLE_TARGET(ToClassName, ToClassType) \
SPECIALIZE_TYPE_TRAITS_BEGIN(ToClassName) \
static bool isType(const Inspector::RemoteControllableTarget& target) { return target.type() == Inspector::RemoteControllableTarget::Type::ToClassType; } \
SPECIALIZE_TYPE_TRAITS_END()
#endif // ENABLE(REMOTE_INSPECTOR)