ContentSecurityPolicyResponseHeaders.cpp [plain text]
#include "config.h"
#include "ContentSecurityPolicyResponseHeaders.h"
#include "HTTPHeaderNames.h"
#include "ResourceResponse.h"
namespace WebCore {
ContentSecurityPolicyResponseHeaders::ContentSecurityPolicyResponseHeaders(const ResourceResponse& response)
{
String policyValue = response.httpHeaderField(HTTPHeaderName::ContentSecurityPolicy);
if (!policyValue.isEmpty())
m_headers.append({ policyValue, ContentSecurityPolicyHeaderType::Enforce });
policyValue = response.httpHeaderField(HTTPHeaderName::ContentSecurityPolicyReportOnly);
if (!policyValue.isEmpty())
m_headers.append({ policyValue, ContentSecurityPolicyHeaderType::Report });
policyValue = response.httpHeaderField(HTTPHeaderName::XWebKitCSP);
if (!policyValue.isEmpty())
m_headers.append({ policyValue, ContentSecurityPolicyHeaderType::PrefixedEnforce });
policyValue = response.httpHeaderField(HTTPHeaderName::XWebKitCSPReportOnly);
if (!policyValue.isEmpty())
m_headers.append({ policyValue, ContentSecurityPolicyHeaderType::PrefixedReport });
}
ContentSecurityPolicyResponseHeaders ContentSecurityPolicyResponseHeaders::isolatedCopy() const
{
ContentSecurityPolicyResponseHeaders isolatedCopy;
isolatedCopy.m_headers.reserveInitialCapacity(m_headers.size());
for (auto& header : m_headers)
isolatedCopy.m_headers.uncheckedAppend({ header.first.isolatedCopy(), header.second });
return isolatedCopy;
}
}