PageRenderTime 22ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/gecko_api/include/nsIProtocolHandler.h

http://firefox-mac-pdf.googlecode.com/
C Header | 345 lines | 104 code | 51 blank | 190 comment | 0 complexity | e7e07786ceaf9159b9589f7f3f16276d MD5 | raw file
  1. /*
  2. * DO NOT EDIT. THIS FILE IS GENERATED FROM /builds/tinderbox/XR-Trunk/Darwin_8.8.4_Depend/mozilla/netwerk/base/public/nsIProtocolHandler.idl
  3. */
  4. #ifndef __gen_nsIProtocolHandler_h__
  5. #define __gen_nsIProtocolHandler_h__
  6. #ifndef __gen_nsISupports_h__
  7. #include "nsISupports.h"
  8. #endif
  9. /* For IDL files that don't want to include root IDL files. */
  10. #ifndef NS_NO_VTABLE
  11. #define NS_NO_VTABLE
  12. #endif
  13. class nsIURI; /* forward declaration */
  14. class nsIChannel; /* forward declaration */
  15. /* starting interface: nsIProtocolHandler */
  16. #define NS_IPROTOCOLHANDLER_IID_STR "15fd6940-8ea7-11d3-93ad-00104ba0fd40"
  17. #define NS_IPROTOCOLHANDLER_IID \
  18. {0x15fd6940, 0x8ea7, 0x11d3, \
  19. { 0x93, 0xad, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40 }}
  20. /**
  21. * nsIProtocolHandler
  22. *
  23. * @status FROZEN
  24. */
  25. class NS_NO_VTABLE NS_SCRIPTABLE nsIProtocolHandler : public nsISupports {
  26. public:
  27. NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPROTOCOLHANDLER_IID)
  28. /**
  29. * The scheme of this protocol (e.g., "file").
  30. */
  31. /* readonly attribute ACString scheme; */
  32. NS_SCRIPTABLE NS_IMETHOD GetScheme(nsACString & aScheme) = 0;
  33. /**
  34. * The default port is the port that this protocol normally uses.
  35. * If a port does not make sense for the protocol (e.g., "about:")
  36. * then -1 will be returned.
  37. */
  38. /* readonly attribute long defaultPort; */
  39. NS_SCRIPTABLE NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort) = 0;
  40. /**
  41. * Returns the protocol specific flags (see flag definitions below).
  42. */
  43. /* readonly attribute unsigned long protocolFlags; */
  44. NS_SCRIPTABLE NS_IMETHOD GetProtocolFlags(PRUint32 *aProtocolFlags) = 0;
  45. /**
  46. * Makes a URI object that is suitable for loading by this protocol,
  47. * where the URI string is given as an UTF-8 string. The caller may
  48. * provide the charset from which the URI string originated, so that
  49. * the URI string can be translated back to that charset (if necessary)
  50. * before communicating with, for example, the origin server of the URI
  51. * string. (Many servers do not support UTF-8 IRIs at the present time,
  52. * so we must be careful about tracking the native charset of the origin
  53. * server.)
  54. *
  55. * @param aSpec - the URI string in UTF-8 encoding. depending
  56. * on the protocol implementation, unicode character
  57. * sequences may or may not be %xx escaped.
  58. * @param aOriginCharset - the charset of the document from which this URI
  59. * string originated. this corresponds to the
  60. * charset that should be used when communicating
  61. * this URI to an origin server, for example. if
  62. * null, then UTF-8 encoding is assumed (i.e.,
  63. * no charset transformation from aSpec).
  64. * @param aBaseURI - if null, aSpec must specify an absolute URI.
  65. * otherwise, aSpec may be resolved relative
  66. * to aBaseURI, depending on the protocol.
  67. * If the protocol has no concept of relative
  68. * URI aBaseURI will simply be ignored.
  69. */
  70. /* nsIURI newURI (in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI); */
  71. NS_SCRIPTABLE NS_IMETHOD NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval) = 0;
  72. /**
  73. * Constructs a new channel from the given URI for this protocol handler.
  74. */
  75. /* nsIChannel newChannel (in nsIURI aURI); */
  76. NS_SCRIPTABLE NS_IMETHOD NewChannel(nsIURI *aURI, nsIChannel **_retval) = 0;
  77. /**
  78. * Allows a protocol to override blacklisted ports.
  79. *
  80. * This method will be called when there is an attempt to connect to a port
  81. * that is blacklisted. For example, for most protocols, port 25 (Simple Mail
  82. * Transfer) is banned. When a URI containing this "known-to-do-bad-things"
  83. * port number is encountered, this function will be called to ask if the
  84. * protocol handler wants to override the ban.
  85. */
  86. /* boolean allowPort (in long port, in string scheme); */
  87. NS_SCRIPTABLE NS_IMETHOD AllowPort(PRInt32 port, const char *scheme, PRBool *_retval) = 0;
  88. /**************************************************************************
  89. * Constants for the protocol flags (the first is the default mask, the
  90. * others are deviations):
  91. *
  92. * NOTE: Implementation must ignore any flags they do not understand.
  93. */
  94. /**
  95. * standard full URI with authority component and concept of relative
  96. * URIs (http, ftp, ...)
  97. */
  98. enum { URI_STD = 0U };
  99. /**
  100. * no concept of relative URIs (about, javascript, finger, ...)
  101. */
  102. enum { URI_NORELATIVE = 1U };
  103. /**
  104. * no authority component (file, ...)
  105. */
  106. enum { URI_NOAUTH = 2U };
  107. /**
  108. * The URIs for this protocol have no inherent security context, so
  109. * documents loaded via this protocol should inherit the security context
  110. * from the document that loads them.
  111. */
  112. enum { URI_INHERITS_SECURITY_CONTEXT = 16U };
  113. /**
  114. * "Automatic" loads that would replace the document (e.g. <meta> refresh,
  115. * certain types of XLinks, possibly other loads that the application
  116. * decides are not user triggered) are not allowed if the originating (NOT
  117. * the target) URI has this protocol flag. Note that the decision as to
  118. * what constitutes an "automatic" load is made externally, by the caller
  119. * of nsIScriptSecurityManager::CheckLoadURI. See documentation for that
  120. * method for more information.
  121. *
  122. * A typical protocol that might want to set this flag is a protocol that
  123. * shows highly untrusted content in a viewing area that the user expects
  124. * to have a lot of control over, such as an e-mail reader.
  125. */
  126. enum { URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT = 32U };
  127. /**
  128. * +-------------------------------------------------------------------+
  129. * | |
  130. * | ALL PROTOCOL HANDLERS MUST SET ONE OF THE FOLLOWING FOUR FLAGS. |
  131. * | |
  132. * +-------------------------------------------------------------------+
  133. *
  134. * These flags are used to determine who is allowed to load URIs for this
  135. * protocol. Note that if a URI is nested, only the flags for the
  136. * innermost URI matter. See nsINestedURI.
  137. *
  138. * If none of these four flags are set, the URI must be treated as if it
  139. * had the URI_LOADABLE_BY_ANYONE flag set, for compatibility with protocol
  140. * handlers written against Gecko 1.8 or earlier. In this case, there may
  141. * be run-time warning messages indicating that a "default insecure"
  142. * assumption is being made. At some point in the futures (Mozilla 2.0,
  143. * most likely), these warnings will become errors.
  144. */
  145. /**
  146. * The URIs for this protocol can be loaded by anyone. For example, any
  147. * website should be allowed to trigger a load of a URI for this protocol.
  148. * Web-safe protocols like "http" should set this flag.
  149. */
  150. enum { URI_LOADABLE_BY_ANYONE = 64U };
  151. /**
  152. * The URIs for this protocol are UNSAFE if loaded by untrusted (web)
  153. * content and may only be loaded by privileged code (for example, code
  154. * which has the system principal). Various internal protocols should set
  155. * this flag.
  156. */
  157. enum { URI_DANGEROUS_TO_LOAD = 128U };
  158. /**
  159. * The URIs for this protocol point to resources that are part of the
  160. * application's user interface. There are cases when such resources may
  161. * be made accessible to untrusted content such as web pages, so this is
  162. * less restrictive than URI_DANGEROUS_TO_LOAD but more restrictive than
  163. * URI_LOADABLE_BY_ANYONE. See the documentation for
  164. * nsIScriptSecurityManager::CheckLoadURI.
  165. */
  166. enum { URI_IS_UI_RESOURCE = 256U };
  167. /**
  168. * Loading of URIs for this protocol from other origins should only be
  169. * allowed if those origins should have access to the local filesystem.
  170. * It's up to the application to decide what origins should have such
  171. * access. Protocols like "file" that point to local data should set this
  172. * flag.
  173. */
  174. enum { URI_IS_LOCAL_FILE = 512U };
  175. /**
  176. * Loading channels from this protocol has side-effects that make
  177. * it unsuitable for saving to a local file.
  178. */
  179. enum { URI_NON_PERSISTABLE = 1024U };
  180. /**
  181. * Channels using this protocol never call OnDataAvailable
  182. * on the listener passed to AsyncOpen and they therefore
  183. * do not return any data that we can use.
  184. */
  185. enum { URI_DOES_NOT_RETURN_DATA = 2048U };
  186. /**
  187. * This protocol handler can be proxied via a proxy (socks or http)
  188. * (e.g., irc, smtp, http, etc.). If the protocol supports transparent
  189. * proxying, the handler should implement nsIProxiedProtocolHandler.
  190. *
  191. * If it supports only HTTP proxying, then it need not support
  192. * nsIProxiedProtocolHandler, but should instead set the ALLOWS_PROXY_HTTP
  193. * flag (see below).
  194. *
  195. * @see nsIProxiedProtocolHandler
  196. */
  197. enum { ALLOWS_PROXY = 4U };
  198. /**
  199. * This protocol handler can be proxied using a http proxy (e.g., http,
  200. * ftp, etc.). nsIIOService::newChannelFromURI will feed URIs from this
  201. * protocol handler to the HTTP protocol handler instead. This flag is
  202. * ignored if ALLOWS_PROXY is not set.
  203. */
  204. enum { ALLOWS_PROXY_HTTP = 8U };
  205. };
  206. NS_DEFINE_STATIC_IID_ACCESSOR(nsIProtocolHandler, NS_IPROTOCOLHANDLER_IID)
  207. /* Use this macro when declaring classes that implement this interface. */
  208. #define NS_DECL_NSIPROTOCOLHANDLER \
  209. NS_SCRIPTABLE NS_IMETHOD GetScheme(nsACString & aScheme); \
  210. NS_SCRIPTABLE NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort); \
  211. NS_SCRIPTABLE NS_IMETHOD GetProtocolFlags(PRUint32 *aProtocolFlags); \
  212. NS_SCRIPTABLE NS_IMETHOD NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval); \
  213. NS_SCRIPTABLE NS_IMETHOD NewChannel(nsIURI *aURI, nsIChannel **_retval); \
  214. NS_SCRIPTABLE NS_IMETHOD AllowPort(PRInt32 port, const char *scheme, PRBool *_retval); \
  215. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  216. #define NS_FORWARD_NSIPROTOCOLHANDLER(_to) \
  217. NS_SCRIPTABLE NS_IMETHOD GetScheme(nsACString & aScheme) { return _to GetScheme(aScheme); } \
  218. NS_SCRIPTABLE NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort) { return _to GetDefaultPort(aDefaultPort); } \
  219. NS_SCRIPTABLE NS_IMETHOD GetProtocolFlags(PRUint32 *aProtocolFlags) { return _to GetProtocolFlags(aProtocolFlags); } \
  220. NS_SCRIPTABLE NS_IMETHOD NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval) { return _to NewURI(aSpec, aOriginCharset, aBaseURI, _retval); } \
  221. NS_SCRIPTABLE NS_IMETHOD NewChannel(nsIURI *aURI, nsIChannel **_retval) { return _to NewChannel(aURI, _retval); } \
  222. NS_SCRIPTABLE NS_IMETHOD AllowPort(PRInt32 port, const char *scheme, PRBool *_retval) { return _to AllowPort(port, scheme, _retval); } \
  223. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  224. #define NS_FORWARD_SAFE_NSIPROTOCOLHANDLER(_to) \
  225. NS_SCRIPTABLE NS_IMETHOD GetScheme(nsACString & aScheme) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetScheme(aScheme); } \
  226. NS_SCRIPTABLE NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDefaultPort(aDefaultPort); } \
  227. NS_SCRIPTABLE NS_IMETHOD GetProtocolFlags(PRUint32 *aProtocolFlags) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetProtocolFlags(aProtocolFlags); } \
  228. NS_SCRIPTABLE NS_IMETHOD NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->NewURI(aSpec, aOriginCharset, aBaseURI, _retval); } \
  229. NS_SCRIPTABLE NS_IMETHOD NewChannel(nsIURI *aURI, nsIChannel **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->NewChannel(aURI, _retval); } \
  230. NS_SCRIPTABLE NS_IMETHOD AllowPort(PRInt32 port, const char *scheme, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->AllowPort(port, scheme, _retval); } \
  231. #if 0
  232. /* Use the code below as a template for the implementation class for this interface. */
  233. /* Header file */
  234. class nsProtocolHandler : public nsIProtocolHandler
  235. {
  236. public:
  237. NS_DECL_ISUPPORTS
  238. NS_DECL_NSIPROTOCOLHANDLER
  239. nsProtocolHandler();
  240. private:
  241. ~nsProtocolHandler();
  242. protected:
  243. /* additional members */
  244. };
  245. /* Implementation file */
  246. NS_IMPL_ISUPPORTS1(nsProtocolHandler, nsIProtocolHandler)
  247. nsProtocolHandler::nsProtocolHandler()
  248. {
  249. /* member initializers and constructor code */
  250. }
  251. nsProtocolHandler::~nsProtocolHandler()
  252. {
  253. /* destructor code */
  254. }
  255. /* readonly attribute ACString scheme; */
  256. NS_IMETHODIMP nsProtocolHandler::GetScheme(nsACString & aScheme)
  257. {
  258. return NS_ERROR_NOT_IMPLEMENTED;
  259. }
  260. /* readonly attribute long defaultPort; */
  261. NS_IMETHODIMP nsProtocolHandler::GetDefaultPort(PRInt32 *aDefaultPort)
  262. {
  263. return NS_ERROR_NOT_IMPLEMENTED;
  264. }
  265. /* readonly attribute unsigned long protocolFlags; */
  266. NS_IMETHODIMP nsProtocolHandler::GetProtocolFlags(PRUint32 *aProtocolFlags)
  267. {
  268. return NS_ERROR_NOT_IMPLEMENTED;
  269. }
  270. /* nsIURI newURI (in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI); */
  271. NS_IMETHODIMP nsProtocolHandler::NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval)
  272. {
  273. return NS_ERROR_NOT_IMPLEMENTED;
  274. }
  275. /* nsIChannel newChannel (in nsIURI aURI); */
  276. NS_IMETHODIMP nsProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval)
  277. {
  278. return NS_ERROR_NOT_IMPLEMENTED;
  279. }
  280. /* boolean allowPort (in long port, in string scheme); */
  281. NS_IMETHODIMP nsProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
  282. {
  283. return NS_ERROR_NOT_IMPLEMENTED;
  284. }
  285. /* End of implementation class template. */
  286. #endif
  287. /**
  288. * Protocol handlers are registered with XPCOM under the following CONTRACTID prefix:
  289. */
  290. #define NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "@mozilla.org/network/protocol;1?name="
  291. /**
  292. * For example, "@mozilla.org/network/protocol;1?name=http"
  293. */
  294. #endif /* __gen_nsIProtocolHandler_h__ */