1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/src/nsContentPolicy.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +// vim: ft=cpp ts=8 sw=4 et tw=78 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef __nsContentPolicy_h__ 1.11 +#define __nsContentPolicy_h__ 1.12 + 1.13 +#include "nsIContentPolicy.h" 1.14 +#include "nsCategoryCache.h" 1.15 + 1.16 +/* 1.17 + * Implementation of the "@mozilla.org/layout/content-policy;1" contract. 1.18 + */ 1.19 + 1.20 +class nsContentPolicy : public nsIContentPolicy 1.21 +{ 1.22 + public: 1.23 + NS_DECL_ISUPPORTS 1.24 + NS_DECL_NSICONTENTPOLICY 1.25 + 1.26 + nsContentPolicy(); 1.27 + virtual ~nsContentPolicy(); 1.28 + private: 1.29 + //Array of policies 1.30 + nsCategoryCache<nsIContentPolicy> mPolicies; 1.31 + 1.32 + //Helper type for CheckPolicy 1.33 + typedef 1.34 + NS_STDCALL_FUNCPROTO(nsresult, CPMethod, nsIContentPolicy, 1.35 + ShouldProcess, 1.36 + (uint32_t, nsIURI*, nsIURI*, nsISupports*, 1.37 + const nsACString &, nsISupports*, nsIPrincipal*, 1.38 + int16_t*)); 1.39 + 1.40 + //Helper method that applies policyMethod across all policies in mPolicies 1.41 + // with the given parameters 1.42 + nsresult CheckPolicy(CPMethod policyMethod, uint32_t contentType, 1.43 + nsIURI *aURI, nsIURI *origURI, 1.44 + nsISupports *requestingContext, 1.45 + const nsACString &mimeGuess, nsISupports *extra, 1.46 + nsIPrincipal *requestPrincipal, 1.47 + int16_t *decision); 1.48 +}; 1.49 + 1.50 +nsresult 1.51 +NS_NewContentPolicy(nsIContentPolicy **aResult); 1.52 + 1.53 +#endif /* __nsContentPolicy_h__ */