Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | |
michael@0 | 8 | interface nsIURI; |
michael@0 | 9 | interface nsIChannel; |
michael@0 | 10 | |
michael@0 | 11 | /** |
michael@0 | 12 | * nsIProtocolHandler |
michael@0 | 13 | */ |
michael@0 | 14 | [scriptable, uuid(f5753fec-a051-4ddc-8891-11f1f1575072)] |
michael@0 | 15 | interface nsIProtocolHandler : nsISupports |
michael@0 | 16 | { |
michael@0 | 17 | /** |
michael@0 | 18 | * The scheme of this protocol (e.g., "file"). |
michael@0 | 19 | */ |
michael@0 | 20 | readonly attribute ACString scheme; |
michael@0 | 21 | |
michael@0 | 22 | /** |
michael@0 | 23 | * The default port is the port that this protocol normally uses. |
michael@0 | 24 | * If a port does not make sense for the protocol (e.g., "about:") |
michael@0 | 25 | * then -1 will be returned. |
michael@0 | 26 | */ |
michael@0 | 27 | readonly attribute long defaultPort; |
michael@0 | 28 | |
michael@0 | 29 | /** |
michael@0 | 30 | * Returns the protocol specific flags (see flag definitions below). |
michael@0 | 31 | */ |
michael@0 | 32 | readonly attribute unsigned long protocolFlags; |
michael@0 | 33 | |
michael@0 | 34 | /** |
michael@0 | 35 | * Makes a URI object that is suitable for loading by this protocol, |
michael@0 | 36 | * where the URI string is given as an UTF-8 string. The caller may |
michael@0 | 37 | * provide the charset from which the URI string originated, so that |
michael@0 | 38 | * the URI string can be translated back to that charset (if necessary) |
michael@0 | 39 | * before communicating with, for example, the origin server of the URI |
michael@0 | 40 | * string. (Many servers do not support UTF-8 IRIs at the present time, |
michael@0 | 41 | * so we must be careful about tracking the native charset of the origin |
michael@0 | 42 | * server.) |
michael@0 | 43 | * |
michael@0 | 44 | * @param aSpec - the URI string in UTF-8 encoding. depending |
michael@0 | 45 | * on the protocol implementation, unicode character |
michael@0 | 46 | * sequences may or may not be %xx escaped. |
michael@0 | 47 | * @param aOriginCharset - the charset of the document from which this URI |
michael@0 | 48 | * string originated. this corresponds to the |
michael@0 | 49 | * charset that should be used when communicating |
michael@0 | 50 | * this URI to an origin server, for example. if |
michael@0 | 51 | * null, then UTF-8 encoding is assumed (i.e., |
michael@0 | 52 | * no charset transformation from aSpec). |
michael@0 | 53 | * @param aBaseURI - if null, aSpec must specify an absolute URI. |
michael@0 | 54 | * otherwise, aSpec may be resolved relative |
michael@0 | 55 | * to aBaseURI, depending on the protocol. |
michael@0 | 56 | * If the protocol has no concept of relative |
michael@0 | 57 | * URI aBaseURI will simply be ignored. |
michael@0 | 58 | */ |
michael@0 | 59 | nsIURI newURI(in AUTF8String aSpec, |
michael@0 | 60 | in string aOriginCharset, |
michael@0 | 61 | in nsIURI aBaseURI); |
michael@0 | 62 | |
michael@0 | 63 | /** |
michael@0 | 64 | * Constructs a new channel from the given URI for this protocol handler. |
michael@0 | 65 | */ |
michael@0 | 66 | nsIChannel newChannel(in nsIURI aURI); |
michael@0 | 67 | |
michael@0 | 68 | /** |
michael@0 | 69 | * Allows a protocol to override blacklisted ports. |
michael@0 | 70 | * |
michael@0 | 71 | * This method will be called when there is an attempt to connect to a port |
michael@0 | 72 | * that is blacklisted. For example, for most protocols, port 25 (Simple Mail |
michael@0 | 73 | * Transfer) is banned. When a URI containing this "known-to-do-bad-things" |
michael@0 | 74 | * port number is encountered, this function will be called to ask if the |
michael@0 | 75 | * protocol handler wants to override the ban. |
michael@0 | 76 | */ |
michael@0 | 77 | boolean allowPort(in long port, in string scheme); |
michael@0 | 78 | |
michael@0 | 79 | |
michael@0 | 80 | /************************************************************************** |
michael@0 | 81 | * Constants for the protocol flags (the first is the default mask, the |
michael@0 | 82 | * others are deviations): |
michael@0 | 83 | * |
michael@0 | 84 | * NOTE: Implementation must ignore any flags they do not understand. |
michael@0 | 85 | */ |
michael@0 | 86 | |
michael@0 | 87 | /** |
michael@0 | 88 | * standard full URI with authority component and concept of relative |
michael@0 | 89 | * URIs (http, ftp, ...) |
michael@0 | 90 | */ |
michael@0 | 91 | const unsigned long URI_STD = 0; |
michael@0 | 92 | |
michael@0 | 93 | /** |
michael@0 | 94 | * no concept of relative URIs (about, javascript, finger, ...) |
michael@0 | 95 | */ |
michael@0 | 96 | const unsigned long URI_NORELATIVE = (1<<0); |
michael@0 | 97 | |
michael@0 | 98 | /** |
michael@0 | 99 | * no authority component (file, ...) |
michael@0 | 100 | */ |
michael@0 | 101 | const unsigned long URI_NOAUTH = (1<<1); |
michael@0 | 102 | |
michael@0 | 103 | /** |
michael@0 | 104 | * This protocol handler can be proxied via a proxy (socks or http) |
michael@0 | 105 | * (e.g., irc, smtp, http, etc.). If the protocol supports transparent |
michael@0 | 106 | * proxying, the handler should implement nsIProxiedProtocolHandler. |
michael@0 | 107 | * |
michael@0 | 108 | * If it supports only HTTP proxying, then it need not support |
michael@0 | 109 | * nsIProxiedProtocolHandler, but should instead set the ALLOWS_PROXY_HTTP |
michael@0 | 110 | * flag (see below). |
michael@0 | 111 | * |
michael@0 | 112 | * @see nsIProxiedProtocolHandler |
michael@0 | 113 | */ |
michael@0 | 114 | const unsigned long ALLOWS_PROXY = (1<<2); |
michael@0 | 115 | |
michael@0 | 116 | /** |
michael@0 | 117 | * This protocol handler can be proxied using a http proxy (e.g., http, |
michael@0 | 118 | * ftp, etc.). nsIIOService::newChannelFromURI will feed URIs from this |
michael@0 | 119 | * protocol handler to the HTTP protocol handler instead. This flag is |
michael@0 | 120 | * ignored if ALLOWS_PROXY is not set. |
michael@0 | 121 | */ |
michael@0 | 122 | const unsigned long ALLOWS_PROXY_HTTP = (1<<3); |
michael@0 | 123 | |
michael@0 | 124 | /** |
michael@0 | 125 | * The URIs for this protocol have no inherent security context, so |
michael@0 | 126 | * documents loaded via this protocol should inherit the security context |
michael@0 | 127 | * from the document that loads them. |
michael@0 | 128 | */ |
michael@0 | 129 | const unsigned long URI_INHERITS_SECURITY_CONTEXT = (1<<4); |
michael@0 | 130 | |
michael@0 | 131 | /** |
michael@0 | 132 | * "Automatic" loads that would replace the document (e.g. <meta> refresh, |
michael@0 | 133 | * certain types of XLinks, possibly other loads that the application |
michael@0 | 134 | * decides are not user triggered) are not allowed if the originating (NOT |
michael@0 | 135 | * the target) URI has this protocol flag. Note that the decision as to |
michael@0 | 136 | * what constitutes an "automatic" load is made externally, by the caller |
michael@0 | 137 | * of nsIScriptSecurityManager::CheckLoadURI. See documentation for that |
michael@0 | 138 | * method for more information. |
michael@0 | 139 | * |
michael@0 | 140 | * A typical protocol that might want to set this flag is a protocol that |
michael@0 | 141 | * shows highly untrusted content in a viewing area that the user expects |
michael@0 | 142 | * to have a lot of control over, such as an e-mail reader. |
michael@0 | 143 | */ |
michael@0 | 144 | const unsigned long URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT = (1<<5); |
michael@0 | 145 | |
michael@0 | 146 | /** |
michael@0 | 147 | * +-------------------------------------------------------------------+ |
michael@0 | 148 | * | | |
michael@0 | 149 | * | ALL PROTOCOL HANDLERS MUST SET ONE OF THE FOLLOWING FIVE FLAGS. | |
michael@0 | 150 | * | | |
michael@0 | 151 | * +-------------------------------------------------------------------+ |
michael@0 | 152 | * |
michael@0 | 153 | * These flags are used to determine who is allowed to load URIs for this |
michael@0 | 154 | * protocol. Note that if a URI is nested, only the flags for the |
michael@0 | 155 | * innermost URI matter. See nsINestedURI. |
michael@0 | 156 | * |
michael@0 | 157 | * If none of these five flags are set, the URI must be treated as if it |
michael@0 | 158 | * had the URI_LOADABLE_BY_ANYONE flag set, for compatibility with protocol |
michael@0 | 159 | * handlers written against Gecko 1.8 or earlier. In this case, there may |
michael@0 | 160 | * be run-time warning messages indicating that a "default insecure" |
michael@0 | 161 | * assumption is being made. At some point in the futures (Mozilla 2.0, |
michael@0 | 162 | * most likely), these warnings will become errors. |
michael@0 | 163 | */ |
michael@0 | 164 | |
michael@0 | 165 | /** |
michael@0 | 166 | * The URIs for this protocol can be loaded by anyone. For example, any |
michael@0 | 167 | * website should be allowed to trigger a load of a URI for this protocol. |
michael@0 | 168 | * Web-safe protocols like "http" should set this flag. |
michael@0 | 169 | */ |
michael@0 | 170 | const unsigned long URI_LOADABLE_BY_ANYONE = (1<<6); |
michael@0 | 171 | |
michael@0 | 172 | /** |
michael@0 | 173 | * The URIs for this protocol are UNSAFE if loaded by untrusted (web) |
michael@0 | 174 | * content and may only be loaded by privileged code (for example, code |
michael@0 | 175 | * which has the system principal). Various internal protocols should set |
michael@0 | 176 | * this flag. |
michael@0 | 177 | */ |
michael@0 | 178 | const unsigned long URI_DANGEROUS_TO_LOAD = (1<<7); |
michael@0 | 179 | |
michael@0 | 180 | /** |
michael@0 | 181 | * The URIs for this protocol point to resources that are part of the |
michael@0 | 182 | * application's user interface. There are cases when such resources may |
michael@0 | 183 | * be made accessible to untrusted content such as web pages, so this is |
michael@0 | 184 | * less restrictive than URI_DANGEROUS_TO_LOAD but more restrictive than |
michael@0 | 185 | * URI_LOADABLE_BY_ANYONE. See the documentation for |
michael@0 | 186 | * nsIScriptSecurityManager::CheckLoadURI. |
michael@0 | 187 | */ |
michael@0 | 188 | const unsigned long URI_IS_UI_RESOURCE = (1<<8); |
michael@0 | 189 | |
michael@0 | 190 | /** |
michael@0 | 191 | * Loading of URIs for this protocol from other origins should only be |
michael@0 | 192 | * allowed if those origins should have access to the local filesystem. |
michael@0 | 193 | * It's up to the application to decide what origins should have such |
michael@0 | 194 | * access. Protocols like "file" that point to local data should set this |
michael@0 | 195 | * flag. |
michael@0 | 196 | */ |
michael@0 | 197 | const unsigned long URI_IS_LOCAL_FILE = (1<<9); |
michael@0 | 198 | |
michael@0 | 199 | /** |
michael@0 | 200 | * The URIs for this protocol can be loaded only by callers with a |
michael@0 | 201 | * principal that subsumes this uri. For example, privileged code and |
michael@0 | 202 | * websites that are same origin as this uri. |
michael@0 | 203 | */ |
michael@0 | 204 | const unsigned long URI_LOADABLE_BY_SUBSUMERS = (1<<10); |
michael@0 | 205 | |
michael@0 | 206 | /** |
michael@0 | 207 | * Channels using this protocol never call OnDataAvailable |
michael@0 | 208 | * on the listener passed to AsyncOpen and they therefore |
michael@0 | 209 | * do not return any data that we can use. |
michael@0 | 210 | */ |
michael@0 | 211 | const unsigned long URI_DOES_NOT_RETURN_DATA = (1<<11); |
michael@0 | 212 | |
michael@0 | 213 | /** |
michael@0 | 214 | * URIs for this protocol are considered to be local resources. This could |
michael@0 | 215 | * be a local file (URI_IS_LOCAL_FILE), a UI resource (URI_IS_UI_RESOURCE), |
michael@0 | 216 | * or something else that would not hit the network. |
michael@0 | 217 | */ |
michael@0 | 218 | const unsigned long URI_IS_LOCAL_RESOURCE = (1<<12); |
michael@0 | 219 | |
michael@0 | 220 | /** |
michael@0 | 221 | * URIs for this protocol execute script when they are opened. |
michael@0 | 222 | */ |
michael@0 | 223 | const unsigned long URI_OPENING_EXECUTES_SCRIPT = (1<<13); |
michael@0 | 224 | |
michael@0 | 225 | /** |
michael@0 | 226 | * Loading channels from this protocol has side-effects that make |
michael@0 | 227 | * it unsuitable for saving to a local file. |
michael@0 | 228 | */ |
michael@0 | 229 | const unsigned long URI_NON_PERSISTABLE = (1<<14); |
michael@0 | 230 | |
michael@0 | 231 | /** |
michael@0 | 232 | * This protocol handler forbids accessing cookies e.g. for mail related |
michael@0 | 233 | * protocols. |
michael@0 | 234 | */ |
michael@0 | 235 | const unsigned long URI_FORBIDS_COOKIE_ACCESS = (1<<15); |
michael@0 | 236 | |
michael@0 | 237 | /** |
michael@0 | 238 | * URIs for this protocol require the webapps permission on the principal |
michael@0 | 239 | * when opening URIs for a different domain. See bug#773886 |
michael@0 | 240 | */ |
michael@0 | 241 | const unsigned long URI_CROSS_ORIGIN_NEEDS_WEBAPPS_PERM = (1<<16); |
michael@0 | 242 | |
michael@0 | 243 | /** |
michael@0 | 244 | * Channels for this protocol don't need to spin the event loop to handle |
michael@0 | 245 | * Open() and reads on the resulting stream. |
michael@0 | 246 | */ |
michael@0 | 247 | const unsigned long URI_SYNC_LOAD_IS_OK = (1<<17); |
michael@0 | 248 | |
michael@0 | 249 | /** |
michael@0 | 250 | * URI is secure to load in an https page and should not be blocked |
michael@0 | 251 | * by nsMixedContentBlocker |
michael@0 | 252 | */ |
michael@0 | 253 | const unsigned long URI_SAFE_TO_LOAD_IN_SECURE_CONTEXT = (1<<18); |
michael@0 | 254 | |
michael@0 | 255 | |
michael@0 | 256 | }; |
michael@0 | 257 | |
michael@0 | 258 | %{C++ |
michael@0 | 259 | /** |
michael@0 | 260 | * Protocol handlers are registered with XPCOM under the following CONTRACTID prefix: |
michael@0 | 261 | */ |
michael@0 | 262 | #define NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "@mozilla.org/network/protocol;1?name=" |
michael@0 | 263 | /** |
michael@0 | 264 | * For example, "@mozilla.org/network/protocol;1?name=http" |
michael@0 | 265 | */ |
michael@0 | 266 | %} |