Bumping manifests a=b2g-bump
[gecko.git] / caps / nsNullPrincipal.h
blob09f25d0b8cec4fa657d914dff0eca31cb8f90380
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /**
7 * This is the principal that has no rights and can't be accessed by
8 * anything other than itself and chrome; null principals are not
9 * same-origin with anything but themselves.
12 #ifndef nsNullPrincipal_h__
13 #define nsNullPrincipal_h__
15 #include "nsIPrincipal.h"
16 #include "nsJSPrincipals.h"
17 #include "nsIScriptSecurityManager.h"
18 #include "nsCOMPtr.h"
19 #include "nsIContentSecurityPolicy.h"
21 class nsIURI;
23 #define NS_NULLPRINCIPAL_CID \
24 { 0xa0bd8b42, 0xf6bf, 0x4fb9, \
25 { 0x93, 0x42, 0x90, 0xbf, 0xc9, 0xb7, 0xa1, 0xab } }
26 #define NS_NULLPRINCIPAL_CONTRACTID "@mozilla.org/nullprincipal;1"
28 #define NS_NULLPRINCIPAL_SCHEME "moz-nullprincipal"
30 class nsNullPrincipal MOZ_FINAL : public nsJSPrincipals
32 public:
33 nsNullPrincipal();
35 // Our refcount is managed by nsJSPrincipals. Use this macro to avoid an
36 // extra refcount member.
38 // FIXME: bug 327245 -- I sorta wish there were a clean way to share the
39 // nsJSPrincipals munging code between the various principal classes without
40 // giving up the NS_DECL_NSIPRINCIPAL goodness.
41 NS_DECL_ISUPPORTS_INHERITED
42 NS_DECL_NSIPRINCIPAL
43 NS_DECL_NSISERIALIZABLE
45 static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIPrincipal *aInheritFrom);
47 nsresult Init(uint32_t aAppId = nsIScriptSecurityManager::NO_APP_ID,
48 bool aInMozBrowser = false);
50 virtual void GetScriptLocation(nsACString &aStr) MOZ_OVERRIDE;
52 #ifdef DEBUG
53 virtual void dumpImpl() MOZ_OVERRIDE;
54 #endif
56 protected:
57 virtual ~nsNullPrincipal();
59 nsCOMPtr<nsIURI> mURI;
60 nsCOMPtr<nsIContentSecurityPolicy> mCSP;
61 uint32_t mAppId;
62 bool mInMozBrowser;
65 #endif // nsNullPrincipal_h__