Changeset 222472 in webkit
- Timestamp:
- Sep 25, 2017 3:33:19 PM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r222395 r222472 2117 2117 loader/NetscapePlugInStreamLoader.cpp 2118 2118 loader/PingLoader.cpp 2119 loader/PolicyCallback.cpp2120 2119 loader/PolicyChecker.cpp 2121 2120 loader/ProgressTracker.cpp -
trunk/Source/WebCore/ChangeLog
r222471 r222472 1 2017-09-25 Alex Christensen <achristensen@webkit.org> 2 3 Stop using PolicyCallback 4 https://bugs.webkit.org/show_bug.cgi?id=176088 5 6 Reviewed by Andy Estes. 7 8 This is what lambdas are for. No change in behavior. 9 Cancelling the callback is now the responsibility of the FrameLoaderClient, to whom we have given the lambda. 10 That is why there are changes in WebKit and WebKitLegacy where the FrameLoaderClient::cancelPolicyCheck finds the lambda it has stored. 11 12 * CMakeLists.txt: 13 * WebCore.xcodeproj/project.pbxproj: 14 * loader/DocumentLoader.cpp: 15 * loader/FrameLoader.cpp: 16 * loader/FrameLoaderClient.h: 17 * loader/PolicyCallback.cpp: Removed. 18 * loader/PolicyCallback.h: Removed. 19 * loader/PolicyChecker.cpp: 20 (WebCore::PolicyChecker::checkNavigationPolicy): 21 (WebCore::PolicyChecker::checkNewWindowPolicy): 22 (WebCore::PolicyChecker::stopCheck): 23 (WebCore::PolicyChecker::continueAfterNavigationPolicy): Deleted. 24 * loader/PolicyChecker.h: 25 (WebCore::PolicyChecker::setSuggestedFilename): Deleted. 26 1 27 2017-09-25 Youenn Fablet <youenn@apple.com> 2 28 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r222467 r222472 4106 4106 96ABA42314BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 96ABA42214BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp */; }; 4107 4107 9703E1BF15DC4E37001F24C8 /* JSVoidCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97E9EC8B15DC492F004F2E71 /* JSVoidCallback.cpp */; }; 4108 97059977107D975200A50A7C /* PolicyCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97059973107D975200A50A7C /* PolicyCallback.cpp */; };4109 97059978107D975200A50A7C /* PolicyCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059974107D975200A50A7C /* PolicyCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };4110 4108 97059979107D975200A50A7C /* PolicyChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97059975107D975200A50A7C /* PolicyChecker.cpp */; }; 4111 4109 9705997A107D975200A50A7C /* PolicyChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059976107D975200A50A7C /* PolicyChecker.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 12471 12469 952076021F2675F9007D2AAB /* CallTracerTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CallTracerTypes.h; sourceTree = "<group>"; }; 12472 12470 96ABA42214BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DOpenGLCommon.cpp; sourceTree = "<group>"; }; 12473 97059973107D975200A50A7C /* PolicyCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyCallback.cpp; sourceTree = "<group>"; };12474 97059974107D975200A50A7C /* PolicyCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyCallback.h; sourceTree = "<group>"; };12475 12471 97059975107D975200A50A7C /* PolicyChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyChecker.cpp; sourceTree = "<group>"; }; 12476 12472 97059976107D975200A50A7C /* PolicyChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyChecker.h; sourceTree = "<group>"; }; … … 24464 24460 D0FF2A5B11F8C45A007E74E0 /* PingLoader.cpp */, 24465 24461 D0FF2A5C11F8C45A007E74E0 /* PingLoader.h */, 24466 97059973107D975200A50A7C /* PolicyCallback.cpp */,24467 97059974107D975200A50A7C /* PolicyCallback.h */,24468 24462 97059975107D975200A50A7C /* PolicyChecker.cpp */, 24469 24463 97059976107D975200A50A7C /* PolicyChecker.h */, … … 29588 29582 3FF813A71DBA8640009BF001 /* PointerLockController.h in Headers */, 29589 29583 84730D921248F0B300D3A9C9 /* PointLightSource.h in Headers */, 29590 97059978107D975200A50A7C /* PolicyCallback.h in Headers */,29591 29584 9705997A107D975200A50A7C /* PolicyChecker.h in Headers */, 29592 29585 FD45A957175D414C00C21EC8 /* PolygonShape.h in Headers */, … … 33579 33572 5CFC4350192409E300A0D3B5 /* PointerLockController.cpp in Sources */, 33580 33573 A1E1154613015C4E0054AC8C /* PointLightSource.cpp in Sources */, 33581 97059977107D975200A50A7C /* PolicyCallback.cpp in Sources */,33582 33574 97059979107D975200A50A7C /* PolicyChecker.cpp in Sources */, 33583 33575 FD45A959175D417100C21EC8 /* PolygonShape.cpp in Sources */, -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r222467 r222472 76 76 #include "TextResourceDecoder.h" 77 77 #include <wtf/Assertions.h> 78 #include <wtf/CompletionHandler.h> 78 79 #include <wtf/NeverDestroyed.h> 79 80 #include <wtf/Ref.h> -
trunk/Source/WebCore/loader/FrameLoader.cpp
r222467 r222472 120 120 #include "WindowFeatures.h" 121 121 #include "XMLDocumentParser.h" 122 #include <wtf/CompletionHandler.h> 122 123 #include <wtf/CurrentTime.h> 123 124 #include <wtf/Ref.h> -
trunk/Source/WebCore/loader/FrameLoaderClient.h
r222456 r222472 85 85 class Page; 86 86 class PluginViewBase; 87 class PolicyChecker;88 87 class PreviewLoaderClient; 89 88 class ProtectionSpace; -
trunk/Source/WebCore/loader/PolicyChecker.cpp
r222456 r222472 45 45 #include "HTMLFrameOwnerElement.h" 46 46 #include "HTMLPlugInElement.h" 47 #include <wtf/CompletionHandler.h> 47 48 48 49 #if USE(QUICK_LOOK) … … 76 77 } 77 78 78 void PolicyChecker::checkNavigationPolicy(const ResourceRequest& newRequest, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction function)79 void PolicyChecker::checkNavigationPolicy(const ResourceRequest& newRequest, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction&& function) 79 80 { 80 81 checkNavigationPolicy(newRequest, didReceiveRedirectResponse, m_frame.loader().activeDocumentLoader(), nullptr, WTFMove(function)); 81 82 } 82 83 83 void PolicyChecker::checkNavigationPolicy(const ResourceRequest& request, bool didReceiveRedirectResponse, DocumentLoader* loader, FormState* formState, NavigationPolicyDecisionFunction function)84 void PolicyChecker::checkNavigationPolicy(const ResourceRequest& request, bool didReceiveRedirectResponse, DocumentLoader* loader, FormState* formState, NavigationPolicyDecisionFunction&& function) 84 85 { 85 86 NavigationAction action = loader->triggeringAction(); … … 92 93 // This avoids confusion on the part of the client. 93 94 if (equalIgnoringHeaderFields(request, loader->lastCheckedRequest()) || (!request.isNull() && request.url().isEmpty())) { 94 function(request, 0, true);95 function(request, nullptr, true); 95 96 loader->setLastCheckedRequest(request); 96 97 return; … … 107 108 if (isBackForwardLoadType(m_loadType)) 108 109 m_loadType = FrameLoadType::Reload; 109 function(request, 0, shouldContinue);110 function(request, nullptr, shouldContinue); 110 111 return; 111 112 } … … 117 118 m_frame.ownerElement()->dispatchEvent(Event::create(eventNames().loadEvent, false, false)); 118 119 } 119 function(request, 0, false);120 function(request, nullptr, false); 120 121 return; 121 122 } 122 123 123 124 loader->setLastCheckedRequest(request); 124 125 m_callback.set(request, formState, WTFMove(function));126 125 127 126 #if USE(QUICK_LOOK) 128 127 // Always allow QuickLook-generated URLs based on the protocol scheme. 129 if (!request.isNull() && isQuickLookPreviewURL(request.url())) { 130 continueAfterNavigationPolicy(PolicyUse); 131 return; 132 } 128 if (!request.isNull() && isQuickLookPreviewURL(request.url())) 129 return function(request, formState, true); 133 130 #endif 134 131 … … 140 137 frame->loader().reload(); 141 138 }); 142 continueAfterNavigationPolicy(PolicyIgnore); 143 return; 139 return function({ }, nullptr, false); 144 140 } 145 141 m_contentFilterUnblockHandler = { }; … … 147 143 148 144 m_delegateIsDecidingNavigationPolicy = true; 149 m_suggestedFilename = action.downloadAttribute().isEmpty() ? nullAtom() : action.downloadAttribute(); 150 m_frame.loader().client().dispatchDecidePolicyForNavigationAction(action, request, didReceiveRedirectResponse, formState, [this](PolicyAction action) { 151 continueAfterNavigationPolicy(action); 145 String suggestedFilename = action.downloadAttribute().isEmpty() ? nullAtom() : action.downloadAttribute(); 146 ResourceRequest requestCopy = request; 147 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 { 148 switch (policyAction) { 149 case PolicyDownload: 150 m_frame.loader().setOriginalURLForDownloadRequest(request); 151 m_frame.loader().client().startDownload(request, suggestedFilename); 152 FALLTHROUGH; 153 case PolicyIgnore: 154 return function({ }, nullptr, false); 155 case PolicyUse: 156 if (!m_frame.loader().client().canHandleRequest(request)) { 157 handleUnimplementablePolicy(m_frame.loader().client().cannotShowURLError(request)); 158 return function({ }, nullptr, false); 159 } 160 return function(request, formState.get(), true); 161 } 162 ASSERT_NOT_REACHED(); 152 163 }); 153 164 m_delegateIsDecidingNavigationPolicy = false; 154 165 } 155 166 156 void PolicyChecker::checkNewWindowPolicy(NavigationAction&& navigationAction, const ResourceRequest& request, FormState* formState, const String& frameName, NewWindowPolicyDecisionFunction function)167 void PolicyChecker::checkNewWindowPolicy(NavigationAction&& navigationAction, const ResourceRequest& request, FormState* formState, const String& frameName, NewWindowPolicyDecisionFunction&& function) 157 168 { 158 169 if (m_frame.document() && m_frame.document()->isSandboxed(SandboxPopups)) 159 return continueAfterNavigationPolicy(PolicyIgnore);170 return function({ }, nullptr, { }, { }, false); 160 171 161 172 if (!DOMWindow::allowPopUp(m_frame)) 162 return continueAfterNavigationPolicy(PolicyIgnore);163 164 m_frame.loader().client().dispatchDecidePolicyForNewWindowAction(navigationAction, request, formState, frameName, [frame = makeRef(m_frame), request, formState = makeRefPtr(formState), frameName, navigationAction, function = WTFMove(function)](PolicyAction policyAction) {173 return function({ }, nullptr, { }, { }, false); 174 175 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 { 165 176 switch (policyAction) { 166 177 case PolicyDownload: … … 181 192 { 182 193 m_frame.loader().client().cancelPolicyCheck(); 183 PolicyCallback callback = WTFMove(m_callback);184 callback.cancel();185 194 } 186 195 … … 188 197 { 189 198 handleUnimplementablePolicy(m_frame.loader().client().cannotShowMIMETypeError(response)); 190 }191 192 void PolicyChecker::continueAfterNavigationPolicy(PolicyAction policy)193 {194 PolicyCallback callback = WTFMove(m_callback);195 196 bool shouldContinue = policy == PolicyUse;197 198 switch (policy) {199 case PolicyIgnore:200 callback.clearRequest();201 break;202 case PolicyDownload: {203 ResourceRequest request = callback.request();204 m_frame.loader().setOriginalURLForDownloadRequest(request);205 m_frame.loader().client().startDownload(request, m_suggestedFilename);206 callback.clearRequest();207 break;208 }209 case PolicyUse: {210 ResourceRequest request(callback.request());211 212 if (!m_frame.loader().client().canHandleRequest(request)) {213 handleUnimplementablePolicy(m_frame.loader().client().cannotShowURLError(callback.request()));214 callback.clearRequest();215 shouldContinue = false;216 }217 break;218 }219 }220 221 callback.call(shouldContinue);222 199 } 223 200 -
trunk/Source/WebCore/loader/PolicyChecker.h
r222456 r222472 31 31 32 32 #include "FrameLoaderTypes.h" 33 #include "PolicyCallback.h"34 33 #include "ResourceRequest.h" 35 34 #include <wtf/text/WTFString.h> … … 38 37 #include "ContentFilterUnblockHandler.h" 39 38 #endif 39 40 namespace WTF { 41 template<typename> class CompletionHandler; 42 } 40 43 41 44 namespace WebCore { … … 48 51 class ResourceResponse; 49 52 50 using NewWindowPolicyDecisionFunction = WTF::Function<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>; 53 using NewWindowPolicyDecisionFunction = WTF::CompletionHandler<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>; 54 using NavigationPolicyDecisionFunction = WTF::CompletionHandler<void(const ResourceRequest&, FormState*, bool shouldContinue)>; 51 55 52 56 class PolicyChecker { … … 56 60 explicit PolicyChecker(Frame&); 57 61 58 void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, DocumentLoader*, FormState*, NavigationPolicyDecisionFunction );59 void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction );60 void checkNewWindowPolicy(NavigationAction&&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction );62 void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, DocumentLoader*, FormState*, NavigationPolicyDecisionFunction&&); 63 void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction&&); 64 void checkNewWindowPolicy(NavigationAction&&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction&&); 61 65 62 66 void stopCheck(); … … 66 70 FrameLoadType loadType() const { return m_loadType; } 67 71 void setLoadType(FrameLoadType loadType) { m_loadType = loadType; } 68 69 void setSuggestedFilename(const String& suggestedFilename) { m_suggestedFilename = suggestedFilename; }70 72 71 73 bool delegateIsDecidingNavigationPolicy() const { return m_delegateIsDecidingNavigationPolicy; } … … 77 79 78 80 private: 79 void continueAfterNavigationPolicy(PolicyAction);80 81 81 void handleUnimplementablePolicy(const ResourceError&); 82 82 … … 90 90 // on navigation action delegate callbacks. 91 91 FrameLoadType m_loadType; 92 PolicyCallback m_callback;93 String m_suggestedFilename;94 92 95 93 #if ENABLE(CONTENT_FILTERING) -
trunk/Source/WebKit/ChangeLog
r222468 r222472 1 2017-09-25 Alex Christensen <achristensen@webkit.org> 2 3 Stop using PolicyCallback 4 https://bugs.webkit.org/show_bug.cgi?id=176088 5 6 Reviewed by Andy Estes. 7 8 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: 9 * WebProcess/WebPage/WebFrame.cpp: 10 (WebKit::WebFrame::invalidatePolicyListener): 11 * WebProcess/WebPage/WebFrame.h: 12 * WebProcess/WebPage/WebInspector.cpp: 13 1 14 2017-09-25 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r222468 r222472 78 78 #include <WebCore/PluginData.h> 79 79 #include <WebCore/PluginDocument.h> 80 #include <WebCore/PolicyChecker.h> 80 81 #include <WebCore/ProgressTracker.h> 81 82 #include <WebCore/ResourceError.h> -
trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp
r222468 r222472 241 241 m_policyDownloadID = { }; 242 242 m_policyListenerID = 0; 243 m_policyFunction = nullptr; 243 if (auto function = std::exchange(m_policyFunction, nullptr)) 244 function(PolicyIgnore); 244 245 } 245 246 … … 255 256 return; 256 257 257 ASSERT(m_policyFunction); 258 if (!m_policyFunction) 259 return; 258 260 259 261 FramePolicyFunction function = WTFMove(m_policyFunction); -
trunk/Source/WebKit/WebProcess/WebPage/WebFrame.h
r222456 r222472 34 34 #include <WebCore/FrameLoaderClient.h> 35 35 #include <WebCore/FrameLoaderTypes.h> 36 #include <WebCore/PolicyChecker.h>37 36 #include <wtf/Forward.h> 37 #include <wtf/HashMap.h> 38 38 #include <wtf/RefPtr.h> 39 39 #include <wtf/RetainPtr.h> -
trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp
r219407 r222472 42 42 #include <WebCore/InspectorPageAgent.h> 43 43 #include <WebCore/MainFrame.h> 44 #include <WebCore/NavigationAction.h> 44 45 #include <WebCore/NotImplemented.h> 45 46 #include <WebCore/Page.h> -
trunk/Source/WebKitLegacy/mac/ChangeLog
r222465 r222472 1 2017-09-25 Alex Christensen <achristensen@webkit.org> 2 3 Stop using PolicyCallback 4 https://bugs.webkit.org/show_bug.cgi?id=176088 5 6 Reviewed by Andy Estes. 7 8 * WebCoreSupport/WebFrameLoaderClient.mm: 9 (-[WebFramePolicyListener invalidate]): 10 (-[WebFramePolicyListener receivedPolicyDecision:]): 11 1 12 2017-09-25 Sam Weinig <sam@webkit.org> 2 13 -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
r222456 r222472 2410 2410 { 2411 2411 _frame = nullptr; 2412 if (auto policyFunction = std::exchange(_policyFunction, nullptr)) 2413 policyFunction(PolicyIgnore); 2412 2414 } 2413 2415 … … 2426 2428 return; 2427 2429 2428 FramePolicyFunction policyFunction = WTFMove(_policyFunction); 2429 _policyFunction = nullptr; 2430 2431 ASSERT(policyFunction); 2432 policyFunction(action); 2430 if (auto policyFunction = std::exchange(_policyFunction, nullptr)) 2431 policyFunction(action); 2433 2432 } 2434 2433
Note: See TracChangeset
for help on using the changeset viewer.