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 DOM_QUOTA_PRINCIPALUTILS_H_
8 #define DOM_QUOTA_PRINCIPALUTILS_H_
12 #include "nsStringFwd.h"
15 class nsPIDOMWindowOuter
;
16 enum class nsresult
: uint32_t;
20 template <typename V
, typename E
>
25 namespace mozilla::ipc
{
31 namespace mozilla::dom::quota
{
33 struct PrincipalMetadata
;
36 bool IsPrincipalInfoValid(const mozilla::ipc::PrincipalInfo
& aPrincipalInfo
);
38 Result
<PrincipalMetadata
, nsresult
> GetInfoFromValidatedPrincipalInfo(
39 QuotaManager
& aQuotaManager
,
40 const mozilla::ipc::PrincipalInfo
& aPrincipalInfo
);
42 nsAutoCString
GetGroupFromValidatedPrincipalInfo(
43 const mozilla::ipc::PrincipalInfo
& aPrincipalInfo
);
45 nsAutoCString
GetOriginFromValidatedPrincipalInfo(
46 const mozilla::ipc::PrincipalInfo
& aPrincipalInfo
);
48 Result
<PrincipalMetadata
, nsresult
> GetInfoFromPrincipal(
49 nsIPrincipal
* aPrincipal
);
51 Result
<PrincipalMetadata
, nsresult
> GetInfoFromWindow(
52 nsPIDOMWindowOuter
* aWindow
);
54 Result
<nsAutoCString
, nsresult
> GetOriginFromPrincipal(
55 nsIPrincipal
* aPrincipal
);
57 Result
<nsAutoCString
, nsresult
> GetOriginFromWindow(
58 nsPIDOMWindowOuter
* aWindow
);
60 nsLiteralCString
GetGroupForChrome();
62 nsLiteralCString
GetOriginForChrome();
64 PrincipalMetadata
GetInfoForChrome();
66 } // namespace mozilla::dom::quota
68 #endif // DOM_QUOTA_PRINCIPALUTILS_H_