abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 1 | /* |
bfulgham@apple.com | 8f83154 | 2016-03-31 15:35:41 +0000 | [diff] [blame] | 2 | * Copyright (C) 2006-2016 Apple Inc. All rights reserved. |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 3 | * 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.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 14 | * 3. Neither the name of Apple Inc. ("Apple") nor the names of |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 15 | * 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.org | 553e8d3 | 2016-11-12 08:57:21 +0000 | [diff] [blame] | 30 | #pragma once |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 31 | |
| 32 | #include "FrameLoaderTypes.h" |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 33 | #include "PolicyCallback.h" |
abarth@webkit.org | fa616dd | 2013-03-03 09:16:26 +0000 | [diff] [blame] | 34 | #include "ResourceRequest.h" |
weinig@apple.com | 3f5ab02 | 2012-09-06 17:36:48 +0000 | [diff] [blame] | 35 | #include <wtf/text/WTFString.h> |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 36 | |
aestes@apple.com | c048657 | 2015-03-20 08:42:59 +0000 | [diff] [blame] | 37 | #if ENABLE(CONTENT_FILTERING) |
| 38 | #include "ContentFilterUnblockHandler.h" |
| 39 | #endif |
| 40 | |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 41 | namespace WebCore { |
| 42 | |
eric@webkit.org | e133cb1 | 2009-10-16 23:44:48 +0000 | [diff] [blame] | 43 | class DocumentLoader; |
| 44 | class FormState; |
| 45 | class Frame; |
| 46 | class NavigationAction; |
| 47 | class ResourceError; |
| 48 | class ResourceResponse; |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 49 | |
commit-queue@webkit.org | f486c53 | 2017-08-24 21:45:38 +0000 | [diff] [blame] | 50 | using NewWindowPolicyDecisionFunction = WTF::Function<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>; |
| 51 | |
ossy@webkit.org | 95c1bc4 | 2011-01-20 16:30:54 +0000 | [diff] [blame] | 52 | class PolicyChecker { |
| 53 | WTF_MAKE_NONCOPYABLE(PolicyChecker); |
cdumez@apple.com | 20ad7e6 | 2015-07-30 16:25:36 +0000 | [diff] [blame] | 54 | WTF_MAKE_FAST_ALLOCATED; |
eric@webkit.org | e133cb1 | 2009-10-16 23:44:48 +0000 | [diff] [blame] | 55 | public: |
akling@apple.com | e6d9acd | 2013-10-05 02:06:33 +0000 | [diff] [blame] | 56 | explicit PolicyChecker(Frame&); |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 57 | |
darin@apple.com | 961f2a5 | 2016-12-31 09:51:29 +0000 | [diff] [blame] | 58 | void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, DocumentLoader*, FormState*, NavigationPolicyDecisionFunction); |
dbates@webkit.org | 28db74a | 2016-04-15 22:23:44 +0000 | [diff] [blame] | 59 | void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction); |
commit-queue@webkit.org | f486c53 | 2017-08-24 21:45:38 +0000 | [diff] [blame] | 60 | void checkNewWindowPolicy(NavigationAction&&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction); |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 61 | |
eric@webkit.org | e133cb1 | 2009-10-16 23:44:48 +0000 | [diff] [blame] | 62 | void stopCheck(); |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 63 | |
eric@webkit.org | e133cb1 | 2009-10-16 23:44:48 +0000 | [diff] [blame] | 64 | void cannotShowMIMEType(const ResourceResponse&); |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 65 | |
eric@webkit.org | e133cb1 | 2009-10-16 23:44:48 +0000 | [diff] [blame] | 66 | FrameLoadType loadType() const { return m_loadType; } |
| 67 | void setLoadType(FrameLoadType loadType) { m_loadType = loadType; } |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 68 | |
bfulgham@apple.com | 8f83154 | 2016-03-31 15:35:41 +0000 | [diff] [blame] | 69 | void setSuggestedFilename(const String& suggestedFilename) { m_suggestedFilename = suggestedFilename; } |
| 70 | |
eric@webkit.org | e133cb1 | 2009-10-16 23:44:48 +0000 | [diff] [blame] | 71 | bool delegateIsDecidingNavigationPolicy() const { return m_delegateIsDecidingNavigationPolicy; } |
| 72 | bool delegateIsHandlingUnimplementablePolicy() const { return m_delegateIsHandlingUnimplementablePolicy; } |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 73 | |
aestes@apple.com | c048657 | 2015-03-20 08:42:59 +0000 | [diff] [blame] | 74 | #if ENABLE(CONTENT_FILTERING) |
aestes@apple.com | 13aae08 | 2016-01-02 08:03:08 +0000 | [diff] [blame] | 75 | void setContentFilterUnblockHandler(ContentFilterUnblockHandler unblockHandler) { m_contentFilterUnblockHandler = WTFMove(unblockHandler); } |
aestes@apple.com | c048657 | 2015-03-20 08:42:59 +0000 | [diff] [blame] | 76 | #endif |
| 77 | |
eric@webkit.org | e133cb1 | 2009-10-16 23:44:48 +0000 | [diff] [blame] | 78 | private: |
| 79 | void continueAfterNavigationPolicy(PolicyAction); |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 80 | |
eric@webkit.org | e133cb1 | 2009-10-16 23:44:48 +0000 | [diff] [blame] | 81 | void handleUnimplementablePolicy(const ResourceError&); |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 82 | |
akling@apple.com | e6d9acd | 2013-10-05 02:06:33 +0000 | [diff] [blame] | 83 | Frame& m_frame; |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 84 | |
eric@webkit.org | e133cb1 | 2009-10-16 23:44:48 +0000 | [diff] [blame] | 85 | bool m_delegateIsDecidingNavigationPolicy; |
| 86 | bool m_delegateIsHandlingUnimplementablePolicy; |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 87 | |
eric@webkit.org | e133cb1 | 2009-10-16 23:44:48 +0000 | [diff] [blame] | 88 | // 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.com | 8f83154 | 2016-03-31 15:35:41 +0000 | [diff] [blame] | 93 | String m_suggestedFilename; |
aestes@apple.com | c048657 | 2015-03-20 08:42:59 +0000 | [diff] [blame] | 94 | |
| 95 | #if ENABLE(CONTENT_FILTERING) |
| 96 | ContentFilterUnblockHandler m_contentFilterUnblockHandler; |
| 97 | #endif |
eric@webkit.org | e133cb1 | 2009-10-16 23:44:48 +0000 | [diff] [blame] | 98 | }; |
abarth@webkit.org | 390b102 | 2009-10-08 06:17:22 +0000 | [diff] [blame] | 99 | |
| 100 | } // namespace WebCore |