Backed out changeset f594e6f00208 (bug 1940883) for causing crashes in bug 1941164.
[gecko.git] / toolkit / components / antitracking / PartitioningExceptionList.h
blob250a636340fe1c34c7f5dd7fb18089165f60a739
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_PartitioningExceptionList_h
8 #define mozilla_PartitioningExceptionList_h
10 #include "nsCOMPtr.h"
11 #include "nsIPartitioningExceptionListService.h"
12 #include "nsTArray.h"
13 #include "nsString.h"
15 class nsIChannel;
16 class nsIPrincipal;
18 namespace mozilla {
20 class PartitioningExceptionList : public nsIPartitioningExceptionListObserver {
21 public:
22 NS_DECL_ISUPPORTS
23 NS_DECL_NSIPARTITIONINGEXCEPTIONLISTOBSERVER
25 static bool Check(const nsACString& aFirstPartyOrigin,
26 const nsACString& aThirdPartyOrigin);
28 private:
29 static PartitioningExceptionList* GetOrCreate();
31 PartitioningExceptionList() = default;
32 virtual ~PartitioningExceptionList() = default;
34 nsresult Init();
35 void Shutdown();
37 struct PartitionExceptionListPattern {
38 nsCString mScheme;
39 nsCString mSuffix;
40 bool mIsWildCard = false;
43 struct PartitionExceptionListEntry {
44 PartitionExceptionListPattern mFirstParty;
45 PartitionExceptionListPattern mThirdParty;
48 static nsresult GetSchemeFromOrigin(const nsACString& aOrigin,
49 nsACString& aScheme,
50 nsACString& aOriginNoScheme);
52 static bool OriginMatchesPattern(
53 const nsACString& aOrigin, const PartitionExceptionListPattern& aPattern);
55 static nsresult GetExceptionListPattern(
56 const nsACString& aOriginPattern,
57 PartitionExceptionListPattern& aPattern);
59 nsCOMPtr<nsIPartitioningExceptionListService> mService;
60 nsTArray<PartitionExceptionListEntry> mExceptionList;
63 } // namespace mozilla
65 #endif // mozilla_PartitioningExceptionList_h