WebFramePolicyListenerProxy.cpp [plain text]
#include "config.h"
#include "WebFramePolicyListenerProxy.h"
#include "APINavigation.h"
#include "APIWebsiteDataStore.h"
#include "APIWebsitePolicies.h"
#include "SafeBrowsingWarning.h"
#include "WebFrameProxy.h"
#include "WebsiteDataStore.h"
#include "WebsitePoliciesData.h"
namespace WebKit {
WebFramePolicyListenerProxy::WebFramePolicyListenerProxy(Reply&& reply, ShouldExpectSafeBrowsingResult expect)
: m_reply(WTFMove(reply))
{
if (expect == ShouldExpectSafeBrowsingResult::No)
didReceiveSafeBrowsingResults({ });
}
WebFramePolicyListenerProxy::~WebFramePolicyListenerProxy() = default;
void WebFramePolicyListenerProxy::didReceiveSafeBrowsingResults(RefPtr<SafeBrowsingWarning>&& safeBrowsingWarning)
{
ASSERT(!m_safeBrowsingWarning);
if (m_policyResult) {
if (m_reply)
m_reply(WebCore::PolicyAction::Use, m_policyResult->first.get(), m_policyResult->second, WTFMove(safeBrowsingWarning));
} else
m_safeBrowsingWarning = WTFMove(safeBrowsingWarning);
}
void WebFramePolicyListenerProxy::use(API::WebsitePolicies* policies, ProcessSwapRequestedByClient processSwapRequestedByClient)
{
if (m_safeBrowsingWarning) {
if (m_reply)
m_reply(WebCore::PolicyAction::Use, policies, processSwapRequestedByClient, WTFMove(*m_safeBrowsingWarning));
} 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, { });
}
}