PageRenderTime 28ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/gecko_sdk/idl/nsIProtocolHandler.idl

http://firefox-mac-pdf.googlecode.com/
IDL | 255 lines | 31 code | 25 blank | 199 comment | 0 complexity | 7a7eb5cbe4444cdfb0032601ed565ba2 MD5 | raw file
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  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/
  9. *
  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
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. #include "nsISupports.idl"
  38. interface nsIURI;
  39. interface nsIChannel;
  40. /**
  41. * nsIProtocolHandler
  42. *
  43. * @status FROZEN
  44. */
  45. [scriptable, uuid(15fd6940-8ea7-11d3-93ad-00104ba0fd40)]
  46. interface nsIProtocolHandler : nsISupports
  47. {
  48. /**
  49. * The scheme of this protocol (e.g., "file").
  50. */
  51. readonly attribute ACString scheme;
  52. /**
  53. * The default port is the port that this protocol normally uses.
  54. * If a port does not make sense for the protocol (e.g., "about:")
  55. * then -1 will be returned.
  56. */
  57. readonly attribute long defaultPort;
  58. /**
  59. * Returns the protocol specific flags (see flag definitions below).
  60. */
  61. readonly attribute unsigned long protocolFlags;
  62. /**
  63. * Makes a URI object that is suitable for loading by this protocol,
  64. * where the URI string is given as an UTF-8 string. The caller may
  65. * provide the charset from which the URI string originated, so that
  66. * the URI string can be translated back to that charset (if necessary)
  67. * before communicating with, for example, the origin server of the URI
  68. * string. (Many servers do not support UTF-8 IRIs at the present time,
  69. * so we must be careful about tracking the native charset of the origin
  70. * server.)
  71. *
  72. * @param aSpec - the URI string in UTF-8 encoding. depending
  73. * on the protocol implementation, unicode character
  74. * sequences may or may not be %xx escaped.
  75. * @param aOriginCharset - the charset of the document from which this URI
  76. * string originated. this corresponds to the
  77. * charset that should be used when communicating
  78. * this URI to an origin server, for example. if
  79. * null, then UTF-8 encoding is assumed (i.e.,
  80. * no charset transformation from aSpec).
  81. * @param aBaseURI - if null, aSpec must specify an absolute URI.
  82. * otherwise, aSpec may be resolved relative
  83. * to aBaseURI, depending on the protocol.
  84. * If the protocol has no concept of relative
  85. * URI aBaseURI will simply be ignored.
  86. */
  87. nsIURI newURI(in AUTF8String aSpec,
  88. in string aOriginCharset,
  89. in nsIURI aBaseURI);
  90. /**
  91. * Constructs a new channel from the given URI for this protocol handler.
  92. */
  93. nsIChannel newChannel(in nsIURI aURI);
  94. /**
  95. * Allows a protocol to override blacklisted ports.
  96. *
  97. * This method will be called when there is an attempt to connect to a port
  98. * that is blacklisted. For example, for most protocols, port 25 (Simple Mail
  99. * Transfer) is banned. When a URI containing this "known-to-do-bad-things"
  100. * port number is encountered, this function will be called to ask if the
  101. * protocol handler wants to override the ban.
  102. */
  103. boolean allowPort(in long port, in string scheme);
  104. /**************************************************************************
  105. * Constants for the protocol flags (the first is the default mask, the
  106. * others are deviations):
  107. *
  108. * NOTE: Implementation must ignore any flags they do not understand.
  109. */
  110. /**
  111. * standard full URI with authority component and concept of relative
  112. * URIs (http, ftp, ...)
  113. */
  114. const unsigned long URI_STD = 0;
  115. /**
  116. * no concept of relative URIs (about, javascript, finger, ...)
  117. */
  118. const unsigned long URI_NORELATIVE = (1<<0);
  119. /**
  120. * no authority component (file, ...)
  121. */
  122. const unsigned long URI_NOAUTH = (1<<1);
  123. /**
  124. * The URIs for this protocol have no inherent security context, so
  125. * documents loaded via this protocol should inherit the security context
  126. * from the document that loads them.
  127. */
  128. const unsigned long URI_INHERITS_SECURITY_CONTEXT = (1<<4);
  129. /**
  130. * "Automatic" loads that would replace the document (e.g. <meta> refresh,
  131. * certain types of XLinks, possibly other loads that the application
  132. * decides are not user triggered) are not allowed if the originating (NOT
  133. * the target) URI has this protocol flag. Note that the decision as to
  134. * what constitutes an "automatic" load is made externally, by the caller
  135. * of nsIScriptSecurityManager::CheckLoadURI. See documentation for that
  136. * method for more information.
  137. *
  138. * A typical protocol that might want to set this flag is a protocol that
  139. * shows highly untrusted content in a viewing area that the user expects
  140. * to have a lot of control over, such as an e-mail reader.
  141. */
  142. const unsigned long URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT = (1<<5);
  143. /**
  144. * +-------------------------------------------------------------------+
  145. * | |
  146. * | ALL PROTOCOL HANDLERS MUST SET ONE OF THE FOLLOWING FOUR FLAGS. |
  147. * | |
  148. * +-------------------------------------------------------------------+
  149. *
  150. * These flags are used to determine who is allowed to load URIs for this
  151. * protocol. Note that if a URI is nested, only the flags for the
  152. * innermost URI matter. See nsINestedURI.
  153. *
  154. * If none of these four flags are set, the URI must be treated as if it
  155. * had the URI_LOADABLE_BY_ANYONE flag set, for compatibility with protocol
  156. * handlers written against Gecko 1.8 or earlier. In this case, there may
  157. * be run-time warning messages indicating that a "default insecure"
  158. * assumption is being made. At some point in the futures (Mozilla 2.0,
  159. * most likely), these warnings will become errors.
  160. */
  161. /**
  162. * The URIs for this protocol can be loaded by anyone. For example, any
  163. * website should be allowed to trigger a load of a URI for this protocol.
  164. * Web-safe protocols like "http" should set this flag.
  165. */
  166. const unsigned long URI_LOADABLE_BY_ANYONE = (1<<6);
  167. /**
  168. * The URIs for this protocol are UNSAFE if loaded by untrusted (web)
  169. * content and may only be loaded by privileged code (for example, code
  170. * which has the system principal). Various internal protocols should set
  171. * this flag.
  172. */
  173. const unsigned long URI_DANGEROUS_TO_LOAD = (1<<7);
  174. /**
  175. * The URIs for this protocol point to resources that are part of the
  176. * application's user interface. There are cases when such resources may
  177. * be made accessible to untrusted content such as web pages, so this is
  178. * less restrictive than URI_DANGEROUS_TO_LOAD but more restrictive than
  179. * URI_LOADABLE_BY_ANYONE. See the documentation for
  180. * nsIScriptSecurityManager::CheckLoadURI.
  181. */
  182. const unsigned long URI_IS_UI_RESOURCE = (1<<8);
  183. /**
  184. * Loading of URIs for this protocol from other origins should only be
  185. * allowed if those origins should have access to the local filesystem.
  186. * It's up to the application to decide what origins should have such
  187. * access. Protocols like "file" that point to local data should set this
  188. * flag.
  189. */
  190. const unsigned long URI_IS_LOCAL_FILE = (1<<9);
  191. /**
  192. * Loading channels from this protocol has side-effects that make
  193. * it unsuitable for saving to a local file.
  194. */
  195. const unsigned long URI_NON_PERSISTABLE = (1<<10);
  196. /**
  197. * Channels using this protocol never call OnDataAvailable
  198. * on the listener passed to AsyncOpen and they therefore
  199. * do not return any data that we can use.
  200. */
  201. const unsigned long URI_DOES_NOT_RETURN_DATA = (1<<11);
  202. /**
  203. * This protocol handler can be proxied via a proxy (socks or http)
  204. * (e.g., irc, smtp, http, etc.). If the protocol supports transparent
  205. * proxying, the handler should implement nsIProxiedProtocolHandler.
  206. *
  207. * If it supports only HTTP proxying, then it need not support
  208. * nsIProxiedProtocolHandler, but should instead set the ALLOWS_PROXY_HTTP
  209. * flag (see below).
  210. *
  211. * @see nsIProxiedProtocolHandler
  212. */
  213. const unsigned long ALLOWS_PROXY = (1<<2);
  214. /**
  215. * This protocol handler can be proxied using a http proxy (e.g., http,
  216. * ftp, etc.). nsIIOService::newChannelFromURI will feed URIs from this
  217. * protocol handler to the HTTP protocol handler instead. This flag is
  218. * ignored if ALLOWS_PROXY is not set.
  219. */
  220. const unsigned long ALLOWS_PROXY_HTTP = (1<<3);
  221. };
  222. %{C++
  223. /**
  224. * Protocol handlers are registered with XPCOM under the following CONTRACTID prefix:
  225. */
  226. #define NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "@mozilla.org/network/protocol;1?name="
  227. /**
  228. * For example, "@mozilla.org/network/protocol;1?name=http"
  229. */
  230. %}