2014-07-09 20:35:02 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; 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"
|
2015-09-17 18:56:41 +00:00
|
|
|
#include "nsIContentPolicyBase.idl"
|
2014-07-09 20:35:02 +00:00
|
|
|
|
2015-02-19 01:34:29 +00:00
|
|
|
interface nsIChannel;
|
2014-07-09 20:35:02 +00:00
|
|
|
interface nsIOutputStream;
|
|
|
|
interface nsIURI;
|
|
|
|
|
2015-05-25 18:21:05 +00:00
|
|
|
%{C++
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class ChannelInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
|
|
|
[ptr] native ChannelInfo(mozilla::dom::ChannelInfo);
|
|
|
|
|
2014-07-09 20:35:02 +00:00
|
|
|
/**
|
|
|
|
* Interface to allow implementors of nsINetworkInterceptController to control the behaviour
|
|
|
|
* of intercepted channels without tying implementation details of the interception to
|
|
|
|
* the actual channel. nsIInterceptedChannel is expected to be implemented by objects
|
|
|
|
* which do not implement nsIChannel.
|
|
|
|
*/
|
|
|
|
|
2015-09-17 18:56:41 +00:00
|
|
|
[scriptable, uuid(91d430cc-7e04-4df1-a3c0-879fa30f7ab9)]
|
2014-07-09 20:35:02 +00:00
|
|
|
interface nsIInterceptedChannel : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Instruct a channel that has been intercepted to continue with the original
|
|
|
|
* network request.
|
|
|
|
*/
|
|
|
|
void resetInterception();
|
|
|
|
|
2015-03-17 15:48:30 +00:00
|
|
|
/**
|
|
|
|
* Set the status and reason for the forthcoming synthesized response.
|
|
|
|
* Multiple calls overwrite existing values.
|
|
|
|
*/
|
|
|
|
void synthesizeStatus(in uint16_t status, in ACString reason);
|
|
|
|
|
2014-07-09 20:35:02 +00:00
|
|
|
/**
|
|
|
|
* Attach a header name/value pair to the forthcoming synthesized response.
|
|
|
|
* Overwrites any existing header value.
|
|
|
|
*/
|
|
|
|
void synthesizeHeader(in ACString name, in ACString value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instruct a channel that has been intercepted that a response has been
|
|
|
|
* synthesized and can now be read. No further header modification is allowed
|
|
|
|
* after this point.
|
|
|
|
*/
|
|
|
|
void finishSynthesizedResponse();
|
2015-02-19 01:34:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancel the pending intercepted request.
|
|
|
|
* @return NS_ERROR_FAILURE if the response has already been synthesized or
|
|
|
|
* the original request has been instructed to continue.
|
|
|
|
*/
|
2015-07-14 20:11:26 +00:00
|
|
|
void cancel(in nsresult status);
|
2015-02-19 01:34:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The synthesized response body to be produced.
|
|
|
|
*/
|
|
|
|
readonly attribute nsIOutputStream responseBody;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The underlying channel object that was intercepted.
|
|
|
|
*/
|
|
|
|
readonly attribute nsIChannel channel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the underlying request was caused by a navigation attempt.
|
|
|
|
*/
|
|
|
|
readonly attribute bool isNavigation;
|
2015-03-04 23:27:33 +00:00
|
|
|
|
|
|
|
/**
|
2015-05-25 18:21:05 +00:00
|
|
|
* This method allows to override the channel info for the channel.
|
2015-03-04 23:27:33 +00:00
|
|
|
*/
|
2015-05-25 18:21:05 +00:00
|
|
|
[noscript]
|
|
|
|
void setChannelInfo(in ChannelInfo channelInfo);
|
2015-09-17 18:56:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the internal load type from the underlying channel.
|
|
|
|
*/
|
|
|
|
[noscript]
|
|
|
|
readonly attribute nsContentPolicyType internalContentPolicyType;
|
2014-07-09 20:35:02 +00:00
|
|
|
};
|
|
|
|
|
2015-09-21 21:10:37 +00:00
|
|
|
/**
|
|
|
|
* Interface to allow consumers to dispatch the fetch event asynchronously.
|
|
|
|
* Consumers get access to this interface by calling channelIntercepted(),
|
|
|
|
* and they can choose to either dispatch() immediately or do that at some
|
|
|
|
* later time.
|
|
|
|
*/
|
|
|
|
|
|
|
|
[scriptable, uuid(799504e4-36f8-4ab5-b9d2-53f0c0c40c04)]
|
|
|
|
interface nsIFetchEventDispatcher : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Actually dispatches the fetch event to the service worker.
|
|
|
|
*/
|
|
|
|
void dispatch();
|
|
|
|
};
|
|
|
|
|
2014-07-09 20:35:02 +00:00
|
|
|
/**
|
|
|
|
* Interface to allow consumers to attach themselves to a channel's
|
|
|
|
* notification callbacks/loadgroup and determine if a given channel
|
|
|
|
* request should be intercepted before any network request is initiated.
|
|
|
|
*/
|
|
|
|
|
2015-09-17 18:56:41 +00:00
|
|
|
[scriptable, uuid(7157fe12-20e3-45db-b09e-68fdf6d0614f)]
|
2014-07-09 20:35:02 +00:00
|
|
|
interface nsINetworkInterceptController : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Returns true if a channel should avoid initiating any network
|
|
|
|
* requests until specifically instructed to do so.
|
|
|
|
*
|
|
|
|
* @param aURI the URI being requested by a channel
|
2015-02-19 01:34:29 +00:00
|
|
|
* @param aIsNavigate True if the request is for a navigation, false for a fetch.
|
2014-07-09 20:35:02 +00:00
|
|
|
*/
|
2015-09-17 18:56:41 +00:00
|
|
|
bool shouldPrepareForIntercept(in nsIURI aURI, in bool aIsNavigate, in nsContentPolicyType aType);
|
2014-07-09 20:35:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Notification when a given intercepted channel is prepared to accept a synthesized
|
|
|
|
* response via the provided stream.
|
|
|
|
*
|
|
|
|
* @param aChannel the controlling interface for a channel that has been intercepted
|
|
|
|
*/
|
2015-09-21 21:10:37 +00:00
|
|
|
nsIFetchEventDispatcher channelIntercepted(in nsIInterceptedChannel aChannel);
|
2014-07-09 20:35:02 +00:00
|
|
|
};
|