1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsCSPService_h___
8 #define nsCSPService_h___
11 #include "nsIContentPolicy.h"
12 #include "nsIChannel.h"
13 #include "nsIChannelEventSink.h"
15 #define CSPSERVICE_CONTRACTID "@mozilla.org/cspservice;1"
16 #define CSPSERVICE_CID \
18 0x8d2f40b2, 0x4875, 0x4c95, { \
19 0x97, 0xd9, 0x3f, 0x7d, 0xca, 0x2c, 0xb4, 0x60 \
22 class CSPService
: public nsIContentPolicy
, public nsIChannelEventSink
{
25 NS_DECL_NSICONTENTPOLICY
26 NS_DECL_NSICHANNELEVENTSINK
30 // helper function to avoid creating a new instance of the
31 // cspservice everytime we call content policies.
32 static nsresult
ConsultCSP(nsIURI
* aContentLocation
, nsILoadInfo
* aLoadInfo
,
35 // Static helper to check CSP when doing a channel redirect.
36 // Returns the results to returns from
37 // AsyncOnChannelRedirect/nsIAsyncVerifyRedirectCallback. Optionally returns
38 // an nsresult to Cancel the old channel with.
39 static nsresult
ConsultCSPForRedirect(nsIURI
* aOriginalURI
, nsIURI
* aNewURI
,
40 nsILoadInfo
* aLoadInfo
,
41 mozilla::Maybe
<nsresult
>& aCancelCode
);
44 virtual ~CSPService();
46 #endif /* nsCSPService_h___ */