Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (222471 => 222472)
--- trunk/Source/WebCore/CMakeLists.txt 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-09-25 22:33:19 UTC (rev 222472)
@@ -2116,7 +2116,6 @@
loader/NavigationScheduler.cpp
loader/NetscapePlugInStreamLoader.cpp
loader/PingLoader.cpp
- loader/PolicyCallback.cpp
loader/PolicyChecker.cpp
loader/ProgressTracker.cpp
loader/ResourceCryptographicDigest.cpp
Modified: trunk/Source/WebCore/ChangeLog (222471 => 222472)
--- trunk/Source/WebCore/ChangeLog 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebCore/ChangeLog 2017-09-25 22:33:19 UTC (rev 222472)
@@ -1,3 +1,29 @@
+2017-09-25 Alex Christensen <[email protected]>
+
+ Stop using PolicyCallback
+ https://bugs.webkit.org/show_bug.cgi?id=176088
+
+ Reviewed by Andy Estes.
+
+ This is what lambdas are for. No change in behavior.
+ Cancelling the callback is now the responsibility of the FrameLoaderClient, to whom we have given the lambda.
+ That is why there are changes in WebKit and WebKitLegacy where the FrameLoaderClient::cancelPolicyCheck finds the lambda it has stored.
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * loader/DocumentLoader.cpp:
+ * loader/FrameLoader.cpp:
+ * loader/FrameLoaderClient.h:
+ * loader/PolicyCallback.cpp: Removed.
+ * loader/PolicyCallback.h: Removed.
+ * loader/PolicyChecker.cpp:
+ (WebCore::PolicyChecker::checkNavigationPolicy):
+ (WebCore::PolicyChecker::checkNewWindowPolicy):
+ (WebCore::PolicyChecker::stopCheck):
+ (WebCore::PolicyChecker::continueAfterNavigationPolicy): Deleted.
+ * loader/PolicyChecker.h:
+ (WebCore::PolicyChecker::setSuggestedFilename): Deleted.
+
2017-09-25 Youenn Fablet <[email protected]>
MediaStreamTrack.getSettings should compute its deviceId/groupId like enumerateDevices
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (222471 => 222472)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-09-25 22:33:19 UTC (rev 222472)
@@ -4105,8 +4105,6 @@
952076061F2675FE007D2AAB /* CallTracerTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 952076021F2675F9007D2AAB /* CallTracerTypes.h */; };
96ABA42314BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 96ABA42214BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp */; };
9703E1BF15DC4E37001F24C8 /* JSVoidCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97E9EC8B15DC492F004F2E71 /* JSVoidCallback.cpp */; };
- 97059977107D975200A50A7C /* PolicyCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97059973107D975200A50A7C /* PolicyCallback.cpp */; };
- 97059978107D975200A50A7C /* PolicyCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059974107D975200A50A7C /* PolicyCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
97059979107D975200A50A7C /* PolicyChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97059975107D975200A50A7C /* PolicyChecker.cpp */; };
9705997A107D975200A50A7C /* PolicyChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059976107D975200A50A7C /* PolicyChecker.h */; settings = {ATTRIBUTES = (Private, ); }; };
970B728A144FFAC600F00A37 /* EventInterfaces.h in Headers */ = {isa = PBXBuildFile; fileRef = 970B7289144FFAC600F00A37 /* EventInterfaces.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -12470,8 +12468,6 @@
952076011F2675F9007D2AAB /* CallTracer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CallTracer.h; sourceTree = "<group>"; };
952076021F2675F9007D2AAB /* CallTracerTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CallTracerTypes.h; sourceTree = "<group>"; };
96ABA42214BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DOpenGLCommon.cpp; sourceTree = "<group>"; };
- 97059973107D975200A50A7C /* PolicyCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyCallback.cpp; sourceTree = "<group>"; };
- 97059974107D975200A50A7C /* PolicyCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyCallback.h; sourceTree = "<group>"; };
97059975107D975200A50A7C /* PolicyChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyChecker.cpp; sourceTree = "<group>"; };
97059976107D975200A50A7C /* PolicyChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyChecker.h; sourceTree = "<group>"; };
970B7289144FFAC600F00A37 /* EventInterfaces.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventInterfaces.h; sourceTree = "<group>"; };
@@ -24463,8 +24459,6 @@
656D372B0ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h */,
D0FF2A5B11F8C45A007E74E0 /* PingLoader.cpp */,
D0FF2A5C11F8C45A007E74E0 /* PingLoader.h */,
- 97059973107D975200A50A7C /* PolicyCallback.cpp */,
- 97059974107D975200A50A7C /* PolicyCallback.h */,
97059975107D975200A50A7C /* PolicyChecker.cpp */,
97059976107D975200A50A7C /* PolicyChecker.h */,
1A2A68210B5BEDE70002A480 /* ProgressTracker.cpp */,
@@ -29587,7 +29581,6 @@
B2B1F7170D00CAA8004AEA64 /* PointerEventsHitRules.h in Headers */,
3FF813A71DBA8640009BF001 /* PointerLockController.h in Headers */,
84730D921248F0B300D3A9C9 /* PointLightSource.h in Headers */,
- 97059978107D975200A50A7C /* PolicyCallback.h in Headers */,
9705997A107D975200A50A7C /* PolicyChecker.h in Headers */,
FD45A957175D414C00C21EC8 /* PolygonShape.h in Headers */,
5174E20A10A1F44F00F95E6F /* PopStateEvent.h in Headers */,
@@ -33578,7 +33571,6 @@
B2B1F7160D00CAA8004AEA64 /* PointerEventsHitRules.cpp in Sources */,
5CFC4350192409E300A0D3B5 /* PointerLockController.cpp in Sources */,
A1E1154613015C4E0054AC8C /* PointLightSource.cpp in Sources */,
- 97059977107D975200A50A7C /* PolicyCallback.cpp in Sources */,
97059979107D975200A50A7C /* PolicyChecker.cpp in Sources */,
FD45A959175D417100C21EC8 /* PolygonShape.cpp in Sources */,
5189F0DE10B46B0E00F3C739 /* PopStateEvent.cpp in Sources */,
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (222471 => 222472)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2017-09-25 22:33:19 UTC (rev 222472)
@@ -75,6 +75,7 @@
#include "SubresourceLoader.h"
#include "TextResourceDecoder.h"
#include <wtf/Assertions.h>
+#include <wtf/CompletionHandler.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/Ref.h>
#include <wtf/text/CString.h>
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (222471 => 222472)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2017-09-25 22:33:19 UTC (rev 222472)
@@ -119,6 +119,7 @@
#include "UserContentController.h"
#include "WindowFeatures.h"
#include "XMLDocumentParser.h"
+#include <wtf/CompletionHandler.h>
#include <wtf/CurrentTime.h>
#include <wtf/Ref.h>
#include <wtf/StdLibExtras.h>
Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (222471 => 222472)
--- trunk/Source/WebCore/loader/FrameLoaderClient.h 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h 2017-09-25 22:33:19 UTC (rev 222472)
@@ -84,7 +84,6 @@
class NavigationAction;
class Page;
class PluginViewBase;
-class PolicyChecker;
class PreviewLoaderClient;
class ProtectionSpace;
class RTCPeerConnectionHandler;
Deleted: trunk/Source/WebCore/loader/PolicyCallback.cpp (222471 => 222472)
--- trunk/Source/WebCore/loader/PolicyCallback.cpp 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebCore/loader/PolicyCallback.cpp 2017-09-25 22:33:19 UTC (rev 222472)
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PolicyCallback.h"
-
-#include "FormState.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "HTMLFormElement.h"
-
-namespace WebCore {
-
-void PolicyCallback::set(const ResourceRequest& request, FormState* formState, NavigationPolicyDecisionFunction&& function)
-{
- m_request = request;
- m_formState = formState;
- m_frameName = String();
-
- m_navigationFunction = WTFMove(function);
-}
-
-void PolicyCallback::call(bool shouldContinue)
-{
- if (m_navigationFunction)
- m_navigationFunction(m_request, m_formState.get(), shouldContinue);
-}
-
-void PolicyCallback::clearRequest()
-{
- m_request = ResourceRequest();
- m_formState = nullptr;
- m_frameName = String();
-}
-
-void PolicyCallback::cancel()
-{
- clearRequest();
- if (m_navigationFunction)
- m_navigationFunction(m_request, m_formState.get(), false);
-}
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/loader/PolicyCallback.h (222471 => 222472)
--- trunk/Source/WebCore/loader/PolicyCallback.h 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebCore/loader/PolicyCallback.h 2017-09-25 22:33:19 UTC (rev 222472)
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
- * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "FrameLoaderTypes.h"
-#include "NavigationAction.h"
-#include "ResourceRequest.h"
-#include <functional>
-#include <wtf/Function.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-class FormState;
-
-using NavigationPolicyDecisionFunction = Function<void(const ResourceRequest&, FormState*, bool shouldContinue)>;
-
-class PolicyCallback {
-public:
- void set(const ResourceRequest&, FormState*, NavigationPolicyDecisionFunction&&);
-
- const ResourceRequest& request() const { return m_request; }
- void clearRequest();
-
- void call(bool shouldContinue);
- void cancel();
-
-private:
- ResourceRequest m_request;
- RefPtr<FormState> m_formState;
- String m_frameName;
- NavigationAction m_navigationAction;
-
- NavigationPolicyDecisionFunction m_navigationFunction;
-};
-
-} // namespace WebCore
Modified: trunk/Source/WebCore/loader/PolicyChecker.cpp (222471 => 222472)
--- trunk/Source/WebCore/loader/PolicyChecker.cpp 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebCore/loader/PolicyChecker.cpp 2017-09-25 22:33:19 UTC (rev 222472)
@@ -44,6 +44,7 @@
#include "HTMLFormElement.h"
#include "HTMLFrameOwnerElement.h"
#include "HTMLPlugInElement.h"
+#include <wtf/CompletionHandler.h>
#if USE(QUICK_LOOK)
#include "QuickLook.h"
@@ -75,12 +76,12 @@
{
}
-void PolicyChecker::checkNavigationPolicy(const ResourceRequest& newRequest, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction function)
+void PolicyChecker::checkNavigationPolicy(const ResourceRequest& newRequest, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction&& function)
{
checkNavigationPolicy(newRequest, didReceiveRedirectResponse, m_frame.loader().activeDocumentLoader(), nullptr, WTFMove(function));
}
-void PolicyChecker::checkNavigationPolicy(const ResourceRequest& request, bool didReceiveRedirectResponse, DocumentLoader* loader, FormState* formState, NavigationPolicyDecisionFunction function)
+void PolicyChecker::checkNavigationPolicy(const ResourceRequest& request, bool didReceiveRedirectResponse, DocumentLoader* loader, FormState* formState, NavigationPolicyDecisionFunction&& function)
{
NavigationAction action = ""
if (action.isEmpty()) {
@@ -91,7 +92,7 @@
// Don't ask more than once for the same request or if we are loading an empty URL.
// This avoids confusion on the part of the client.
if (equalIgnoringHeaderFields(request, loader->lastCheckedRequest()) || (!request.isNull() && request.url().isEmpty())) {
- function(request, 0, true);
+ function(request, nullptr, true);
loader->setLastCheckedRequest(request);
return;
}
@@ -106,7 +107,7 @@
#endif
if (isBackForwardLoadType(m_loadType))
m_loadType = FrameLoadType::Reload;
- function(request, 0, shouldContinue);
+ function(request, nullptr, shouldContinue);
return;
}
@@ -116,20 +117,16 @@
// reveal that the frame was blocked. This way, it looks like any other cross-origin page load.
m_frame.ownerElement()->dispatchEvent(Event::create(eventNames().loadEvent, false, false));
}
- function(request, 0, false);
+ function(request, nullptr, false);
return;
}
loader->setLastCheckedRequest(request);
- m_callback.set(request, formState, WTFMove(function));
-
#if USE(QUICK_LOOK)
// Always allow QuickLook-generated URLs based on the protocol scheme.
- if (!request.isNull() && isQuickLookPreviewURL(request.url())) {
- continueAfterNavigationPolicy(PolicyUse);
- return;
- }
+ if (!request.isNull() && isQuickLookPreviewURL(request.url()))
+ return function(request, formState, true);
#endif
#if ENABLE(CONTENT_FILTERING)
@@ -139,29 +136,43 @@
if (unblocked)
frame->loader().reload();
});
- continueAfterNavigationPolicy(PolicyIgnore);
- return;
+ return function({ }, nullptr, false);
}
m_contentFilterUnblockHandler = { };
#endif
m_delegateIsDecidingNavigationPolicy = true;
- m_suggestedFilename = action.downloadAttribute().isEmpty() ? nullAtom() : action.downloadAttribute();
- m_frame.loader().client().dispatchDecidePolicyForNavigationAction(action, request, didReceiveRedirectResponse, formState, [this](PolicyAction action) {
- continueAfterNavigationPolicy(action);
+ String suggestedFilename = action.downloadAttribute().isEmpty() ? nullAtom() : action.downloadAttribute();
+ ResourceRequest requestCopy = request;
+ m_frame.loader().client().dispatchDecidePolicyForNavigationAction(action, request, didReceiveRedirectResponse, formState, [this, function = WTFMove(function), request = WTFMove(requestCopy), formState = makeRefPtr(formState), suggestedFilename = WTFMove(suggestedFilename)](PolicyAction policyAction) mutable {
+ switch (policyAction) {
+ case PolicyDownload:
+ m_frame.loader().setOriginalURLForDownloadRequest(request);
+ m_frame.loader().client().startDownload(request, suggestedFilename);
+ FALLTHROUGH;
+ case PolicyIgnore:
+ return function({ }, nullptr, false);
+ case PolicyUse:
+ if (!m_frame.loader().client().canHandleRequest(request)) {
+ handleUnimplementablePolicy(m_frame.loader().client().cannotShowURLError(request));
+ return function({ }, nullptr, false);
+ }
+ return function(request, formState.get(), true);
+ }
+ ASSERT_NOT_REACHED();
});
m_delegateIsDecidingNavigationPolicy = false;
}
-void PolicyChecker::checkNewWindowPolicy(NavigationAction&& navigationAction, const ResourceRequest& request, FormState* formState, const String& frameName, NewWindowPolicyDecisionFunction function)
+void PolicyChecker::checkNewWindowPolicy(NavigationAction&& navigationAction, const ResourceRequest& request, FormState* formState, const String& frameName, NewWindowPolicyDecisionFunction&& function)
{
if (m_frame.document() && m_frame.document()->isSandboxed(SandboxPopups))
- return continueAfterNavigationPolicy(PolicyIgnore);
+ return function({ }, nullptr, { }, { }, false);
if (!DOMWindow::allowPopUp(m_frame))
- return continueAfterNavigationPolicy(PolicyIgnore);
+ return function({ }, nullptr, { }, { }, false);
- m_frame.loader().client().dispatchDecidePolicyForNewWindowAction(navigationAction, request, formState, frameName, [frame = makeRef(m_frame), request, formState = makeRefPtr(formState), frameName, navigationAction, function = WTFMove(function)](PolicyAction policyAction) {
+ m_frame.loader().client().dispatchDecidePolicyForNewWindowAction(navigationAction, request, formState, frameName, [frame = makeRef(m_frame), request, formState = makeRefPtr(formState), frameName, navigationAction, function = WTFMove(function)](PolicyAction policyAction) mutable {
switch (policyAction) {
case PolicyDownload:
frame->loader().client().startDownload(request);
@@ -180,8 +191,6 @@
void PolicyChecker::stopCheck()
{
m_frame.loader().client().cancelPolicyCheck();
- PolicyCallback callback = WTFMove(m_callback);
- callback.cancel();
}
void PolicyChecker::cannotShowMIMEType(const ResourceResponse& response)
@@ -189,38 +198,6 @@
handleUnimplementablePolicy(m_frame.loader().client().cannotShowMIMETypeError(response));
}
-void PolicyChecker::continueAfterNavigationPolicy(PolicyAction policy)
-{
- PolicyCallback callback = WTFMove(m_callback);
-
- bool shouldContinue = policy == PolicyUse;
-
- switch (policy) {
- case PolicyIgnore:
- callback.clearRequest();
- break;
- case PolicyDownload: {
- ResourceRequest request = callback.request();
- m_frame.loader().setOriginalURLForDownloadRequest(request);
- m_frame.loader().client().startDownload(request, m_suggestedFilename);
- callback.clearRequest();
- break;
- }
- case PolicyUse: {
- ResourceRequest request(callback.request());
-
- if (!m_frame.loader().client().canHandleRequest(request)) {
- handleUnimplementablePolicy(m_frame.loader().client().cannotShowURLError(callback.request()));
- callback.clearRequest();
- shouldContinue = false;
- }
- break;
- }
- }
-
- callback.call(shouldContinue);
-}
-
void PolicyChecker::handleUnimplementablePolicy(const ResourceError& error)
{
m_delegateIsHandlingUnimplementablePolicy = true;
Modified: trunk/Source/WebCore/loader/PolicyChecker.h (222471 => 222472)
--- trunk/Source/WebCore/loader/PolicyChecker.h 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebCore/loader/PolicyChecker.h 2017-09-25 22:33:19 UTC (rev 222472)
@@ -30,7 +30,6 @@
#pragma once
#include "FrameLoaderTypes.h"
-#include "PolicyCallback.h"
#include "ResourceRequest.h"
#include <wtf/text/WTFString.h>
@@ -38,6 +37,10 @@
#include "ContentFilterUnblockHandler.h"
#endif
+namespace WTF {
+template<typename> class CompletionHandler;
+}
+
namespace WebCore {
class DocumentLoader;
@@ -47,7 +50,8 @@
class ResourceError;
class ResourceResponse;
-using NewWindowPolicyDecisionFunction = WTF::Function<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>;
+using NewWindowPolicyDecisionFunction = WTF::CompletionHandler<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>;
+using NavigationPolicyDecisionFunction = WTF::CompletionHandler<void(const ResourceRequest&, FormState*, bool shouldContinue)>;
class PolicyChecker {
WTF_MAKE_NONCOPYABLE(PolicyChecker);
@@ -55,9 +59,9 @@
public:
explicit PolicyChecker(Frame&);
- void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, DocumentLoader*, FormState*, NavigationPolicyDecisionFunction);
- void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction);
- void checkNewWindowPolicy(NavigationAction&&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction);
+ void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, DocumentLoader*, FormState*, NavigationPolicyDecisionFunction&&);
+ void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction&&);
+ void checkNewWindowPolicy(NavigationAction&&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction&&);
void stopCheck();
@@ -66,8 +70,6 @@
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; }
@@ -76,8 +78,6 @@
#endif
private:
- void continueAfterNavigationPolicy(PolicyAction);
-
void handleUnimplementablePolicy(const ResourceError&);
Frame& m_frame;
@@ -89,8 +89,6 @@
// that WebKit conveys this value as the WebActionNavigationTypeKey value
// on navigation action delegate callbacks.
FrameLoadType m_loadType;
- PolicyCallback m_callback;
- String m_suggestedFilename;
#if ENABLE(CONTENT_FILTERING)
ContentFilterUnblockHandler m_contentFilterUnblockHandler;
Modified: trunk/Source/WebKit/ChangeLog (222471 => 222472)
--- trunk/Source/WebKit/ChangeLog 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebKit/ChangeLog 2017-09-25 22:33:19 UTC (rev 222472)
@@ -1,3 +1,16 @@
+2017-09-25 Alex Christensen <[email protected]>
+
+ Stop using PolicyCallback
+ https://bugs.webkit.org/show_bug.cgi?id=176088
+
+ Reviewed by Andy Estes.
+
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ * WebProcess/WebPage/WebFrame.cpp:
+ (WebKit::WebFrame::invalidatePolicyListener):
+ * WebProcess/WebPage/WebFrame.h:
+ * WebProcess/WebPage/WebInspector.cpp:
+
2017-09-25 Chris Dumez <[email protected]>
[WK2] Add API to query if a download was user-initiated
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (222471 => 222472)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2017-09-25 22:33:19 UTC (rev 222472)
@@ -77,6 +77,7 @@
#include <WebCore/Page.h>
#include <WebCore/PluginData.h>
#include <WebCore/PluginDocument.h>
+#include <WebCore/PolicyChecker.h>
#include <WebCore/ProgressTracker.h>
#include <WebCore/ResourceError.h>
#include <WebCore/ScriptController.h>
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp (222471 => 222472)
--- trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp 2017-09-25 22:33:19 UTC (rev 222472)
@@ -240,7 +240,8 @@
m_policyDownloadID = { };
m_policyListenerID = 0;
- m_policyFunction = nullptr;
+ if (auto function = std::exchange(m_policyFunction, nullptr))
+ function(PolicyIgnore);
}
void WebFrame::didReceivePolicyDecision(uint64_t listenerID, PolicyAction action, uint64_t navigationID, DownloadID downloadID)
@@ -254,7 +255,8 @@
if (listenerID != m_policyListenerID)
return;
- ASSERT(m_policyFunction);
+ if (!m_policyFunction)
+ return;
FramePolicyFunction function = WTFMove(m_policyFunction);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebFrame.h (222471 => 222472)
--- trunk/Source/WebKit/WebProcess/WebPage/WebFrame.h 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebFrame.h 2017-09-25 22:33:19 UTC (rev 222472)
@@ -33,8 +33,8 @@
#include <_javascript_Core/JSBase.h>
#include <WebCore/FrameLoaderClient.h>
#include <WebCore/FrameLoaderTypes.h>
-#include <WebCore/PolicyChecker.h>
#include <wtf/Forward.h>
+#include <wtf/HashMap.h>
#include <wtf/RefPtr.h>
#include <wtf/RetainPtr.h>
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp (222471 => 222472)
--- trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp 2017-09-25 22:33:19 UTC (rev 222472)
@@ -41,6 +41,7 @@
#include <WebCore/InspectorFrontendClient.h>
#include <WebCore/InspectorPageAgent.h>
#include <WebCore/MainFrame.h>
+#include <WebCore/NavigationAction.h>
#include <WebCore/NotImplemented.h>
#include <WebCore/Page.h>
#include <WebCore/ScriptController.h>
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (222471 => 222472)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2017-09-25 22:33:19 UTC (rev 222472)
@@ -1,3 +1,14 @@
+2017-09-25 Alex Christensen <[email protected]>
+
+ Stop using PolicyCallback
+ https://bugs.webkit.org/show_bug.cgi?id=176088
+
+ Reviewed by Andy Estes.
+
+ * WebCoreSupport/WebFrameLoaderClient.mm:
+ (-[WebFramePolicyListener invalidate]):
+ (-[WebFramePolicyListener receivedPolicyDecision:]):
+
2017-09-25 Sam Weinig <[email protected]>
Remove unnecessary userVisibleString EditorClient function
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm (222471 => 222472)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm 2017-09-25 21:46:46 UTC (rev 222471)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm 2017-09-25 22:33:19 UTC (rev 222472)
@@ -2409,6 +2409,8 @@
- (void)invalidate
{
_frame = nullptr;
+ if (auto policyFunction = std::exchange(_policyFunction, nullptr))
+ policyFunction(PolicyIgnore);
}
- (void)dealloc
@@ -2425,11 +2427,8 @@
if (!frame)
return;
- FramePolicyFunction policyFunction = WTFMove(_policyFunction);
- _policyFunction = nullptr;
-
- ASSERT(policyFunction);
- policyFunction(action);
+ if (auto policyFunction = std::exchange(_policyFunction, nullptr))
+ policyFunction(action);
}
- (void)ignore