2014-07-10 00:35:02 +04: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 21:56:41 +03:00
|
|
|
#include "nsIContentPolicyBase.idl"
|
2014-07-10 00:35:02 +04:00
|
|
|
|
2015-02-19 04:34:29 +03:00
|
|
|
interface nsIChannel;
|
2015-11-03 22:20:56 +03:00
|
|
|
interface nsIConsoleReportCollector;
|
2014-07-10 00:35:02 +04:00
|
|
|
interface nsIOutputStream;
|
|
|
|
interface nsIURI;
|
|
|
|
|
2015-05-25 21:21:05 +03:00
|
|
|
%{C++
|
2015-10-30 05:53:25 +03:00
|
|
|
#include "nsIConsoleReportCollector.h"
|
2015-05-25 21:21:05 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class ChannelInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
|
|
|
[ptr] native ChannelInfo(mozilla::dom::ChannelInfo);
|
|
|
|
|
2014-07-10 00:35:02 +04: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-11-14 21:09:58 +03:00
|
|
|
[scriptable, uuid(231bb567-90e1-4973-9728-7dab93ab29a8)]
|
2014-07-10 00:35:02 +04:00
|
|
|
interface nsIInterceptedChannel : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Instruct a channel that has been intercepted to continue with the original
|
|
|
|
* network request.
|
|
|
|
*/
|
|
|
|
void resetInterception();
|
|
|
|
|
2015-03-17 18:48:30 +03: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-10 00:35:02 +04: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
|
2015-10-22 16:23:39 +03:00
|
|
|
* after this point. The caller may optionally pass a spec for a URL that
|
|
|
|
* this response originates from; an empty string will cause the original
|
|
|
|
* intercepted request's URL to be used instead.
|
2014-07-10 00:35:02 +04:00
|
|
|
*/
|
2015-10-22 16:23:39 +03:00
|
|
|
void finishSynthesizedResponse(in ACString finalURLSpec);
|
2015-02-19 04:34:29 +03: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 23:11:26 +03:00
|
|
|
void cancel(in nsresult status);
|
2015-02-19 04:34:29 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The synthesized response body to be produced.
|
|
|
|
*/
|
|
|
|
readonly attribute nsIOutputStream responseBody;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The underlying channel object that was intercepted.
|
|
|
|
*/
|
|
|
|
readonly attribute nsIChannel channel;
|
|
|
|
|
2015-03-05 02:27:33 +03:00
|
|
|
/**
|
2015-05-25 21:21:05 +03:00
|
|
|
* This method allows to override the channel info for the channel.
|
2015-03-05 02:27:33 +03:00
|
|
|
*/
|
2015-05-25 21:21:05 +03:00
|
|
|
[noscript]
|
|
|
|
void setChannelInfo(in ChannelInfo channelInfo);
|
2015-09-17 21:56:41 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the internal load type from the underlying channel.
|
|
|
|
*/
|
|
|
|
[noscript]
|
|
|
|
readonly attribute nsContentPolicyType internalContentPolicyType;
|
2015-10-30 05:53:25 +03:00
|
|
|
|
2015-11-03 22:20:56 +03:00
|
|
|
[noscript]
|
|
|
|
readonly attribute nsIConsoleReportCollector consoleReportCollector;
|
|
|
|
|
2015-10-30 05:53:25 +03:00
|
|
|
%{C++
|
2015-11-03 22:20:56 +03:00
|
|
|
already_AddRefed<nsIConsoleReportCollector>
|
|
|
|
GetConsoleReportCollector()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIConsoleReportCollector> reporter;
|
|
|
|
GetConsoleReportCollector(getter_AddRefs(reporter));
|
|
|
|
return reporter.forget();
|
|
|
|
}
|
2015-10-30 05:53:25 +03:00
|
|
|
%}
|
2014-07-10 00:35:02 +04:00
|
|
|
};
|
|
|
|
|
2015-09-22 00:10:37 +03: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-10 00:35:02 +04: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-10-07 05:40:36 +03:00
|
|
|
[scriptable, uuid(49eb1997-90fb-49d6-a25d-41f51c7c99e8)]
|
2014-07-10 00:35:02 +04: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 04:34:29 +03:00
|
|
|
* @param aIsNavigate True if the request is for a navigation, false for a fetch.
|
2014-07-10 00:35:02 +04:00
|
|
|
*/
|
2015-10-07 05:40:36 +03:00
|
|
|
bool shouldPrepareForIntercept(in nsIURI aURI, in bool aIsNonSubresourceRequest);
|
2014-07-10 00:35:02 +04: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-22 00:10:37 +03:00
|
|
|
nsIFetchEventDispatcher channelIntercepted(in nsIInterceptedChannel aChannel);
|
2014-07-10 00:35:02 +04:00
|
|
|
};
|