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