1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_net_ThirdPartyCookieBlockingExceptions_h
6 #define mozilla_net_ThirdPartyCookieBlockingExceptions_h
8 #include "mozilla/MozPromise.h"
9 #include "nsEffectiveTLDService.h"
12 #include "nsTHashSet.h"
13 #include "nsIThirdPartyCookieBlockingExceptionListService.h"
15 class nsIEffectiveTLDService
;
22 class ThirdPartyCookieBlockingExceptions final
{
24 // Initializes the foreign cookie blocking exception list.
27 // Check if the given top-level and third-party URIs are in the exception
29 bool CheckExceptionForURIs(nsIURI
* aFirstPartyURI
, nsIURI
* aThirdPartyURI
);
31 // Check if the given channel is in the exception list.
32 bool CheckExceptionForChannel(nsIChannel
* aChannel
);
34 void Insert(const nsACString
& aException
);
35 void Remove(const nsACString
& aException
);
37 void GetExceptions(nsTArray
<nsCString
>& aExceptions
);
41 bool IsInitialized() const { return mIsInitialized
; }
44 nsCOMPtr
<nsIThirdPartyCookieBlockingExceptionListService
>
45 m3PCBExceptionService
;
47 // A helper function to create a key for the exception list.
48 static void Create3PCBExceptionKey(const nsACString
& aFirstPartySite
,
49 const nsACString
& aThirdPartySite
,
52 aKey
.Append(aFirstPartySite
);
53 aKey
.AppendLiteral(",");
54 aKey
.Append(aThirdPartySite
);
57 // Check if the given third-party site is in the wildcard exception list.
58 // The wildcard exception list is used to allow third-party cookies under
59 // every top-level site.
60 bool CheckWildcardException(const nsACString
& aThirdPartySite
);
62 // Check if the given first-party and third-party sites are in the exception
64 bool CheckException(const nsACString
& aFirstPartySite
,
65 const nsACString
& aThirdPartySite
);
67 // The flag that indicates if the 3PCB exception service is initialized.
68 bool mIsInitialized
= false;
69 nsTHashSet
<nsCStringHashKey
> m3PCBExceptionsSet
;
73 } // namespace mozilla
75 #endif // mozilla_net_ThirdPartyCookieBlockingExceptions_h