1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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/. */
#include "nsISupports.idl"
#include "nsIContentPolicy.idl"
interface nsIProtocolHandler;
interface nsIChannel;
interface nsIURI;
interface nsIFile;
interface nsIPrincipal;
interface nsILoadInfo;
webidl Node;
%{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>);
/**
* nsIIOService provides a set of network utility functions. This interface
* duplicates many of the nsIProtocolHandler methods in a protocol handler
* 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.
*/
[scriptable, builtinclass, uuid(4286de5a-b2ea-446f-8f70-e2a461f42694)]
interface nsIIOService : nsISupports
{
/**
* Returns a protocol handler for a given URI scheme.
*
* @param aScheme the URI scheme
* @return reference to corresponding nsIProtocolHandler
*/
nsIProtocolHandler getProtocolHandler(in string aScheme);
/**
* Returns the protocol flags for a given scheme.
*
* @param aScheme the URI scheme
* @return value of corresponding nsIProtocolHandler::protocolFlags
*/
unsigned long getProtocolFlags(in string aScheme);
/**
* 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.
*
* @see nsIProtocolHandler::newURI
*/
nsIURI newURI(in AUTF8String aSpec,
[optional] in string aOriginCharset,
[optional] in nsIURI aBaseURI);
/**
* This method constructs a new URI from a nsIFile.
*
* @param aFile specifies the file path
* @return reference to a new nsIURI object
*
* 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().
*/
nsIURI newFileURI(in nsIFile aFile);
/**
* 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);
/**
* Creates a channel for a given URI.
*
* @param aURI
* nsIURI from which to make a 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.
*
* Keep in mind that URIs coming from a webpage should *never* use the
* systemPrincipal as the loadingPrincipal.
*/
nsIChannel newChannelFromURI(in nsIURI aURI,
in Node aLoadingNode,
in nsIPrincipal aLoadingPrincipal,
in nsIPrincipal aTriggeringPrincipal,
in unsigned long aSecurityFlags,
in nsContentPolicyType aContentPolicyType);
[noscript, nostdcall, notxpcom]
nsresult NewChannelFromURIWithClientAndController(in nsIURI aURI,
in Node aLoadingNode,
in nsIPrincipal aLoadingPrincipal,
in nsIPrincipal aTriggeringPrincipal,
in const_MaybeClientInfoRef aLoadingClientInfo,
in const_MaybeServiceWorkerDescriptorRef aController,
in unsigned long aSecurityFlags,
in nsContentPolicyType aContentPolicyType,
in unsigned long aSandboxFlags,
out nsIChannel aResult);
/**
* Equivalent to newChannelFromURI(aURI, aLoadingNode, ...)
*/
nsIChannel newChannelFromURIWithLoadInfo(in nsIURI aURI,
in nsILoadInfo aLoadInfo);
/**
* Equivalent to newChannelFromURI(newURI(...))
*/
nsIChannel newChannel(in AUTF8String aSpec,
in string aOriginCharset,
in nsIURI aBaseURI,
in Node aLoadingNode,
in nsIPrincipal aLoadingPrincipal,
in nsIPrincipal aTriggeringPrincipal,
in unsigned long aSecurityFlags,
in nsContentPolicyType aContentPolicyType);
/**
* Returns true if networking is in "offline" mode. When in offline mode,
* attempts to access the network will fail (although this does not
* necessarily correlate with whether there is actually a network
* available -- that's hard to detect without causing the dialer to
* come up).
*
* Changing this fires observer notifications ... see below.
*/
attribute boolean offline;
/**
* Returns false if there are no interfaces for a network request
*/
readonly attribute boolean connectivity;
/**
* 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.
*
* @see nsIProtocolHandler::allowPort
*/
boolean allowPort(in long aPort, in string aScheme);
/**
* Utility to extract the scheme from a URL string, consistently and
* according to spec (see RFC 2396).
*
* 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.
*
* @param aSpec the URL string to parse
* @return URL scheme, lowercase
*
* @throws NS_ERROR_MALFORMED_URI if URL string is not of the right form.
*/
ACString extractScheme(in AUTF8String urlString);
/**
* 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);
/**
* 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);
/**
* 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.
*/
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,
in nsContentPolicyType aContentPolicyType);
/**
* Return true if socket process is launched.
*/
readonly attribute boolean socketProcessLaunched;
};
%{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"
%}
[builtinclass, uuid(6633c0bf-d97a-428f-8ece-cb6a655fb95a)]
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);
/**
* An internal method to asynchronously run our notifications that happen
* when we wake from sleep
*/
void NotifyWakeup();
};
|