#ifndef PolicyChecker_h
#define PolicyChecker_h
#include "FrameLoaderTypes.h"
#include "PolicyCallback.h"
#include "ResourceRequest.h"
#include <wtf/PassRefPtr.h>
#include <wtf/text/WTFString.h>
#if ENABLE(CONTENT_FILTERING)
#include "ContentFilterUnblockHandler.h"
#endif
namespace WebCore {
class DocumentLoader;
class FormState;
class Frame;
class NavigationAction;
class ResourceError;
class ResourceResponse;
class PolicyChecker {
WTF_MAKE_NONCOPYABLE(PolicyChecker);
WTF_MAKE_FAST_ALLOCATED;
public:
explicit PolicyChecker(Frame&);
void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, DocumentLoader*, PassRefPtr<FormState>, NavigationPolicyDecisionFunction);
void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction);
void checkNewWindowPolicy(const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, NewWindowPolicyDecisionFunction);
void checkContentPolicy(const ResourceResponse&, ContentPolicyDecisionFunction);
void cancelCheck();
void stopCheck();
void cannotShowMIMEType(const ResourceResponse&);
FrameLoadType loadType() const { return m_loadType; }
void setLoadType(FrameLoadType loadType) { m_loadType = loadType; }
void setSuggestedFilename(const String& suggestedFilename) { m_suggestedFilename = suggestedFilename; }
bool delegateIsDecidingNavigationPolicy() const { return m_delegateIsDecidingNavigationPolicy; }
bool delegateIsHandlingUnimplementablePolicy() const { return m_delegateIsHandlingUnimplementablePolicy; }
void continueLoadAfterWillSubmitForm(PolicyAction);
#if ENABLE(CONTENT_FILTERING)
void setContentFilterUnblockHandler(ContentFilterUnblockHandler unblockHandler) { m_contentFilterUnblockHandler = WTFMove(unblockHandler); }
#endif
private:
void continueAfterNavigationPolicy(PolicyAction);
void continueAfterNewWindowPolicy(PolicyAction);
void continueAfterContentPolicy(PolicyAction);
void handleUnimplementablePolicy(const ResourceError&);
Frame& m_frame;
bool m_delegateIsDecidingNavigationPolicy;
bool m_delegateIsHandlingUnimplementablePolicy;
FrameLoadType m_loadType;
PolicyCallback m_callback;
String m_suggestedFilename;
#if ENABLE(CONTENT_FILTERING)
ContentFilterUnblockHandler m_contentFilterUnblockHandler;
#endif
};
}
#endif // PolicyChecker_h