blob: ef4cc9cac97c933ea4bf43063e1b666d48310756 [file] [log] [blame]
abarth@webkit.org390b1022009-10-08 06:17:22 +00001/*
bfulgham@apple.com8f831542016-03-31 15:35:41 +00002 * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
abarth@webkit.org390b1022009-10-08 06:17:22 +00003 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
mjs@apple.com92047332014-03-15 04:08:27 +000014 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
abarth@webkit.org390b1022009-10-08 06:17:22 +000015 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
commit-queue@webkit.org553e8d32016-11-12 08:57:21 +000030#pragma once
abarth@webkit.org390b1022009-10-08 06:17:22 +000031
32#include "FrameLoaderTypes.h"
abarth@webkit.org390b1022009-10-08 06:17:22 +000033#include "PolicyCallback.h"
abarth@webkit.orgfa616dd2013-03-03 09:16:26 +000034#include "ResourceRequest.h"
weinig@apple.com3f5ab022012-09-06 17:36:48 +000035#include <wtf/text/WTFString.h>
abarth@webkit.org390b1022009-10-08 06:17:22 +000036
aestes@apple.comc0486572015-03-20 08:42:59 +000037#if ENABLE(CONTENT_FILTERING)
38#include "ContentFilterUnblockHandler.h"
39#endif
40
abarth@webkit.org390b1022009-10-08 06:17:22 +000041namespace WebCore {
42
eric@webkit.orge133cb12009-10-16 23:44:48 +000043class DocumentLoader;
44class FormState;
45class Frame;
46class NavigationAction;
47class ResourceError;
48class ResourceResponse;
abarth@webkit.org390b1022009-10-08 06:17:22 +000049
commit-queue@webkit.orgf486c532017-08-24 21:45:38 +000050using NewWindowPolicyDecisionFunction = WTF::Function<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>;
51
ossy@webkit.org95c1bc42011-01-20 16:30:54 +000052class PolicyChecker {
53 WTF_MAKE_NONCOPYABLE(PolicyChecker);
cdumez@apple.com20ad7e62015-07-30 16:25:36 +000054 WTF_MAKE_FAST_ALLOCATED;
eric@webkit.orge133cb12009-10-16 23:44:48 +000055public:
akling@apple.come6d9acd2013-10-05 02:06:33 +000056 explicit PolicyChecker(Frame&);
abarth@webkit.org390b1022009-10-08 06:17:22 +000057
darin@apple.com961f2a52016-12-31 09:51:29 +000058 void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, DocumentLoader*, FormState*, NavigationPolicyDecisionFunction);
dbates@webkit.org28db74a2016-04-15 22:23:44 +000059 void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction);
commit-queue@webkit.orgf486c532017-08-24 21:45:38 +000060 void checkNewWindowPolicy(NavigationAction&&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction);
abarth@webkit.org390b1022009-10-08 06:17:22 +000061
eric@webkit.orge133cb12009-10-16 23:44:48 +000062 void stopCheck();
abarth@webkit.org390b1022009-10-08 06:17:22 +000063
eric@webkit.orge133cb12009-10-16 23:44:48 +000064 void cannotShowMIMEType(const ResourceResponse&);
abarth@webkit.org390b1022009-10-08 06:17:22 +000065
eric@webkit.orge133cb12009-10-16 23:44:48 +000066 FrameLoadType loadType() const { return m_loadType; }
67 void setLoadType(FrameLoadType loadType) { m_loadType = loadType; }
abarth@webkit.org390b1022009-10-08 06:17:22 +000068
bfulgham@apple.com8f831542016-03-31 15:35:41 +000069 void setSuggestedFilename(const String& suggestedFilename) { m_suggestedFilename = suggestedFilename; }
70
eric@webkit.orge133cb12009-10-16 23:44:48 +000071 bool delegateIsDecidingNavigationPolicy() const { return m_delegateIsDecidingNavigationPolicy; }
72 bool delegateIsHandlingUnimplementablePolicy() const { return m_delegateIsHandlingUnimplementablePolicy; }
abarth@webkit.org390b1022009-10-08 06:17:22 +000073
aestes@apple.comc0486572015-03-20 08:42:59 +000074#if ENABLE(CONTENT_FILTERING)
aestes@apple.com13aae082016-01-02 08:03:08 +000075 void setContentFilterUnblockHandler(ContentFilterUnblockHandler unblockHandler) { m_contentFilterUnblockHandler = WTFMove(unblockHandler); }
aestes@apple.comc0486572015-03-20 08:42:59 +000076#endif
77
eric@webkit.orge133cb12009-10-16 23:44:48 +000078private:
79 void continueAfterNavigationPolicy(PolicyAction);
abarth@webkit.org390b1022009-10-08 06:17:22 +000080
eric@webkit.orge133cb12009-10-16 23:44:48 +000081 void handleUnimplementablePolicy(const ResourceError&);
abarth@webkit.org390b1022009-10-08 06:17:22 +000082
akling@apple.come6d9acd2013-10-05 02:06:33 +000083 Frame& m_frame;
abarth@webkit.org390b1022009-10-08 06:17:22 +000084
eric@webkit.orge133cb12009-10-16 23:44:48 +000085 bool m_delegateIsDecidingNavigationPolicy;
86 bool m_delegateIsHandlingUnimplementablePolicy;
abarth@webkit.org390b1022009-10-08 06:17:22 +000087
eric@webkit.orge133cb12009-10-16 23:44:48 +000088 // This identifies the type of navigation action which prompted this load. Note
89 // that WebKit conveys this value as the WebActionNavigationTypeKey value
90 // on navigation action delegate callbacks.
91 FrameLoadType m_loadType;
92 PolicyCallback m_callback;
bfulgham@apple.com8f831542016-03-31 15:35:41 +000093 String m_suggestedFilename;
aestes@apple.comc0486572015-03-20 08:42:59 +000094
95#if ENABLE(CONTENT_FILTERING)
96 ContentFilterUnblockHandler m_contentFilterUnblockHandler;
97#endif
eric@webkit.orge133cb12009-10-16 23:44:48 +000098};
abarth@webkit.org390b1022009-10-08 06:17:22 +000099
100} // namespace WebCore