2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-06-08 01:33:30 +04:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
2020-12-16 14:36:47 +03:00
|
|
|
#include "nsIContentPolicy.idl"
|
1999-06-08 01:33:30 +04:00
|
|
|
|
|
|
|
interface nsIProtocolHandler;
|
2001-04-10 10:01:08 +04:00
|
|
|
interface nsIChannel;
|
1999-06-08 01:33:30 +04:00
|
|
|
interface nsIURI;
|
2001-06-22 02:02:47 +04:00
|
|
|
interface nsIFile;
|
2014-10-23 04:20:12 +04:00
|
|
|
interface nsIPrincipal;
|
2014-12-13 01:24:57 +03:00
|
|
|
interface nsILoadInfo;
|
1999-06-08 01:33:30 +04:00
|
|
|
|
2018-05-30 05:58:48 +03:00
|
|
|
webidl Node;
|
|
|
|
|
2018-01-23 18:38:54 +03:00
|
|
|
%{C++
|
|
|
|
#include "mozilla/Maybe.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class ClientInfo;
|
|
|
|
class ServiceWorkerDescriptor;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
%}
|
|
|
|
|
|
|
|
[ref] native const_MaybeClientInfoRef(const mozilla::Maybe<mozilla::dom::ClientInfo>);
|
|
|
|
[ref] native const_MaybeServiceWorkerDescriptorRef(const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>);
|
|
|
|
|
2002-08-15 22:38:46 +04:00
|
|
|
/**
|
2002-10-29 22:43:00 +03:00
|
|
|
* nsIIOService provides a set of network utility functions. This interface
|
2002-08-15 22:38:46 +04:00
|
|
|
* duplicates many of the nsIProtocolHandler methods in a protocol handler
|
2002-10-29 22:43:00 +03:00
|
|
|
* independent way (e.g., NewURI inspects the scheme in order to delegate
|
|
|
|
* creation of the new URI to the appropriate protocol handler). nsIIOService
|
|
|
|
* also provides a set of URL parsing utility functions. These are provided
|
|
|
|
* as a convenience to the programmer and in some cases to improve performance
|
|
|
|
* by eliminating intermediate data structures and interfaces.
|
2002-08-15 22:38:46 +04:00
|
|
|
*/
|
2019-05-13 22:51:49 +03:00
|
|
|
[scriptable, builtinclass, uuid(4286de5a-b2ea-446f-8f70-e2a461f42694)]
|
1999-06-08 01:33:30 +04:00
|
|
|
interface nsIIOService : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Returns a protocol handler for a given URI scheme.
|
2001-09-08 16:47:05 +04:00
|
|
|
*
|
2002-08-15 22:38:46 +04:00
|
|
|
* @param aScheme the URI scheme
|
|
|
|
* @return reference to corresponding nsIProtocolHandler
|
1999-06-08 01:33:30 +04:00
|
|
|
*/
|
2002-08-15 22:38:46 +04:00
|
|
|
nsIProtocolHandler getProtocolHandler(in string aScheme);
|
1999-06-08 01:33:30 +04:00
|
|
|
|
2001-08-08 00:42:57 +04:00
|
|
|
/**
|
2001-09-13 06:21:05 +04:00
|
|
|
* Returns the protocol flags for a given scheme.
|
2001-08-08 14:03:29 +04:00
|
|
|
*
|
2002-08-15 22:38:46 +04:00
|
|
|
* @param aScheme the URI scheme
|
|
|
|
* @return value of corresponding nsIProtocolHandler::protocolFlags
|
2001-08-08 00:42:57 +04:00
|
|
|
*/
|
2002-08-15 22:38:46 +04:00
|
|
|
unsigned long getProtocolFlags(in string aScheme);
|
2001-08-08 00:42:57 +04:00
|
|
|
|
1999-06-08 01:33:30 +04:00
|
|
|
/**
|
2002-10-29 22:43:00 +03:00
|
|
|
* This method constructs a new URI by determining the scheme of the
|
|
|
|
* URI spec, and then delegating the construction of the URI to the
|
|
|
|
* protocol handler for that scheme. QueryInterface can be used on
|
|
|
|
* the resulting URI object to obtain a more specific type of URI.
|
2002-08-15 22:38:46 +04:00
|
|
|
*
|
2002-03-06 10:48:55 +03:00
|
|
|
* @see nsIProtocolHandler::newURI
|
1999-06-08 01:33:30 +04:00
|
|
|
*/
|
2002-03-06 10:48:55 +03:00
|
|
|
nsIURI newURI(in AUTF8String aSpec,
|
2017-01-09 22:27:24 +03:00
|
|
|
[optional] in string aOriginCharset,
|
|
|
|
[optional] in nsIURI aBaseURI);
|
1999-06-08 01:33:30 +04:00
|
|
|
|
2001-06-22 02:02:47 +04:00
|
|
|
/**
|
2002-08-15 22:38:46 +04:00
|
|
|
* This method constructs a new URI from a nsIFile.
|
2001-06-22 02:02:47 +04:00
|
|
|
*
|
2002-08-15 22:38:46 +04:00
|
|
|
* @param aFile specifies the file path
|
2002-03-06 10:48:55 +03:00
|
|
|
* @return reference to a new nsIURI object
|
2009-10-17 03:59:02 +04:00
|
|
|
*
|
|
|
|
* Note: in the future, for perf reasons we should allow
|
|
|
|
* callers to specify whether this is a file or directory by
|
|
|
|
* splitting this into newDirURI() and newActualFileURI().
|
2001-06-22 02:02:47 +04:00
|
|
|
*/
|
2002-03-06 10:48:55 +03:00
|
|
|
nsIURI newFileURI(in nsIFile aFile);
|
2001-06-22 02:02:47 +04:00
|
|
|
|
2020-03-13 15:44:36 +03:00
|
|
|
/**
|
|
|
|
* Converts an internal URI (e.g. one that has a username and password in
|
|
|
|
* it) into one which we can expose to the user, for example on the URL bar.
|
|
|
|
*
|
|
|
|
* @param aURI The URI to be converted.
|
|
|
|
* @return nsIURI The converted, exposable URI.
|
|
|
|
*/
|
|
|
|
nsIURI createExposableURI(in nsIURI aURI);
|
|
|
|
|
2014-10-23 04:20:12 +04:00
|
|
|
/**
|
|
|
|
* Creates a channel for a given URI.
|
|
|
|
*
|
2014-12-12 20:05:21 +03:00
|
|
|
* @param aURI
|
|
|
|
* nsIURI from which to make a channel
|
|
|
|
* @param aLoadingNode
|
|
|
|
* @param aLoadingPrincipal
|
|
|
|
* @param aTriggeringPrincipal
|
|
|
|
* @param aSecurityFlags
|
|
|
|
* @param aContentPolicyType
|
2016-09-20 09:34:40 +03:00
|
|
|
* These will be used as values for the nsILoadInfo object on the
|
|
|
|
* created channel. For details, see nsILoadInfo in nsILoadInfo.idl
|
2014-10-23 04:20:12 +04:00
|
|
|
* @return reference to the new nsIChannel object
|
2014-12-12 20:05:21 +03:00
|
|
|
*
|
2014-12-13 00:45:51 +03:00
|
|
|
* Please note, if you provide both a loadingNode and a loadingPrincipal,
|
|
|
|
* then loadingPrincipal must be equal to loadingNode->NodePrincipal().
|
|
|
|
* But less error prone is to just supply a loadingNode.
|
2015-01-07 04:01:07 +03:00
|
|
|
*
|
|
|
|
* Keep in mind that URIs coming from a webpage should *never* use the
|
|
|
|
* systemPrincipal as the loadingPrincipal.
|
2014-10-23 04:20:12 +04:00
|
|
|
*/
|
2019-02-21 14:48:20 +03:00
|
|
|
nsIChannel newChannelFromURI(in nsIURI aURI,
|
|
|
|
in Node aLoadingNode,
|
|
|
|
in nsIPrincipal aLoadingPrincipal,
|
|
|
|
in nsIPrincipal aTriggeringPrincipal,
|
|
|
|
in unsigned long aSecurityFlags,
|
2020-12-16 14:36:47 +03:00
|
|
|
in nsContentPolicyType aContentPolicyType);
|
2014-10-23 04:20:12 +04:00
|
|
|
|
2018-01-23 18:38:54 +03:00
|
|
|
[noscript, nostdcall, notxpcom]
|
|
|
|
nsresult NewChannelFromURIWithClientAndController(in nsIURI aURI,
|
2018-05-30 05:58:48 +03:00
|
|
|
in Node aLoadingNode,
|
2018-01-23 18:38:54 +03:00
|
|
|
in nsIPrincipal aLoadingPrincipal,
|
|
|
|
in nsIPrincipal aTriggeringPrincipal,
|
|
|
|
in const_MaybeClientInfoRef aLoadingClientInfo,
|
|
|
|
in const_MaybeServiceWorkerDescriptorRef aController,
|
|
|
|
in unsigned long aSecurityFlags,
|
2020-12-16 14:36:47 +03:00
|
|
|
in nsContentPolicyType aContentPolicyType,
|
2020-01-15 11:02:57 +03:00
|
|
|
in unsigned long aSandboxFlags,
|
2018-01-23 18:38:54 +03:00
|
|
|
out nsIChannel aResult);
|
|
|
|
|
2014-12-13 01:24:57 +03:00
|
|
|
/**
|
2019-02-21 14:48:20 +03:00
|
|
|
* Equivalent to newChannelFromURI(aURI, aLoadingNode, ...)
|
2014-12-13 01:24:57 +03:00
|
|
|
*/
|
|
|
|
nsIChannel newChannelFromURIWithLoadInfo(in nsIURI aURI,
|
|
|
|
in nsILoadInfo aLoadInfo);
|
|
|
|
|
1999-06-08 01:33:30 +04:00
|
|
|
/**
|
2019-02-21 14:48:20 +03:00
|
|
|
* Equivalent to newChannelFromURI(newURI(...))
|
2014-10-23 04:20:12 +04:00
|
|
|
*/
|
2019-02-21 14:48:20 +03:00
|
|
|
nsIChannel newChannel(in AUTF8String aSpec,
|
|
|
|
in string aOriginCharset,
|
|
|
|
in nsIURI aBaseURI,
|
|
|
|
in Node aLoadingNode,
|
|
|
|
in nsIPrincipal aLoadingPrincipal,
|
|
|
|
in nsIPrincipal aTriggeringPrincipal,
|
|
|
|
in unsigned long aSecurityFlags,
|
2020-12-16 14:36:47 +03:00
|
|
|
in nsContentPolicyType aContentPolicyType);
|
2014-10-23 04:20:12 +04:00
|
|
|
|
2000-01-27 11:57:14 +03:00
|
|
|
/**
|
2001-09-08 16:47:05 +04:00
|
|
|
* Returns true if networking is in "offline" mode. When in offline mode,
|
2005-11-21 09:01:10 +03:00
|
|
|
* attempts to access the network will fail (although this does not
|
|
|
|
* necessarily correlate with whether there is actually a network
|
2001-09-08 16:47:05 +04:00
|
|
|
* available -- that's hard to detect without causing the dialer to
|
|
|
|
* come up).
|
2006-04-05 01:26:17 +04:00
|
|
|
*
|
|
|
|
* Changing this fires observer notifications ... see below.
|
2000-01-27 11:57:14 +03:00
|
|
|
*/
|
|
|
|
attribute boolean offline;
|
|
|
|
|
2015-05-02 00:14:39 +03:00
|
|
|
/**
|
|
|
|
* Returns false if there are no interfaces for a network request
|
|
|
|
*/
|
|
|
|
readonly attribute boolean connectivity;
|
|
|
|
|
2001-06-06 04:10:09 +04:00
|
|
|
/**
|
2002-10-29 22:43:00 +03:00
|
|
|
* Checks if a port number is banned. This involves consulting a list of
|
|
|
|
* unsafe ports, corresponding to network services that may be easily
|
|
|
|
* exploitable. If the given port is considered unsafe, then the protocol
|
|
|
|
* handler (corresponding to aScheme) will be asked whether it wishes to
|
|
|
|
* override the IO service's decision to block the port. This gives the
|
|
|
|
* protocol handler ultimate control over its own security policy while
|
|
|
|
* ensuring reasonable, default protection.
|
2001-06-06 04:10:09 +04:00
|
|
|
*
|
2002-08-15 22:38:46 +04:00
|
|
|
* @see nsIProtocolHandler::allowPort
|
2001-06-06 04:10:09 +04:00
|
|
|
*/
|
2002-08-15 22:38:46 +04:00
|
|
|
boolean allowPort(in long aPort, in string aScheme);
|
2001-06-06 04:10:09 +04:00
|
|
|
|
2002-03-06 10:48:55 +03:00
|
|
|
/**
|
2002-08-15 22:38:46 +04:00
|
|
|
* Utility to extract the scheme from a URL string, consistently and
|
|
|
|
* according to spec (see RFC 2396).
|
2002-03-06 10:48:55 +03:00
|
|
|
*
|
2002-09-13 23:32:45 +04:00
|
|
|
* NOTE: Most URL parsing is done via nsIURI, and in fact the scheme
|
|
|
|
* can also be extracted from a URL string via nsIURI. This method
|
|
|
|
* is provided purely as an optimization.
|
|
|
|
*
|
2002-08-15 22:38:46 +04:00
|
|
|
* @param aSpec the URL string to parse
|
2018-02-26 18:42:27 +03:00
|
|
|
* @return URL scheme, lowercase
|
2001-11-16 05:09:13 +03:00
|
|
|
*
|
2002-08-15 22:38:46 +04:00
|
|
|
* @throws NS_ERROR_MALFORMED_URI if URL string is not of the right form.
|
2000-03-29 07:58:50 +04:00
|
|
|
*/
|
2002-08-15 22:38:46 +04:00
|
|
|
ACString extractScheme(in AUTF8String urlString);
|
2017-03-31 23:39:45 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if a URI host is a local IPv4 or IPv6 address literal.
|
|
|
|
*
|
|
|
|
* @param nsIURI the URI that contains the hostname to check
|
|
|
|
* @return true if the URI hostname is a local IP address
|
|
|
|
*/
|
|
|
|
boolean hostnameIsLocalIPAddress(in nsIURI aURI);
|
2017-11-10 17:03:36 +03:00
|
|
|
|
2019-08-28 13:58:48 +03:00
|
|
|
/**
|
|
|
|
* Checks if a URI host is a shared IPv4 address literal.
|
|
|
|
*
|
|
|
|
* @param nsIURI the URI that contains the hostname to check
|
|
|
|
* @return true if the URI hostname is a shared IP address
|
|
|
|
*/
|
|
|
|
boolean hostnameIsSharedIPAddress(in nsIURI aURI);
|
|
|
|
|
2017-11-10 17:03:36 +03:00
|
|
|
/**
|
|
|
|
* While this is set, IOService will monitor an nsINetworkLinkService
|
|
|
|
* (if available) and set its offline status to "true" whenever
|
|
|
|
* isLinkUp is false.
|
|
|
|
*
|
|
|
|
* Applications that want to control changes to the IOService's offline
|
|
|
|
* status should set this to false, watch for network:link-status-changed
|
|
|
|
* broadcasts, and change nsIIOService::offline as they see fit. Note
|
|
|
|
* that this means during application startup, IOService may be offline
|
|
|
|
* if there is no link, until application code runs and can turn off
|
|
|
|
* this management.
|
|
|
|
*/
|
|
|
|
attribute boolean manageOfflineStatus;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a channel for a given URI.
|
|
|
|
*
|
|
|
|
* @param aURI
|
|
|
|
* nsIURI from which to make a channel
|
|
|
|
* @param aProxyURI
|
|
|
|
* nsIURI to use for proxy resolution. Can be null in which
|
|
|
|
* case aURI is used
|
|
|
|
* @param aProxyFlags flags from nsIProtocolProxyService to use
|
|
|
|
* when resolving proxies for this new channel
|
|
|
|
* @param aLoadingNode
|
|
|
|
* @param aLoadingPrincipal
|
|
|
|
* @param aTriggeringPrincipal
|
|
|
|
* @param aSecurityFlags
|
|
|
|
* @param aContentPolicyType
|
|
|
|
* These will be used as values for the nsILoadInfo object on the
|
|
|
|
* created channel. For details, see nsILoadInfo in nsILoadInfo.idl
|
|
|
|
* @return reference to the new nsIChannel object
|
|
|
|
*
|
|
|
|
* Please note, if you provide both a loadingNode and a loadingPrincipal,
|
|
|
|
* then loadingPrincipal must be equal to loadingNode->NodePrincipal().
|
|
|
|
* But less error prone is to just supply a loadingNode.
|
|
|
|
*/
|
2019-02-21 14:48:20 +03:00
|
|
|
nsIChannel newChannelFromURIWithProxyFlags(in nsIURI aURI,
|
|
|
|
in nsIURI aProxyURI,
|
|
|
|
in unsigned long aProxyFlags,
|
|
|
|
in Node aLoadingNode,
|
|
|
|
in nsIPrincipal aLoadingPrincipal,
|
|
|
|
in nsIPrincipal aTriggeringPrincipal,
|
|
|
|
in unsigned long aSecurityFlags,
|
2020-12-16 14:36:47 +03:00
|
|
|
in nsContentPolicyType aContentPolicyType);
|
2020-04-06 13:43:28 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if socket process is launched.
|
|
|
|
*/
|
|
|
|
readonly attribute boolean socketProcessLaunched;
|
2022-02-23 14:55:59 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The pid for socket process.
|
|
|
|
*/
|
|
|
|
readonly attribute unsigned long long socketProcessId;
|
1999-06-08 01:33:30 +04:00
|
|
|
};
|
2006-04-05 01:26:17 +04:00
|
|
|
|
|
|
|
%{C++
|
|
|
|
/**
|
|
|
|
* We send notifications through nsIObserverService with topic
|
|
|
|
* NS_IOSERVICE_GOING_OFFLINE_TOPIC and data NS_IOSERVICE_OFFLINE
|
|
|
|
* when 'offline' has changed from false to true, and we are about
|
|
|
|
* to shut down network services such as DNS. When those
|
|
|
|
* services have been shut down, we send a notification with
|
|
|
|
* topic NS_IOSERVICE_OFFLINE_STATUS_TOPIC and data
|
|
|
|
* NS_IOSERVICE_OFFLINE.
|
|
|
|
*
|
|
|
|
* When 'offline' changes from true to false, then after
|
|
|
|
* network services have been restarted, we send a notification
|
|
|
|
* with topic NS_IOSERVICE_OFFLINE_STATUS_TOPIC and data
|
|
|
|
* NS_IOSERVICE_ONLINE.
|
|
|
|
*/
|
|
|
|
#define NS_IOSERVICE_GOING_OFFLINE_TOPIC "network:offline-about-to-go-offline"
|
|
|
|
#define NS_IOSERVICE_OFFLINE_STATUS_TOPIC "network:offline-status-changed"
|
|
|
|
#define NS_IOSERVICE_OFFLINE "offline"
|
|
|
|
#define NS_IOSERVICE_ONLINE "online"
|
2014-08-23 07:05:56 +04:00
|
|
|
|
2006-04-05 01:26:17 +04:00
|
|
|
%}
|
2015-05-02 00:14:39 +03:00
|
|
|
|
2015-07-31 23:39:48 +03:00
|
|
|
[builtinclass, uuid(6633c0bf-d97a-428f-8ece-cb6a655fb95a)]
|
2015-05-02 00:14:39 +03:00
|
|
|
interface nsIIOServiceInternal : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* This is an internal method that should only be called from ContentChild
|
|
|
|
* in order to pass the connectivity state from the chrome process to the
|
|
|
|
* content process. It throws if called outside the content process.
|
|
|
|
*/
|
|
|
|
void SetConnectivity(in boolean connectivity);
|
2015-07-31 23:39:48 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An internal method to asynchronously run our notifications that happen
|
|
|
|
* when we wake from sleep
|
|
|
|
*/
|
|
|
|
void NotifyWakeup();
|
2015-05-02 00:14:39 +03:00
|
|
|
};
|