#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include <cstdint>
#include <ostream>
#include <string_view>
#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/notreached.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "net/base/lookup_string_in_fixed_set.h"
#include "net/base/net_module.h"
#include "net/base/url_util.h"
#include "url/gurl.h"
#include "url/origin.h"
#include "url/third_party/mozilla/url_parse.h"
#include "url/url_util.h"
namespace net::registry_controlled_domains {
namespace {
#include "net/base/registry_controlled_domains/effective_tld_names-reversed-inc.cc"
base::span<const uint8_t> g_graph = …;
struct MappedHostComponent { … };
struct RegistryLengthOutput { … };
RegistryLengthOutput GetRegistryLengthInTrimmedHost(
std::string_view host,
UnknownRegistryFilter unknown_filter,
PrivateRegistryFilter private_filter) { … }
RegistryLengthOutput GetRegistryLengthImpl(
std::string_view host,
UnknownRegistryFilter unknown_filter,
PrivateRegistryFilter private_filter) { … }
std::string_view GetDomainAndRegistryImpl(
std::string_view host,
PrivateRegistryFilter private_filter) { … }
std::string_view GetDomainAndRegistryAsStringPiece(
std::string_view host,
PrivateRegistryFilter filter) { … }
void AppendInvalidString(std::string_view str, url::CanonOutput* output) { … }
void AppendInvalidString(std::u16string_view str, url::CanonOutput* output) { … }
template <typename T, typename CharT = typename T::value_type>
size_t DoPermissiveGetHostRegistryLength(T host,
UnknownRegistryFilter unknown_filter,
PrivateRegistryFilter private_filter) { … }
bool SameDomainOrHost(std::string_view host1,
std::string_view host2,
PrivateRegistryFilter filter) { … }
}
std::string GetDomainAndRegistry(const GURL& gurl,
PrivateRegistryFilter filter) { … }
std::string GetDomainAndRegistry(const url::Origin& origin,
PrivateRegistryFilter filter) { … }
std::string GetDomainAndRegistry(std::string_view host,
PrivateRegistryFilter filter) { … }
bool SameDomainOrHost(
const GURL& gurl1,
const GURL& gurl2,
PrivateRegistryFilter filter) { … }
bool SameDomainOrHost(const url::Origin& origin1,
const url::Origin& origin2,
PrivateRegistryFilter filter) { … }
bool SameDomainOrHost(const url::Origin& origin1,
const std::optional<url::Origin>& origin2,
PrivateRegistryFilter filter) { … }
bool SameDomainOrHost(const GURL& gurl,
const url::Origin& origin,
PrivateRegistryFilter filter) { … }
size_t GetRegistryLength(
const GURL& gurl,
UnknownRegistryFilter unknown_filter,
PrivateRegistryFilter private_filter) { … }
bool HostHasRegistryControlledDomain(std::string_view host,
UnknownRegistryFilter unknown_filter,
PrivateRegistryFilter private_filter) { … }
bool HostIsRegistryIdentifier(std::string_view canon_host,
PrivateRegistryFilter private_filter) { … }
size_t GetCanonicalHostRegistryLength(std::string_view canon_host,
UnknownRegistryFilter unknown_filter,
PrivateRegistryFilter private_filter) { … }
size_t PermissiveGetHostRegistryLength(std::string_view host,
UnknownRegistryFilter unknown_filter,
PrivateRegistryFilter private_filter) { … }
size_t PermissiveGetHostRegistryLength(std::u16string_view host,
UnknownRegistryFilter unknown_filter,
PrivateRegistryFilter private_filter) { … }
void ResetFindDomainGraphForTesting() { … }
void SetFindDomainGraphForTesting(base::span<const uint8_t> domains) { … }
}