WebScriptMessageHandler.h [plain text]
#pragma once
#include "APIContentWorld.h"
#include "WebUserContentControllerDataTypes.h"
#include <wtf/Identified.h>
#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
struct SecurityOriginData;
class SerializedScriptValue;
}
namespace API {
class ContentWorld;
class SerializedScriptValue;
}
namespace WebKit {
class WebPageProxy;
class WebFrameProxy;
struct FrameInfoData;
class WebScriptMessageHandler : public RefCounted<WebScriptMessageHandler>, public Identified<WebScriptMessageHandler> {
public:
class Client {
public:
virtual ~Client() { }
virtual void didPostMessage(WebPageProxy&, FrameInfoData&&, API::ContentWorld&, WebCore::SerializedScriptValue&) = 0;
virtual bool supportsAsyncReply() = 0;
virtual void didPostMessageWithAsyncReply(WebPageProxy&, FrameInfoData&&, API::ContentWorld&, WebCore::SerializedScriptValue&, WTF::Function<void(API::SerializedScriptValue*, const String&)>&&) = 0;
};
static Ref<WebScriptMessageHandler> create(std::unique_ptr<Client>, const String& name, API::ContentWorld&);
virtual ~WebScriptMessageHandler();
String name() const { return m_name; }
API::ContentWorld& world() { return m_world.get(); }
Client& client() const { return *m_client; }
private:
WebScriptMessageHandler(std::unique_ptr<Client>, const String&, API::ContentWorld&);
std::unique_ptr<Client> m_client;
String m_name;
Ref<API::ContentWorld> m_world;
};
}