nsCSPService.h (1600B)
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/. */ 6 7 #ifndef nsCSPService_h___ 8 #define nsCSPService_h___ 9 10 #include "nsIChannel.h" 11 #include "nsIChannelEventSink.h" 12 #include "nsIContentPolicy.h" 13 #include "nsXPCOM.h" 14 15 #define CSPSERVICE_CONTRACTID "@mozilla.org/cspservice;1" 16 #define CSPSERVICE_CID \ 17 {0x8d2f40b2, 0x4875, 0x4c95, {0x97, 0xd9, 0x3f, 0x7d, 0xca, 0x2c, 0xb4, 0x60}} 18 class CSPService : public nsIContentPolicy, public nsIChannelEventSink { 19 public: 20 NS_DECL_ISUPPORTS 21 NS_DECL_NSICONTENTPOLICY 22 NS_DECL_NSICHANNELEVENTSINK 23 24 CSPService(); 25 26 // helper function to avoid creating a new instance of the 27 // cspservice everytime we call content policies. 28 static nsresult ConsultCSP(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo, 29 int16_t* aDecision); 30 31 // Static helper to check CSP when doing a channel redirect. 32 // Returns the results to returns from 33 // AsyncOnChannelRedirect/nsIAsyncVerifyRedirectCallback. Optionally returns 34 // an nsresult to Cancel the old channel with. 35 static nsresult ConsultCSPForRedirect(nsIURI* aOriginalURI, nsIURI* aNewURI, 36 nsILoadInfo* aLoadInfo, 37 mozilla::Maybe<nsresult>& aCancelCode); 38 39 protected: 40 virtual ~CSPService(); 41 }; 42 #endif /* nsCSPService_h___ */