nsIEffectiveTLDService.idl 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsISupports.idl"
  6. interface nsIURI;
  7. [scriptable, uuid(68067eb5-ad8d-43cb-a043-1cc85ebe06e7)]
  8. interface nsIEffectiveTLDService : nsISupports
  9. {
  10. /**
  11. * Returns the public suffix of a URI. A public suffix is the highest-level domain
  12. * under which individual domains may be registered; it may therefore contain one
  13. * or more dots. For example, the public suffix for "www.bbc.co.uk" is "co.uk",
  14. * because the .uk TLD does not allow the registration of domains at the
  15. * second level ("bbc.uk" is forbidden).
  16. *
  17. * The public suffix will be returned encoded in ASCII/ACE and will be normalized
  18. * according to RFC 3454, i.e. the same encoding returned by nsIURI::GetAsciiHost().
  19. * If consumers wish to compare the result of this method against the host from
  20. * another nsIURI, the host should be obtained using nsIURI::GetAsciiHost().
  21. * In the case of nested URIs, the innermost URI will be used.
  22. *
  23. * @param aURI The URI to be analyzed
  24. *
  25. * @returns the public suffix
  26. *
  27. * @throws NS_ERROR_UNEXPECTED
  28. * or other error returned by nsIIDNService::normalize when
  29. * the hostname contains characters disallowed in URIs
  30. * @throws NS_ERROR_HOST_IS_IP_ADDRESS
  31. * if the host is a numeric IPv4 or IPv6 address (as determined by
  32. * the success of a call to PR_StringToNetAddr()).
  33. */
  34. ACString getPublicSuffix(in nsIURI aURI);
  35. /**
  36. * Returns the base domain of a URI; that is, the public suffix with a given
  37. * number of additional domain name parts. For example, the result of this method
  38. * for "www.bbc.co.uk", depending on the value of aAdditionalParts parameter, will
  39. * be:
  40. *
  41. * 0 (default) -> bbc.co.uk
  42. * 1 -> www.bbc.co.uk
  43. *
  44. * Similarly, the public suffix for "www.developer.mozilla.org" is "org", and the base
  45. * domain will be:
  46. *
  47. * 0 (default) -> mozilla.org
  48. * 1 -> developer.mozilla.org
  49. * 2 -> www.developer.mozilla.org
  50. *
  51. * The base domain will be returned encoded in ASCII/ACE and will be normalized
  52. * according to RFC 3454, i.e. the same encoding returned by nsIURI::GetAsciiHost().
  53. * If consumers wish to compare the result of this method against the host from
  54. * another nsIURI, the host should be obtained using nsIURI::GetAsciiHost().
  55. * In the case of nested URIs, the innermost URI will be used.
  56. *
  57. * @param aURI The URI to be analyzed
  58. * @param aAdditionalParts Number of domain name parts to be
  59. * returned in addition to the public suffix
  60. *
  61. * @returns the base domain (public suffix plus the requested number of additional parts)
  62. *
  63. * @throws NS_ERROR_UNEXPECTED
  64. * or other error returned by nsIIDNService::normalize when
  65. * the hostname contains characters disallowed in URIs
  66. * @throws NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS
  67. * when there are insufficient subdomain levels in the hostname to satisfy the
  68. * requested aAdditionalParts value.
  69. * @throws NS_ERROR_HOST_IS_IP_ADDRESS
  70. * if aHost is a numeric IPv4 or IPv6 address (as determined by
  71. * the success of a call to PR_StringToNetAddr()).
  72. *
  73. * @see getPublicSuffix()
  74. */
  75. ACString getBaseDomain(in nsIURI aURI, [optional] in uint32_t aAdditionalParts);
  76. /**
  77. * NOTE: It is strongly recommended to use getPublicSuffix() above if a suitable
  78. * nsIURI is available. Only use this method if this is not the case.
  79. *
  80. * Returns the public suffix of a host string. Otherwise identical to getPublicSuffix().
  81. *
  82. * @param aHost The host to be analyzed. Any additional parts (e.g. scheme,
  83. * port, or path) will cause this method to throw. ASCII/ACE and
  84. * UTF8 encodings are acceptable as input; normalization will
  85. * be performed as specified in getBaseDomain().
  86. *
  87. * @see getPublicSuffix()
  88. */
  89. ACString getPublicSuffixFromHost(in AUTF8String aHost);
  90. /**
  91. * NOTE: It is strongly recommended to use getBaseDomain() above if a suitable
  92. * nsIURI is available. Only use this method if this is not the case.
  93. *
  94. * Returns the base domain of a host string. Otherwise identical to getBaseDomain().
  95. *
  96. * @param aHost The host to be analyzed. Any additional parts (e.g. scheme,
  97. * port, or path) will cause this method to throw. ASCII/ACE and
  98. * UTF8 encodings are acceptable as input; normalization will
  99. * be performed as specified in getBaseDomain().
  100. *
  101. * @see getBaseDomain()
  102. */
  103. ACString getBaseDomainFromHost(in AUTF8String aHost, [optional] in uint32_t aAdditionalParts);
  104. /**
  105. * Returns the parent sub-domain of a host string. If the host is a base
  106. * domain, it will throw NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS.
  107. *
  108. * For example: "player.bbc.co.uk" would return "bbc.co.uk" and
  109. * "bbc.co.uk" would throw NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS.
  110. *
  111. * @param aHost The host to be analyzed. Any additional parts (e.g. scheme,
  112. * port, or path) will cause this method to throw. ASCII/ACE and
  113. * UTF8 encodings are acceptable as input; normalization will
  114. * be performed as specified in getBaseDomain().
  115. */
  116. ACString getNextSubDomain(in AUTF8String aHost);
  117. };