+2018-09-14 Alex Christensen <achristensen@webkit.org>
+
+ Refactoring related to Safe Browsing
+ https://bugs.webkit.org/show_bug.cgi?id=189631
+
+ Reviewed by Tim Horton.
+
+ Make SafeBrowsingResult RefCounted.
+ Move logic from an unnamed lambda to WebPageProxy::receivedNavigationPolicyDecision.
+
+ * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+ (WebKit::WebPageProxy::beginSafeBrowsingCheck):
+ (WebKit::WebPageProxy::contentFilterDidBlockLoadForFrame): Deleted.
+ (WebKit::WebPageProxy::addPlatformLoadParameters): Deleted.
+ (WebKit::WebPageProxy::createSandboxExtensionsIfNeeded): Deleted.
+ (WebKit::WebPageProxy::startDrag): Deleted.
+ (WebKit::WebPageProxy::setPromisedDataForImage): Deleted.
+ (WebKit::WebPageProxy::setDragCaretRect): Deleted.
+ (WebKit::WebPageProxy::platformRegisterAttachment): Deleted.
+ (WebKit::WebPageProxy::platformCloneAttachment): Deleted.
+ * UIProcess/SafeBrowsingResult.h:
+ (WebKit::SafeBrowsingResult::create):
+ * UIProcess/WebFramePolicyListenerProxy.cpp:
+ (WebKit::WebFramePolicyListenerProxy::didReceiveSafeBrowsingResults):
+ * UIProcess/WebFramePolicyListenerProxy.h:
+ * UIProcess/WebFrameProxy.cpp:
+ (WebKit::WebFrameProxy::setUpPolicyListenerProxy):
+ * UIProcess/WebFrameProxy.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
+ (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+ (WebKit::WebPageProxy::decidePolicyForNewWindowAction):
+ (WebKit::WebPageProxy::decidePolicyForResponse):
+ * UIProcess/WebPageProxy.h:
+
2018-09-14 Geoffrey Garen <ggaren@apple.com>
Clarify the configuration used by WKUIDelegate's createWebViewWithConfiguration
SendFunction m_sendFunction;
};
+
+void WebPageProxy::receivedNavigationPolicyDecision(PolicyAction policyAction, API::Navigation& navigation, ProcessSwapRequestedByClient processSwapRequestedByClient, WebFrameProxy& frame, API::WebsitePolicies* policies, Ref<PolicyDecisionSender>&& sender)
+{
+ std::optional<WebsitePoliciesData> data;
+ if (policies) {
+ data = policies->data();
+ if (policies->websiteDataStore())
+ changeWebsiteDataStore(policies->websiteDataStore()->websiteDataStore());
+ }
+
+ if (policyAction == PolicyAction::Use && frame.isMainFrame()) {
+ String reason;
+ auto proposedProcess = process().processPool().processForNavigation(*this, navigation, processSwapRequestedByClient, policyAction, reason);
+ ASSERT(!reason.isNull());
+
+ if (proposedProcess.ptr() != &process()) {
+ RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "%p - WebPageProxy::decidePolicyForNavigationAction, swapping process %i with process %i for navigation, reason: %{public}s", this, processIdentifier(), proposedProcess->processIdentifier(), reason.utf8().data());
+ LOG(ProcessSwapping, "(ProcessSwapping) Switching from process %i to new process (%i) for navigation %" PRIu64 " '%s'", processIdentifier(), proposedProcess->processIdentifier(), navigation.navigationID(), navigation.loggingString());
+
+ RunLoop::main().dispatch([this, protectedThis = makeRef(*this), navigation = makeRef(navigation), proposedProcess = WTFMove(proposedProcess)]() mutable {
+ continueNavigationInNewProcess(navigation, WTFMove(proposedProcess));
+ });
+ } else
+ RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "%p - WebPageProxy::decidePolicyForNavigationAction, keep using process %i for navigation, reason: %{public}s", this, processIdentifier(), reason.utf8().data());
+ }
+ receivedPolicyDecision(policyAction, &navigation, WTFMove(data), WTFMove(sender));
+
+}
+
void WebPageProxy::receivedPolicyDecision(PolicyAction action, API::Navigation* navigation, std::optional<WebsitePoliciesData>&& websitePolicies, Ref<PolicyDecisionSender>&& sender)
{
if (!isValid()) {
UNUSED_PARAM(newNavigationID);
#endif
- auto listener = makeRef(frame->setUpPolicyListenerProxy([this, protectedThis = makeRef(*this), frame = makeRef(*frame), sender = sender.copyRef(), navigation] (WebCore::PolicyAction policyAction, API::WebsitePolicies* policies, ProcessSwapRequestedByClient processSwapRequestedByClient, Vector<SafeBrowsingResult>&&) mutable {
+ auto listener = makeRef(frame->setUpPolicyListenerProxy([this, protectedThis = makeRef(*this), frame = makeRef(*frame), sender = WTFMove(sender), navigation = navigation.releaseNonNull()] (WebCore::PolicyAction policyAction, API::WebsitePolicies* policies, ProcessSwapRequestedByClient processSwapRequestedByClient, Vector<Ref<SafeBrowsingResult>>&&) mutable {
// FIXME: do something with the SafeBrowsingResults.
-
- std::optional<WebsitePoliciesData> data;
- if (policies) {
- data = policies->data();
- if (policies->websiteDataStore())
- changeWebsiteDataStore(policies->websiteDataStore()->websiteDataStore());
- }
-
- if (policyAction == PolicyAction::Use && frame->isMainFrame()) {
- String reason;
- auto proposedProcess = process().processPool().processForNavigation(*this, *navigation, processSwapRequestedByClient, policyAction, reason);
- ASSERT(!reason.isNull());
-
- if (proposedProcess.ptr() != &process()) {
- RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "%p - WebPageProxy::decidePolicyForNavigationAction, swapping process %i with process %i for navigation, reason: %{public}s", this, processIdentifier(), proposedProcess->processIdentifier(), reason.utf8().data());
- LOG(ProcessSwapping, "(ProcessSwapping) Switching from process %i to new process (%i) for navigation %" PRIu64 " '%s'", processIdentifier(), proposedProcess->processIdentifier(), navigation->navigationID(), navigation->loggingString());
-
- RunLoop::main().dispatch([this, protectedThis = WTFMove(protectedThis), navigation = makeRef(*navigation), proposedProcess = WTFMove(proposedProcess)]() mutable {
- continueNavigationInNewProcess(navigation.get(), WTFMove(proposedProcess));
- });
- } else
- RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "%p - WebPageProxy::decidePolicyForNavigationAction, keep using process %i for navigation, reason: %{public}s", this, processIdentifier(), reason.utf8().data());
- }
-
- receivedPolicyDecision(policyAction, navigation.get(), WTFMove(data), WTFMove(sender));
+ receivedNavigationPolicyDecision(policyAction, navigation, processSwapRequestedByClient, frame, policies, WTFMove(sender));
}, shouldSkipSafeBrowsingCheck == ShouldSkipSafeBrowsingCheck::Yes ? ShouldExpectSafeBrowsingResult::No : ShouldExpectSafeBrowsingResult::Yes));
if (shouldSkipSafeBrowsingCheck == ShouldSkipSafeBrowsingCheck::No)
beginSafeBrowsingCheck(request.url(), listener);
MESSAGE_CHECK(frame);
MESSAGE_CHECK_URL(request.url());
- auto listener = makeRef(frame->setUpPolicyListenerProxy([this, protectedThis = makeRef(*this), listenerID, frameID] (WebCore::PolicyAction policyAction, API::WebsitePolicies*, ProcessSwapRequestedByClient processSwapRequestedByClient, Vector<SafeBrowsingResult>&& safeBrowsingResults) mutable {
+ auto listener = makeRef(frame->setUpPolicyListenerProxy([this, protectedThis = makeRef(*this), listenerID, frameID] (WebCore::PolicyAction policyAction, API::WebsitePolicies*, ProcessSwapRequestedByClient processSwapRequestedByClient, Vector<Ref<SafeBrowsingResult>>&& safeBrowsingResults) mutable {
// FIXME: Assert the API::WebsitePolicies* is nullptr here once clients of WKFramePolicyListenerUseWithPolicies go away.
RELEASE_ASSERT(processSwapRequestedByClient == ProcessSwapRequestedByClient::No);
ASSERT_UNUSED(safeBrowsingResults, safeBrowsingResults.isEmpty());
MESSAGE_CHECK_URL(response.url());
RefPtr<API::Navigation> navigation = navigationID ? &m_navigationState->navigation(navigationID) : nullptr;
- auto listener = makeRef(frame->setUpPolicyListenerProxy([this, protectedThis = makeRef(*this), frameID, listenerID, navigation = WTFMove(navigation)] (WebCore::PolicyAction policyAction, API::WebsitePolicies*, ProcessSwapRequestedByClient processSwapRequestedByClient, Vector<SafeBrowsingResult>&& safeBrowsingResults) mutable {
+ auto listener = makeRef(frame->setUpPolicyListenerProxy([this, protectedThis = makeRef(*this), frameID, listenerID, navigation = WTFMove(navigation)] (WebCore::PolicyAction policyAction, API::WebsitePolicies*, ProcessSwapRequestedByClient processSwapRequestedByClient, Vector<Ref<SafeBrowsingResult>>&& safeBrowsingResults) mutable {
// FIXME: Assert the API::WebsitePolicies* is nullptr here once clients of WKFramePolicyListenerUseWithPolicies go away.
RELEASE_ASSERT(processSwapRequestedByClient == ProcessSwapRequestedByClient::No);
ASSERT_UNUSED(safeBrowsingResults, safeBrowsingResults.isEmpty());