Changeset 221103 in webkit
- Timestamp:
- Aug 23, 2017 2:10:09 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r221100 r221103 1 2017-08-23 Alex Christensen <achristensen@webkit.org> 2 3 Stop using PolicyChecker for ContentPolicy 4 https://bugs.webkit.org/show_bug.cgi?id=175904 5 6 Reviewed by Tim Horton. 7 8 PolicyChecker is an artifact from the days before C++11. Now we have lambdas which 9 have a cleaner flow than one class that exists to be effectively one of three lambda types. 10 Let's remove them one at a time, starting with ContentPolicy checks. 11 12 No change in behaviour. 13 14 * loader/DocumentLoader.cpp: 15 (WebCore::DocumentLoader::responseReceived): 16 * loader/FrameLoader.cpp: 17 (WebCore::FrameLoader::checkContentPolicy): 18 * loader/FrameLoader.h: 19 * loader/PolicyCallback.cpp: 20 (WebCore::PolicyCallback::set): 21 (WebCore::PolicyCallback::call): 22 (WebCore::PolicyCallback::cancel): 23 * loader/PolicyCallback.h: 24 * loader/PolicyChecker.cpp: 25 (WebCore::PolicyChecker::checkContentPolicy): Deleted. 26 (WebCore::PolicyChecker::continueAfterContentPolicy): Deleted. 27 * loader/PolicyChecker.h: 28 1 29 2017-08-23 Jer Noble <jer.noble@apple.com> 2 30 -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r220857 r221103 705 705 #endif 706 706 707 frameLoader()-> policyChecker().checkContentPolicy(m_response, [this](PolicyAction policy) {707 frameLoader()->checkContentPolicy(m_response, [this](PolicyAction policy) { 708 708 continueAfterContentPolicy(policy); 709 709 }); -
trunk/Source/WebCore/loader/FrameLoader.cpp
r220760 r221103 356 356 } 357 357 358 void FrameLoader::checkContentPolicy(const ResourceResponse& response, ContentPolicyDecisionFunction&& function) 359 { 360 client().dispatchDecidePolicyForResponse(response, activeDocumentLoader()->request(), WTFMove(function)); 361 } 362 358 363 void FrameLoader::changeLocation(FrameLoadRequest&& request) 359 364 { -
trunk/Source/WebCore/loader/FrameLoader.h
r220760 r221103 84 84 WEBCORE_EXPORT bool isReload(FrameLoadType); 85 85 86 using ContentPolicyDecisionFunction = WTF::Function<void(PolicyAction)>; 87 86 88 class FrameLoader { 87 89 WTF_MAKE_NONCOPYABLE(FrameLoader); … … 208 210 void setDefersLoading(bool); 209 211 212 void checkContentPolicy(const ResourceResponse&, ContentPolicyDecisionFunction&&); 213 210 214 void didExplicitOpen(); 211 215 -
trunk/Source/WebCore/loader/PolicyCallback.cpp
r215918 r221103 47 47 m_navigationFunction = WTFMove(function); 48 48 m_newWindowFunction = nullptr; 49 m_contentFunction = nullptr;50 49 } 51 50 … … 59 58 m_navigationFunction = nullptr; 60 59 m_newWindowFunction = WTFMove(function); 61 m_contentFunction = nullptr;62 }63 64 void PolicyCallback::set(ContentPolicyDecisionFunction&& function)65 {66 m_request = ResourceRequest();67 m_formState = nullptr;68 m_frameName = String();69 70 m_navigationFunction = nullptr;71 m_newWindowFunction = nullptr;72 m_contentFunction = WTFMove(function);73 60 } 74 61 … … 79 66 if (m_newWindowFunction) 80 67 m_newWindowFunction(m_request, m_formState.get(), m_frameName, m_navigationAction, shouldContinue); 81 ASSERT(!m_contentFunction);82 }83 84 void PolicyCallback::call(PolicyAction action)85 {86 ASSERT(!m_navigationFunction);87 ASSERT(!m_newWindowFunction);88 ASSERT(m_contentFunction);89 m_contentFunction(action);90 68 } 91 69 … … 104 82 if (m_newWindowFunction) 105 83 m_newWindowFunction(m_request, m_formState.get(), m_frameName, m_navigationAction, false); 106 if (m_contentFunction)107 m_contentFunction(PolicyIgnore);108 84 } 109 85 -
trunk/Source/WebCore/loader/PolicyCallback.h
r215918 r221103 42 42 class FormState; 43 43 44 using ContentPolicyDecisionFunction = Function<void(PolicyAction)>;45 44 using NavigationPolicyDecisionFunction = Function<void(const ResourceRequest&, FormState*, bool shouldContinue)>; 46 45 using NewWindowPolicyDecisionFunction = Function<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>; … … 50 49 void set(const ResourceRequest&, FormState*, NavigationPolicyDecisionFunction&&); 51 50 void set(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, NewWindowPolicyDecisionFunction&&); 52 void set(ContentPolicyDecisionFunction&&);53 51 54 52 const ResourceRequest& request() const { return m_request; } … … 56 54 57 55 void call(bool shouldContinue); 58 void call(PolicyAction);59 56 void cancel(); 60 57 … … 67 64 NavigationPolicyDecisionFunction m_navigationFunction; 68 65 NewWindowPolicyDecisionFunction m_newWindowFunction; 69 ContentPolicyDecisionFunction m_contentFunction;70 66 }; 71 67 -
trunk/Source/WebCore/loader/PolicyChecker.cpp
r220459 r221103 168 168 } 169 169 170 void PolicyChecker::checkContentPolicy(const ResourceResponse& response, ContentPolicyDecisionFunction function)171 {172 m_callback.set(WTFMove(function));173 m_frame.loader().client().dispatchDecidePolicyForResponse(response, m_frame.loader().activeDocumentLoader()->request(), [this](PolicyAction action) {174 continueAfterContentPolicy(action);175 });176 }177 178 170 void PolicyChecker::cancelCheck() 179 171 { … … 252 244 } 253 245 254 void PolicyChecker::continueAfterContentPolicy(PolicyAction policy)255 {256 PolicyCallback callback = WTFMove(m_callback);257 callback.call(policy);258 }259 260 246 void PolicyChecker::handleUnimplementablePolicy(const ResourceError& error) 261 247 { -
trunk/Source/WebCore/loader/PolicyChecker.h
r210216 r221103 57 57 void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction); 58 58 void checkNewWindowPolicy(const NavigationAction&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction); 59 void checkContentPolicy(const ResourceResponse&, ContentPolicyDecisionFunction);60 59 61 60 // FIXME: These are different. They could use better names. … … 87 86 void continueAfterNavigationPolicy(PolicyAction); 88 87 void continueAfterNewWindowPolicy(PolicyAction); 89 void continueAfterContentPolicy(PolicyAction);90 88 91 89 void handleUnimplementablePolicy(const ResourceError&);
Note: See TracChangeset
for help on using the changeset viewer.