WebFramePolicyListenerProxy.cpp [plain text]
#include "config.h"
#include "WebFramePolicyListenerProxy.h"
#include "APINavigation.h"
#include "APIWebsitePolicies.h"
#include "SafeBrowsingWarning.h"
#include "WebFrameProxy.h"
#include "WebsiteDataStore.h"
#include "WebsitePoliciesData.h"
namespace WebKit {
WebFramePolicyListenerProxy::WebFramePolicyListenerProxy(Reply&& reply, ShouldExpectSafeBrowsingResult expectSafeBrowsingResult, ShouldExpectAppBoundDomainResult expectAppBoundDomainResult)
: m_reply(WTFMove(reply))
{
if (expectSafeBrowsingResult == ShouldExpectSafeBrowsingResult::No)
didReceiveSafeBrowsingResults({ });
if (expectAppBoundDomainResult == ShouldExpectAppBoundDomainResult::No)
didReceiveAppBoundDomainResult({ });
}
WebFramePolicyListenerProxy::~WebFramePolicyListenerProxy() = default;
void WebFramePolicyListenerProxy::didReceiveAppBoundDomainResult(Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain)
{
ASSERT(RunLoop::isMain());
if (m_policyResult && m_safeBrowsingWarning) {
if (m_reply)
m_reply(WebCore::PolicyAction::Use, m_policyResult->first.get(), m_policyResult->second, WTFMove(*m_safeBrowsingWarning), isNavigatingToAppBoundDomain);
} else
m_isNavigatingToAppBoundDomain = isNavigatingToAppBoundDomain;
}
void WebFramePolicyListenerProxy::didReceiveSafeBrowsingResults(RefPtr<SafeBrowsingWarning>&& safeBrowsingWarning)
{
ASSERT(isMainThread());
ASSERT(!m_safeBrowsingWarning);
if (m_policyResult && m_isNavigatingToAppBoundDomain) {
if (m_reply)
m_reply(WebCore::PolicyAction::Use, m_policyResult->first.get(), m_policyResult->second, WTFMove(safeBrowsingWarning), *m_isNavigatingToAppBoundDomain);
} else
m_safeBrowsingWarning = WTFMove(safeBrowsingWarning);
}
void WebFramePolicyListenerProxy::use(API::WebsitePolicies* policies, ProcessSwapRequestedByClient processSwapRequestedByClient)
{
if (m_safeBrowsingWarning && m_isNavigatingToAppBoundDomain) {
if (m_reply)
m_reply(WebCore::PolicyAction::Use, policies, processSwapRequestedByClient, WTFMove(*m_safeBrowsingWarning), *m_isNavigatingToAppBoundDomain);
} else if (!m_policyResult)
m_policyResult = {{ policies, processSwapRequestedByClient }};
}
void WebFramePolicyListenerProxy::download()
{
if (m_reply)
m_reply(WebCore::PolicyAction::Download, nullptr, ProcessSwapRequestedByClient::No, { }, { });
}
void WebFramePolicyListenerProxy::ignore()
{
if (m_reply)
m_reply(WebCore::PolicyAction::Ignore, nullptr, ProcessSwapRequestedByClient::No, { }, { });
}
}