Bug 1685822 [wpt PR 27117] - [Import Maps] Add tests for rejecting multiple import...
[gecko.git] / dom / security / nsCSPService.h
blobf8c20c3b5a37c9863ab480a65f78bc9d1b5be2ea
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___
10 #include "nsXPCOM.h"
11 #include "nsIContentPolicy.h"
12 #include "nsIChannel.h"
13 #include "nsIChannelEventSink.h"
14 #include "nsDataHashtable.h"
16 #define CSPSERVICE_CONTRACTID "@mozilla.org/cspservice;1"
17 #define CSPSERVICE_CID \
18 { \
19 0x8d2f40b2, 0x4875, 0x4c95, { \
20 0x97, 0xd9, 0x3f, 0x7d, 0xca, 0x2c, 0xb4, 0x60 \
21 } \
23 class CSPService : public nsIContentPolicy, public nsIChannelEventSink {
24 public:
25 NS_DECL_ISUPPORTS
26 NS_DECL_NSICONTENTPOLICY
27 NS_DECL_NSICHANNELEVENTSINK
29 CSPService();
31 // helper function to avoid creating a new instance of the
32 // cspservice everytime we call content policies.
33 static nsresult ConsultCSP(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
34 const nsACString& aMimeTypeGuess,
35 int16_t* aDecision);
37 // Static helper to check CSP when doing a channel redirect.
38 // Returns the results to returns from
39 // AsyncOnChannelRedirect/nsIAsyncVerifyRedirectCallback. Optionally returns
40 // an nsresult to Cancel the old channel with.
41 static nsresult ConsultCSPForRedirect(nsIURI* aOriginalURI, nsIURI* aNewURI,
42 nsILoadInfo* aLoadInfo,
43 mozilla::Maybe<nsresult>& aCancelCode);
45 protected:
46 virtual ~CSPService();
48 #endif /* nsCSPService_h___ */