michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIURI; michael@0: michael@0: [scriptable, uuid(68067eb5-ad8d-43cb-a043-1cc85ebe06e7)] michael@0: interface nsIEffectiveTLDService : nsISupports michael@0: { michael@0: /** michael@0: * Returns the public suffix of a URI. A public suffix is the highest-level domain michael@0: * under which individual domains may be registered; it may therefore contain one michael@0: * or more dots. For example, the public suffix for "www.bbc.co.uk" is "co.uk", michael@0: * because the .uk TLD does not allow the registration of domains at the michael@0: * second level ("bbc.uk" is forbidden). michael@0: * michael@0: * The public suffix will be returned encoded in ASCII/ACE and will be normalized michael@0: * according to RFC 3454, i.e. the same encoding returned by nsIURI::GetAsciiHost(). michael@0: * If consumers wish to compare the result of this method against the host from michael@0: * another nsIURI, the host should be obtained using nsIURI::GetAsciiHost(). michael@0: * In the case of nested URIs, the innermost URI will be used. michael@0: * michael@0: * @param aURI The URI to be analyzed michael@0: * michael@0: * @returns the public suffix michael@0: * michael@0: * @throws NS_ERROR_UNEXPECTED michael@0: * or other error returned by nsIIDNService::normalize when michael@0: * the hostname contains characters disallowed in URIs michael@0: * @throws NS_ERROR_HOST_IS_IP_ADDRESS michael@0: * if the host is a numeric IPv4 or IPv6 address (as determined by michael@0: * the success of a call to PR_StringToNetAddr()). michael@0: */ michael@0: ACString getPublicSuffix(in nsIURI aURI); michael@0: michael@0: /** michael@0: * Returns the base domain of a URI; that is, the public suffix with a given michael@0: * number of additional domain name parts. For example, the result of this method michael@0: * for "www.bbc.co.uk", depending on the value of aAdditionalParts parameter, will michael@0: * be: michael@0: * michael@0: * 0 (default) -> bbc.co.uk michael@0: * 1 -> www.bbc.co.uk michael@0: * michael@0: * Similarly, the public suffix for "www.developer.mozilla.org" is "org", and the base michael@0: * domain will be: michael@0: * michael@0: * 0 (default) -> mozilla.org michael@0: * 1 -> developer.mozilla.org michael@0: * 2 -> www.developer.mozilla.org michael@0: * michael@0: * The base domain will be returned encoded in ASCII/ACE and will be normalized michael@0: * according to RFC 3454, i.e. the same encoding returned by nsIURI::GetAsciiHost(). michael@0: * If consumers wish to compare the result of this method against the host from michael@0: * another nsIURI, the host should be obtained using nsIURI::GetAsciiHost(). michael@0: * In the case of nested URIs, the innermost URI will be used. michael@0: * michael@0: * @param aURI The URI to be analyzed michael@0: * @param aAdditionalParts Number of domain name parts to be michael@0: * returned in addition to the public suffix michael@0: * michael@0: * @returns the base domain (public suffix plus the requested number of additional parts) michael@0: * michael@0: * @throws NS_ERROR_UNEXPECTED michael@0: * or other error returned by nsIIDNService::normalize when michael@0: * the hostname contains characters disallowed in URIs michael@0: * @throws NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS michael@0: * when there are insufficient subdomain levels in the hostname to satisfy the michael@0: * requested aAdditionalParts value. michael@0: * @throws NS_ERROR_HOST_IS_IP_ADDRESS michael@0: * if aHost is a numeric IPv4 or IPv6 address (as determined by michael@0: * the success of a call to PR_StringToNetAddr()). michael@0: * michael@0: * @see getPublicSuffix() michael@0: */ michael@0: ACString getBaseDomain(in nsIURI aURI, [optional] in uint32_t aAdditionalParts); michael@0: michael@0: /** michael@0: * NOTE: It is strongly recommended to use getPublicSuffix() above if a suitable michael@0: * nsIURI is available. Only use this method if this is not the case. michael@0: * michael@0: * Returns the public suffix of a host string. Otherwise identical to getPublicSuffix(). michael@0: * michael@0: * @param aHost The host to be analyzed. Any additional parts (e.g. scheme, michael@0: * port, or path) will cause this method to throw. ASCII/ACE and michael@0: * UTF8 encodings are acceptable as input; normalization will michael@0: * be performed as specified in getBaseDomain(). michael@0: * michael@0: * @see getPublicSuffix() michael@0: */ michael@0: ACString getPublicSuffixFromHost(in AUTF8String aHost); michael@0: michael@0: /** michael@0: * NOTE: It is strongly recommended to use getBaseDomain() above if a suitable michael@0: * nsIURI is available. Only use this method if this is not the case. michael@0: * michael@0: * Returns the base domain of a host string. Otherwise identical to getBaseDomain(). michael@0: * michael@0: * @param aHost The host to be analyzed. Any additional parts (e.g. scheme, michael@0: * port, or path) will cause this method to throw. ASCII/ACE and michael@0: * UTF8 encodings are acceptable as input; normalization will michael@0: * be performed as specified in getBaseDomain(). michael@0: * michael@0: * @see getBaseDomain() michael@0: */ michael@0: ACString getBaseDomainFromHost(in AUTF8String aHost, [optional] in uint32_t aAdditionalParts); michael@0: michael@0: /** michael@0: * Returns the parent sub-domain of a host string. If the host is a base michael@0: * domain, it will throw NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS. michael@0: * michael@0: * For example: "player.bbc.co.uk" would return "bbc.co.uk" and michael@0: * "bbc.co.uk" would throw NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS. michael@0: * michael@0: * @param aHost The host to be analyzed. Any additional parts (e.g. scheme, michael@0: * port, or path) will cause this method to throw. ASCII/ACE and michael@0: * UTF8 encodings are acceptable as input; normalization will michael@0: * be performed as specified in getBaseDomain(). michael@0: */ michael@0: ACString getNextSubDomain(in AUTF8String aHost); michael@0: }; michael@0: