caps/include/nsNullPrincipal.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/caps/include/nsNullPrincipal.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/**
    1.10 + * This is the principal that has no rights and can't be accessed by
    1.11 + * anything other than itself and chrome; null principals are not
    1.12 + * same-origin with anything but themselves.
    1.13 + */
    1.14 +
    1.15 +#ifndef nsNullPrincipal_h__
    1.16 +#define nsNullPrincipal_h__
    1.17 +
    1.18 +#include "nsIPrincipal.h"
    1.19 +#include "nsJSPrincipals.h"
    1.20 +#include "nsCOMPtr.h"
    1.21 +#include "nsIContentSecurityPolicy.h"
    1.22 +
    1.23 +class nsIURI;
    1.24 +
    1.25 +#define NS_NULLPRINCIPAL_CID \
    1.26 +{ 0xdd156d62, 0xd26f, 0x4441, \
    1.27 + { 0x9c, 0xdb, 0xe8, 0xf0, 0x91, 0x07, 0xc2, 0x73 } }
    1.28 +#define NS_NULLPRINCIPAL_CONTRACTID "@mozilla.org/nullprincipal;1"
    1.29 +
    1.30 +#define NS_NULLPRINCIPAL_SCHEME "moz-nullprincipal"
    1.31 +
    1.32 +class nsNullPrincipal : public nsJSPrincipals
    1.33 +{
    1.34 +public:
    1.35 +  nsNullPrincipal();
    1.36 +  
    1.37 +  // Our refcount is managed by nsJSPrincipals.  Use this macro to avoid an
    1.38 +  // extra refcount member.
    1.39 +
    1.40 +  // FIXME: bug 327245 -- I sorta wish there were a clean way to share the
    1.41 +  // nsJSPrincipals munging code between the various principal classes without
    1.42 +  // giving up the NS_DECL_NSIPRINCIPAL goodness.
    1.43 +  NS_DECL_ISUPPORTS_INHERITED
    1.44 +  NS_DECL_NSIPRINCIPAL
    1.45 +  NS_DECL_NSISERIALIZABLE
    1.46 +
    1.47 +  nsresult Init();
    1.48 +
    1.49 +  virtual void GetScriptLocation(nsACString &aStr) MOZ_OVERRIDE;
    1.50 +
    1.51 +#ifdef DEBUG
    1.52 +  virtual void dumpImpl() MOZ_OVERRIDE;
    1.53 +#endif 
    1.54 +
    1.55 + protected:
    1.56 +  virtual ~nsNullPrincipal();
    1.57 +
    1.58 +  nsCOMPtr<nsIURI> mURI;
    1.59 +  nsCOMPtr<nsIContentSecurityPolicy> mCSP;
    1.60 +};
    1.61 +
    1.62 +#endif // nsNullPrincipal_h__

mercurial