Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / netwerk / cookie / ThirdPartyCookieBlockingExceptions.h
blob3da6253337c96c1c1b5130245a32f46d6b85b697
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"
10 #include "nsString.h"
11 #include "nsTArray.h"
12 #include "nsTHashSet.h"
13 #include "nsIThirdPartyCookieBlockingExceptionListService.h"
15 class nsIEffectiveTLDService;
16 class nsIURI;
17 class nsIChannel;
19 namespace mozilla {
20 namespace net {
22 class ThirdPartyCookieBlockingExceptions final {
23 public:
24 // Initializes the foreign cookie blocking exception list.
25 void Initialize();
27 // Check if the given top-level and third-party URIs are in the exception
28 // list.
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);
39 void Shutdown();
41 bool IsInitialized() const { return mIsInitialized; }
43 private:
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,
50 nsACString& aKey) {
51 aKey.Truncate();
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
63 // list.
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;
72 } // namespace net
73 } // namespace mozilla
75 #endif // mozilla_net_ThirdPartyCookieBlockingExceptions_h