This source file includes following definitions.
- m_hostIsPublicSuffix
- matchesOrigin
#include "config.h"
#include "platform/weborigin/OriginAccessEntry.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "public/platform/Platform.h"
#include "public/platform/WebPublicSuffixList.h"
namespace WebCore {
OriginAccessEntry::OriginAccessEntry(const String& protocol, const String& host, SubdomainSetting subdomainSetting, IPAddressSetting ipAddressSetting)
: m_protocol(protocol.lower())
, m_host(host.lower())
, m_subdomainSettings(subdomainSetting)
, m_ipAddressSettings(ipAddressSetting)
, m_hostIsPublicSuffix(false)
{
ASSERT(subdomainSetting == AllowSubdomains || subdomainSetting == DisallowSubdomains);
m_hostIsIPAddress = !m_host.isEmpty() && isASCIIDigit(m_host[m_host.length() - 1]);
if (!m_hostIsIPAddress) {
blink::WebPublicSuffixList* suffixList = blink::Platform::current()->publicSuffixList();
if (suffixList && m_host.length() <= suffixList->getPublicSuffixLength(m_host) + 1)
m_hostIsPublicSuffix = true;
}
}
OriginAccessEntry::MatchResult OriginAccessEntry::matchesOrigin(const SecurityOrigin& origin) const
{
ASSERT(origin.host() == origin.host().lower());
ASSERT(origin.protocol() == origin.protocol().lower());
if (m_protocol != origin.protocol())
return DoesNotMatchOrigin;
if (m_subdomainSettings == AllowSubdomains && m_host.isEmpty())
return MatchesOrigin;
if (m_host == origin.host())
return MatchesOrigin;
if (m_subdomainSettings == DisallowSubdomains)
return DoesNotMatchOrigin;
if (m_hostIsIPAddress && m_ipAddressSettings == TreatIPAddressAsIPAddress)
return DoesNotMatchOrigin;
if (origin.host().length() <= m_host.length() || origin.host()[origin.host().length() - m_host.length() - 1] != '.' || !origin.host().endsWith(m_host))
return DoesNotMatchOrigin;
if (m_hostIsPublicSuffix)
return MatchesOriginButIsPublicSuffix;
return MatchesOrigin;
}
}