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 #ifndef mozilla_net_CookieServiceParent_h
7 #define mozilla_net_CookieServiceParent_h
9 #include "mozilla/net/PCookieServiceParent.h"
10 #include "mozilla/net/CookieKey.h"
15 class OriginAttributes
;
18 class nsIEffectiveTLDService
;
26 class CookieServiceParent
: public PCookieServiceParent
{
27 friend class PCookieServiceParent
;
30 CookieServiceParent();
31 virtual ~CookieServiceParent() = default;
33 void TrackCookieLoad(nsIChannel
* aChannel
);
35 void RemoveBatchDeletedCookies(nsIArray
* aCookieList
);
39 void RemoveCookie(const Cookie
& aCookie
);
41 void AddCookie(const Cookie
& aCookie
);
43 // This will return true if the CookieServiceParent is currently processing
44 // an update from the content process. This is used in ContentParent to make
45 // sure that we are only forwarding those cookie updates to other content
46 // processes, not the one they originated from.
47 bool ProcessingCookie() { return mProcessingCookie
; }
49 bool ContentProcessHasCookie(const Cookie
& cookie
);
50 bool InsecureCookieOrSecureOrigin(const Cookie
& cookie
);
51 void UpdateCookieInContentList(nsIURI
* aHostURI
,
52 const OriginAttributes
& aOriginAttrs
);
54 mozilla::ipc::IPCResult
SetCookies(
55 const nsCString
& aBaseDomain
, const OriginAttributes
& aOriginAttributes
,
56 nsIURI
* aHost
, bool aFromHttp
, const nsTArray
<CookieStruct
>& aCookies
,
57 dom::BrowsingContext
* aBrowsingContext
= nullptr);
60 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
62 mozilla::ipc::IPCResult
RecvSetCookies(
63 const nsCString
& aBaseDomain
, const OriginAttributes
& aOriginAttributes
,
64 nsIURI
* aHost
, bool aFromHttp
, const nsTArray
<CookieStruct
>& aCookies
);
66 mozilla::ipc::IPCResult
RecvGetCookieList(
67 nsIURI
* aHost
, const bool& aIsForeign
,
68 const bool& aIsThirdPartyTrackingResource
,
69 const bool& aIsThirdPartySocialTrackingResource
,
70 const bool& aStorageAccessPermissionGranted
,
71 const uint32_t& aRejectedReason
, const bool& aIsSafeTopLevelNav
,
72 const bool& aIsSameSiteForeign
, const bool& aHadCrossSiteRedirects
,
73 nsTArray
<OriginAttributes
>&& aAttrsList
,
74 GetCookieListResolver
&& aResolve
);
76 static void SerializeCookieListTable(
77 const nsTArray
<Cookie
*>& aFoundCookieList
,
78 nsTArray
<CookieStructTable
>& aCookiesListTable
, nsIURI
* aHostURI
);
80 nsCOMPtr
<nsIEffectiveTLDService
> mTLDService
;
81 RefPtr
<CookieService
> mCookieService
;
82 bool mProcessingCookie
;
83 nsTHashMap
<CookieKey
, bool> mCookieKeysInContent
;
87 } // namespace mozilla
89 #endif // mozilla_net_CookieServiceParent_h