#pragma once
#include "FrameLoaderTypes.h"
#include "ResourceRequest.h"
#include <wtf/text/WTFString.h>
#if ENABLE(CONTENT_FILTERING)
#include "ContentFilterUnblockHandler.h"
#endif
namespace WTF {
template<typename> class CompletionHandler;
}
namespace WebCore {
class DocumentLoader;
class FormState;
class Frame;
class NavigationAction;
class ResourceError;
class ResourceResponse;
using NewWindowPolicyDecisionFunction = WTF::CompletionHandler<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>;
using NavigationPolicyDecisionFunction = WTF::CompletionHandler<void(ResourceRequest&&, FormState*, bool shouldContinue)>;
class PolicyChecker {
WTF_MAKE_NONCOPYABLE(PolicyChecker);
WTF_MAKE_FAST_ALLOCATED;
public:
explicit PolicyChecker(Frame&);
void checkNavigationPolicy(ResourceRequest&&, bool didReceiveRedirectResponse, DocumentLoader*, FormState*, NavigationPolicyDecisionFunction&&);
void checkNavigationPolicy(ResourceRequest&&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction&&);
void checkNewWindowPolicy(NavigationAction&&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction&&);
void stopCheck();
void cannotShowMIMEType(const ResourceResponse&);
FrameLoadType loadType() const { return m_loadType; }
void setLoadType(FrameLoadType loadType) { m_loadType = loadType; }
bool delegateIsDecidingNavigationPolicy() const { return m_delegateIsDecidingNavigationPolicy; }
bool delegateIsHandlingUnimplementablePolicy() const { return m_delegateIsHandlingUnimplementablePolicy; }
#if ENABLE(CONTENT_FILTERING)
void setContentFilterUnblockHandler(ContentFilterUnblockHandler unblockHandler) { m_contentFilterUnblockHandler = WTFMove(unblockHandler); }
#endif
private:
void handleUnimplementablePolicy(const ResourceError&);
Frame& m_frame;
bool m_delegateIsDecidingNavigationPolicy;
bool m_delegateIsHandlingUnimplementablePolicy;
FrameLoadType m_loadType;
#if ENABLE(CONTENT_FILTERING)
ContentFilterUnblockHandler m_contentFilterUnblockHandler;
#endif
};
}