1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla Effective TLD Service
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2006
20 * the Initial Developer. All Rights Reserved.
23 * Pamela Greene <pamg.bugs@gmail.com> (original author)
24 * Daniel Witte <dwitte@stanford.edu>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #include
"nsISupports.idl"
44 [scriptable
, uuid(6852369e
-baa9
-4c9a
-bbcd
-5123fc54a297
)]
45 interface nsIEffectiveTLDService
: nsISupports
48 * Returns the public suffix of a URI. A public suffix is the highest-level domain
49 * under which individual domains may be registered; it may therefore contain one
50 * or more dots. For example, the public suffix for "www.bbc.co.uk" is "co.uk",
51 * because the .uk TLD does not allow the registration of domains at the
52 * second level ("bbc.uk" is forbidden).
54 * The public suffix will be returned encoded in ASCII/ACE and will be normalized
55 * according to RFC 3454, i.e. the same encoding returned by nsIURI::GetAsciiHost().
56 * If consumers wish to compare the result of this method against the host from
57 * another nsIURI, the host should be obtained using nsIURI::GetAsciiHost().
58 * In the case of nested URIs, the innermost URI will be used.
60 * @param aURI The URI to be analyzed
62 * @returns the public suffix
64 * @throws NS_ERROR_UNEXPECTED
65 * or other error returned by nsIIDNService::normalize when
66 * the hostname contains characters disallowed in URIs
67 * @throws NS_ERROR_HOST_IS_IP_ADDRESS
68 * if the host is a numeric IPv4 or IPv6 address (as determined by
69 * the success of a call to PR_StringToNetAddr()).
71 ACString getPublicSuffix
(in nsIURI aURI
);
74 * Returns the base domain of a URI; that is, the public suffix with a given
75 * number of additional domain name parts. For example, the result of this method
76 * for "www.bbc.co.uk", depending on the value of aAdditionalParts parameter, will
79 * 0 (default) -> bbc.co.uk
82 * Similarly, the public suffix for "www.developer.mozilla.org" is "org", and the base
85 * 0 (default) -> mozilla.org
86 * 1 -> developer.mozilla.org
87 * 2 -> www.developer.mozilla.org
89 * The base domain will be returned encoded in ASCII/ACE and will be normalized
90 * according to RFC 3454, i.e. the same encoding returned by nsIURI::GetAsciiHost().
91 * If consumers wish to compare the result of this method against the host from
92 * another nsIURI, the host should be obtained using nsIURI::GetAsciiHost().
93 * In the case of nested URIs, the innermost URI will be used.
95 * @param aURI The URI to be analyzed
96 * @param aAdditionalParts Number of domain name parts to be
97 * returned in addition to the public suffix
99 * @returns the base domain (public suffix plus the requested number of additional parts)
101 * @throws NS_ERROR_UNEXPECTED
102 * or other error returned by nsIIDNService::normalize when
103 * the hostname contains characters disallowed in URIs
104 * @throws NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS
105 * when there are insufficient subdomain levels in the hostname to satisfy the
106 * requested aAdditionalParts value.
107 * @throws NS_ERROR_HOST_IS_IP_ADDRESS
108 * if aHost is a numeric IPv4 or IPv6 address (as determined by
109 * the success of a call to PR_StringToNetAddr()).
111 * @see getPublicSuffix()
113 ACString getBaseDomain
(in nsIURI aURI
, [optional] in PRUint32 aAdditionalParts
);
116 * NOTE: It is strongly recommended to use getPublicSuffix() above if a suitable
117 * nsIURI is available. Only use this method if this is not the case.
119 * Returns the public suffix of a host string. Otherwise identical to getPublicSuffix().
121 * @param aHost The host to be analyzed. Any additional parts (e.g. scheme,
122 * port, or path) will cause this method to throw. ASCII/ACE and
123 * UTF8 encodings are acceptable as input; normalization will
124 * be performed as specified in getBaseDomain().
126 * @see getPublicSuffix()
128 ACString getPublicSuffixFromHost
(in AUTF8String aHost
);
131 * NOTE: It is strongly recommended to use getBaseDomain() above if a suitable
132 * nsIURI is available. Only use this method if this is not the case.
134 * Returns the base domain of a host string. Otherwise identical to getBaseDomain().
136 * @param aHost The host to be analyzed. Any additional parts (e.g. scheme,
137 * port, or path) will cause this method to throw. ASCII/ACE and
138 * UTF8 encodings are acceptable as input; normalization will
139 * be performed as specified in getBaseDomain().
141 * @see getBaseDomain()
143 ACString getBaseDomainFromHost
(in AUTF8String aHost
, [optional] in PRUint32 aAdditionalParts
);