Diff
Modified: trunk/Source/WebKit/ChangeLog (234208 => 234209)
--- trunk/Source/WebKit/ChangeLog 2018-07-25 18:04:22 UTC (rev 234208)
+++ trunk/Source/WebKit/ChangeLog 2018-07-25 18:04:51 UTC (rev 234209)
@@ -1,3 +1,16 @@
+2018-07-25 Commit Queue <[email protected]>
+
+ Unreviewed, rolling out r234196.
+ https://bugs.webkit.org/show_bug.cgi?id=188011
+
+ broke API tests (Requested by alexchristensen on #webkit).
+
+ Reverted changeset:
+
+ "Use CompletionHandler for policy decisions"
+ https://bugs.webkit.org/show_bug.cgi?id=187975
+ https://trac.webkit.org/changeset/234196
+
2018-07-25 Alex Christensen <[email protected]>
Use CompletionHandler for policy decisions
Modified: trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp (234208 => 234209)
--- trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp 2018-07-25 18:04:22 UTC (rev 234208)
+++ trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp 2018-07-25 18:04:51 UTC (rev 234209)
@@ -35,24 +35,47 @@
namespace WebKit {
-WebFramePolicyListenerProxy::WebFramePolicyListenerProxy(CompletionHandler<void(WebCore::PolicyAction, API::WebsitePolicies*, ShouldProcessSwapIfPossible)>&& completionHandler)
- : m_completionHandler(WTFMove(completionHandler))
+WebFramePolicyListenerProxy::WebFramePolicyListenerProxy(WebFrameProxy* frame, uint64_t listenerID, PolicyListenerType policyType)
+ : m_policyType(policyType)
+ , m_frame(frame)
+ , m_listenerID(listenerID)
{
}
+void WebFramePolicyListenerProxy::receivedPolicyDecision(WebCore::PolicyAction action, std::optional<WebsitePoliciesData>&& data, ShouldProcessSwapIfPossible swap)
+{
+ if (!m_frame)
+ return;
+
+ m_frame->receivedPolicyDecision(action, m_listenerID, m_navigation.get(), WTFMove(data), swap);
+ m_frame = nullptr;
+}
+
+void WebFramePolicyListenerProxy::setNavigation(Ref<API::Navigation>&& navigation)
+{
+ m_navigation = WTFMove(navigation);
+}
+
void WebFramePolicyListenerProxy::use(API::WebsitePolicies* policies, ShouldProcessSwapIfPossible swap)
{
- m_completionHandler(WebCore::PolicyAction::Use, policies, swap);
+ std::optional<WebsitePoliciesData> data;
+ if (policies) {
+ data = ""
+ if (m_frame && policies->websiteDataStore())
+ m_frame->changeWebsiteDataStore(policies->websiteDataStore()->websiteDataStore());
+ }
+
+ receivedPolicyDecision(WebCore::PolicyAction::Use, WTFMove(data), swap);
}
void WebFramePolicyListenerProxy::download()
{
- m_completionHandler(WebCore::PolicyAction::Download, nullptr, ShouldProcessSwapIfPossible::No);
+ receivedPolicyDecision(WebCore::PolicyAction::Download, std::nullopt, ShouldProcessSwapIfPossible::No);
}
void WebFramePolicyListenerProxy::ignore()
{
- m_completionHandler(WebCore::PolicyAction::Ignore, nullptr, ShouldProcessSwapIfPossible::No);
+ receivedPolicyDecision(WebCore::PolicyAction::Ignore, std::nullopt, ShouldProcessSwapIfPossible::No);
}
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.h (234208 => 234209)
--- trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.h 2018-07-25 18:04:22 UTC (rev 234208)
+++ trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.h 2018-07-25 18:04:51 UTC (rev 234209)
@@ -26,9 +26,13 @@
#pragma once
#include "APIObject.h"
-#include <wtf/CompletionHandler.h>
+#if PLATFORM(COCOA)
+#include "WKFoundation.h"
+#endif
+
namespace API {
+class Navigation;
class WebsitePolicies;
}
@@ -38,14 +42,24 @@
namespace WebKit {
+class WebFrameProxy;
+class WebsiteDataStore;
+struct WebsitePoliciesData;
+
+enum class PolicyListenerType {
+ NavigationAction,
+ NewWindowAction,
+ Response,
+};
+
enum class ShouldProcessSwapIfPossible { No, Yes };
class WebFramePolicyListenerProxy : public API::ObjectImpl<API::Object::Type::FramePolicyListener> {
public:
- static Ref<WebFramePolicyListenerProxy> create(CompletionHandler<void(WebCore::PolicyAction, API::WebsitePolicies*, ShouldProcessSwapIfPossible)>&& completionHandler)
+ static Ref<WebFramePolicyListenerProxy> create(WebFrameProxy* frame, uint64_t listenerID, PolicyListenerType policyType)
{
- return adoptRef(*new WebFramePolicyListenerProxy(WTFMove(completionHandler)));
+ return adoptRef(*new WebFramePolicyListenerProxy(frame, listenerID, policyType));
}
void use(API::WebsitePolicies* = nullptr, ShouldProcessSwapIfPossible = ShouldProcessSwapIfPossible::No);
@@ -52,10 +66,21 @@
void download();
void ignore();
+ PolicyListenerType policyListenerType() const { return m_policyType; }
+
+ uint64_t listenerID() const { return m_listenerID; }
+
+ void setNavigation(Ref<API::Navigation>&&);
+
private:
- WebFramePolicyListenerProxy(CompletionHandler<void(WebCore::PolicyAction, API::WebsitePolicies*, ShouldProcessSwapIfPossible)>&&);
+ WebFramePolicyListenerProxy(WebFrameProxy*, uint64_t listenerID, PolicyListenerType);
- CompletionHandler<void(WebCore::PolicyAction, API::WebsitePolicies*, ShouldProcessSwapIfPossible)> m_completionHandler;
+ void receivedPolicyDecision(WebCore::PolicyAction, std::optional<WebsitePoliciesData>&&, ShouldProcessSwapIfPossible);
+
+ PolicyListenerType m_policyType;
+ RefPtr<WebFrameProxy> m_frame;
+ uint64_t m_listenerID { 0 };
+ RefPtr<API::Navigation> m_navigation;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp (234208 => 234209)
--- trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp 2018-07-25 18:04:22 UTC (rev 234208)
+++ trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp 2018-07-25 18:04:51 UTC (rev 234209)
@@ -178,17 +178,37 @@
m_title = title;
}
-WebFramePolicyListenerProxy& WebFrameProxy::setUpPolicyListenerProxy(CompletionHandler<void(WebCore::PolicyAction, API::WebsitePolicies*, ShouldProcessSwapIfPossible)>&& completionHandler)
+void WebFrameProxy::receivedPolicyDecision(PolicyAction action, uint64_t listenerID, API::Navigation* navigation, std::optional<WebsitePoliciesData>&& data, ShouldProcessSwapIfPossible swap)
{
+ if (!m_page)
+ return;
+
+ ASSERT(m_activeListener);
+ ASSERT(m_activeListener->listenerID() == listenerID);
+ m_page->receivedPolicyDecision(action, *this, listenerID, navigation, WTFMove(data), swap);
+}
+
+WebFramePolicyListenerProxy& WebFrameProxy::setUpPolicyListenerProxy(uint64_t listenerID, PolicyListenerType policyListenerType)
+{
if (m_activeListener)
m_activeListener->ignore();
- m_activeListener = WebFramePolicyListenerProxy::create([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)] (WebCore::PolicyAction action, API::WebsitePolicies* policies, ShouldProcessSwapIfPossible swap) {
- completionHandler(action, policies, swap);
- m_activeListener = nullptr;
- });
- return *m_activeListener;
+ m_activeListener = WebFramePolicyListenerProxy::create(this, listenerID, policyListenerType);
+ return *static_cast<WebFramePolicyListenerProxy*>(m_activeListener.get());
}
+WebFramePolicyListenerProxy* WebFrameProxy::activePolicyListenerProxy()
+{
+ return m_activeListener.get();
+}
+
+void WebFrameProxy::changeWebsiteDataStore(WebsiteDataStore& websiteDataStore)
+{
+ if (!m_page)
+ return;
+
+ m_page->changeWebsiteDataStore(websiteDataStore);
+}
+
void WebFrameProxy::getWebArchive(Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
{
if (!m_page) {
Modified: trunk/Source/WebKit/UIProcess/WebFrameProxy.h (234208 => 234209)
--- trunk/Source/WebKit/UIProcess/WebFrameProxy.h 2018-07-25 18:04:22 UTC (rev 234208)
+++ trunk/Source/WebKit/UIProcess/WebFrameProxy.h 2018-07-25 18:04:51 UTC (rev 234209)
@@ -53,6 +53,7 @@
class WebPageProxy;
class WebsiteDataStore;
enum class ShouldProcessSwapIfPossible;
+enum class PolicyListenerType;
struct WebsitePoliciesData;
typedef GenericCallback<API::Data*> DataCallback;
@@ -115,8 +116,14 @@
void didSameDocumentNavigation(const WebCore::URL&); // eg. anchor navigation, session state change.
void didChangeTitle(const String&);
- WebFramePolicyListenerProxy& setUpPolicyListenerProxy(CompletionHandler<void(WebCore::PolicyAction, API::WebsitePolicies*, ShouldProcessSwapIfPossible)>&&);
+ // Policy operations.
+ void receivedPolicyDecision(WebCore::PolicyAction, uint64_t listenerID, API::Navigation*, std::optional<WebsitePoliciesData>&&, ShouldProcessSwapIfPossible);
+ WebFramePolicyListenerProxy& setUpPolicyListenerProxy(uint64_t listenerID, PolicyListenerType);
+ WebFramePolicyListenerProxy* activePolicyListenerProxy();
+
+ void changeWebsiteDataStore(WebsiteDataStore&);
+
#if ENABLE(CONTENT_FILTERING)
void contentFilterDidBlockLoad(WebCore::ContentFilterUnblockHandler contentFilterUnblockHandler) { m_contentFilterUnblockHandler = WTFMove(contentFilterUnblockHandler); }
bool didHandleContentFilterUnblockNavigation(const WebCore::ResourceRequest&);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (234208 => 234209)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-07-25 18:04:22 UTC (rev 234208)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-07-25 18:04:51 UTC (rev 234209)
@@ -51,7 +51,6 @@
#include "APISecurityOrigin.h"
#include "APIUIClient.h"
#include "APIURLRequest.h"
-#include "APIWebsitePolicies.h"
#include "AuthenticationChallengeProxy.h"
#include "AuthenticationDecisionListener.h"
#include "DataReference.h"
@@ -2407,7 +2406,7 @@
m_process->send(Messages::WebPage::CenterSelectionInVisibleArea(), m_pageID);
}
-void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy& frame, uint64_t listenerID, API::Navigation* navigation, std::optional<WebsitePoliciesData>&& websitePolicies)
+void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy& frame, uint64_t listenerID, API::Navigation* navigation, std::optional<WebsitePoliciesData>&& websitePolicies, ShouldProcessSwapIfPossible shouldProcessSwapIfPossible)
{
if (!isValid())
return;
@@ -2434,6 +2433,23 @@
m_decidePolicyForResponseRequest = { };
}
+ auto* activePolicyListener = frame.activePolicyListenerProxy();
+ if (activePolicyListener && activePolicyListener->policyListenerType() == PolicyListenerType::NavigationAction) {
+ ASSERT(activePolicyListener->listenerID() == listenerID);
+
+ if (action == PolicyAction::Use && navigation && frame.isMainFrame()) {
+ auto proposedProcess = process().processPool().processForNavigation(*this, *navigation, shouldProcessSwapIfPossible, action);
+
+ if (proposedProcess.ptr() != &process()) {
+ 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.get(), WTFMove(proposedProcess));
+ });
+ }
+ }
+ }
+
if (auto syncNavigationActionPolicyReply = WTFMove(m_syncNavigationActionPolicyReply)) {
syncNavigationActionPolicyReply(navigation ? navigation->navigationID() : 0, action, downloadID, WTFMove(websitePolicies));
return;
@@ -4005,34 +4021,14 @@
navigation->setHasOpenedFrames(navigationActionData.hasOpenedFrames);
navigation->setOpener(navigationActionData.opener);
- auto listener = makeRef(frame->setUpPolicyListenerProxy([this, protectedThis = makeRef(*this), frame = makeRef(*frame), listenerID, navigation] (WebCore::PolicyAction policyAction, API::WebsitePolicies* policies, ShouldProcessSwapIfPossible swap) {
- std::optional<WebsitePoliciesData> data;
- if (policies) {
- data = ""
- if (policies->websiteDataStore())
- changeWebsiteDataStore(policies->websiteDataStore()->websiteDataStore());
- }
+ auto listener = makeRef(frame->setUpPolicyListenerProxy(listenerID, PolicyListenerType::NavigationAction));
- if (policyAction == PolicyAction::Use && frame->isMainFrame()) {
- auto proposedProcess = process().processPool().processForNavigation(*this, *navigation, swap, policyAction);
-
- if (proposedProcess.ptr() != &process()) {
- 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.get(), WTFMove(proposedProcess));
- });
- }
- }
-
- receivedPolicyDecision(policyAction, frame.get(), listenerID, navigation.get(), WTFMove(data));
- }));
-
API::Navigation* mainFrameNavigation = frame->isMainFrame() ? navigation.get() : nullptr;
+ listener->setNavigation(navigation.releaseNonNull());
#if ENABLE(CONTENT_FILTERING)
if (frame->didHandleContentFilterUnblockNavigation(request))
- return receivedPolicyDecision(PolicyAction::Ignore, *frame, listenerID, &m_navigationState->navigation(newNavigationID), std::nullopt);
+ return receivedPolicyDecision(PolicyAction::Ignore, *frame, listenerID, &m_navigationState->navigation(newNavigationID), std::nullopt, ShouldProcessSwapIfPossible::No);
#else
UNUSED_PARAM(newNavigationID);
#endif
@@ -4082,11 +4078,7 @@
MESSAGE_CHECK(frame);
MESSAGE_CHECK_URL(request.url());
- auto listener = makeRef(frame->setUpPolicyListenerProxy([this, protectedThis = makeRef(*this), listenerID, frame = makeRef(*frame)] (WebCore::PolicyAction policyAction, API::WebsitePolicies* policies, ShouldProcessSwapIfPossible swap) {
- ASSERT_UNUSED(policies, !policies);
- ASSERT_UNUSED(swap, swap == ShouldProcessSwapIfPossible::No);
- receivedPolicyDecision(policyAction, frame.get(), listenerID, nullptr, std::nullopt);
- }));
+ Ref<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID, PolicyListenerType::NewWindowAction);
if (m_navigationClient) {
RefPtr<API::FrameInfo> sourceFrameInfo;
@@ -4114,12 +4106,11 @@
MESSAGE_CHECK_URL(request.url());
MESSAGE_CHECK_URL(response.url());
- RefPtr<API::Navigation> navigation = navigationID ? &m_navigationState->navigation(navigationID) : nullptr;
- auto listener = makeRef(frame->setUpPolicyListenerProxy([this, protectedThis = makeRef(*this), frame = makeRef(*frame), listenerID, navigation = WTFMove(navigation)] (WebCore::PolicyAction policyAction, API::WebsitePolicies* policies, ShouldProcessSwapIfPossible swap) {
- ASSERT_UNUSED(policies, !policies);
- ASSERT_UNUSED(swap, swap == ShouldProcessSwapIfPossible::No);
- receivedPolicyDecision(policyAction, frame.get(), listenerID, nullptr, std::nullopt);
- }));
+ Ref<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID, PolicyListenerType::Response);
+ if (navigationID) {
+ auto& navigation = m_navigationState->navigation(navigationID);
+ listener->setNavigation(navigation);
+ }
if (m_navigationClient) {
auto navigationResponse = API::NavigationResponse::create(API::FrameInfo::create(*frame, frameSecurityOrigin.securityOrigin()).get(), request, response, canShowMIMEType);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (234208 => 234209)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-07-25 18:04:22 UTC (rev 234208)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-07-25 18:04:51 UTC (rev 234209)
@@ -908,7 +908,7 @@
void performDictionaryLookupOfCurrentSelection();
#endif
- void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy&, uint64_t listenerID, API::Navigation*, std::optional<WebsitePoliciesData>&&);
+ void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy&, uint64_t listenerID, API::Navigation*, std::optional<WebsitePoliciesData>&&, ShouldProcessSwapIfPossible);
void backForwardRemovedItem(const WebCore::BackForwardItemIdentifier&);