2010-03-25 23:02:28 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-03-25 23:02:28 +00:00
|
|
|
|
|
|
|
#ifndef mozilla_net_CookieServiceChild_h__
|
|
|
|
#define mozilla_net_CookieServiceChild_h__
|
|
|
|
|
|
|
|
#include "mozilla/net/PCookieServiceChild.h"
|
2017-08-03 11:00:41 +00:00
|
|
|
#include "nsClassHashtable.h"
|
|
|
|
#include "nsCookieKey.h"
|
2010-03-25 23:02:28 +00:00
|
|
|
#include "nsICookieService.h"
|
2010-10-19 16:37:03 +00:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIPrefBranch.h"
|
|
|
|
#include "mozIThirdPartyUtil.h"
|
2010-12-01 02:47:08 +00:00
|
|
|
#include "nsWeakReference.h"
|
2018-04-26 14:39:13 +00:00
|
|
|
#include "nsThreadUtils.h"
|
2010-03-25 23:02:28 +00:00
|
|
|
|
2017-08-03 11:00:41 +00:00
|
|
|
class nsCookie;
|
2017-08-03 09:59:31 +00:00
|
|
|
class nsICookiePermission;
|
2017-08-03 11:00:41 +00:00
|
|
|
class nsIEffectiveTLDService;
|
|
|
|
|
2017-08-03 09:59:31 +00:00
|
|
|
struct nsCookieAttributes;
|
|
|
|
|
2010-03-25 23:02:28 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
2017-08-03 11:00:41 +00:00
|
|
|
class CookieStruct;
|
2010-03-25 23:02:28 +00:00
|
|
|
|
|
|
|
class CookieServiceChild : public PCookieServiceChild,
|
|
|
|
public nsICookieService,
|
2010-10-19 16:37:03 +00:00
|
|
|
public nsIObserver,
|
2018-04-26 14:39:13 +00:00
|
|
|
public nsITimerCallback,
|
2010-12-01 02:47:08 +00:00
|
|
|
public nsSupportsWeakReference {
|
2019-02-06 15:57:37 +00:00
|
|
|
friend class PCookieServiceChild;
|
|
|
|
|
2010-03-25 23:02:28 +00:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSICOOKIESERVICE
|
2010-10-19 16:37:03 +00:00
|
|
|
NS_DECL_NSIOBSERVER
|
2018-04-26 14:39:13 +00:00
|
|
|
NS_DECL_NSITIMERCALLBACK
|
2010-03-25 23:02:28 +00:00
|
|
|
|
2017-08-03 11:00:41 +00:00
|
|
|
typedef nsTArray<RefPtr<nsCookie>> CookiesList;
|
|
|
|
typedef nsClassHashtable<nsCookieKey, CookiesList> CookiesMap;
|
|
|
|
|
2010-03-25 23:02:28 +00:00
|
|
|
CookieServiceChild();
|
|
|
|
|
2017-09-04 22:05:10 +00:00
|
|
|
static already_AddRefed<CookieServiceChild> GetSingleton();
|
2010-03-25 23:02:28 +00:00
|
|
|
|
2017-08-03 11:00:41 +00:00
|
|
|
void TrackCookieLoad(nsIChannel *aChannel);
|
|
|
|
|
2010-03-25 23:02:28 +00:00
|
|
|
protected:
|
2014-06-24 16:36:44 +00:00
|
|
|
virtual ~CookieServiceChild();
|
2018-04-26 14:39:13 +00:00
|
|
|
void MoveCookies();
|
2014-06-24 16:36:44 +00:00
|
|
|
|
2010-03-25 23:02:28 +00:00
|
|
|
void SerializeURIs(nsIURI *aHostURI, nsIChannel *aChannel,
|
|
|
|
nsCString &aHostSpec, nsCString &aHostCharset,
|
|
|
|
nsCString &aOriginatingSpec,
|
|
|
|
nsCString &aOriginatingCharset);
|
|
|
|
|
|
|
|
nsresult GetCookieStringInternal(nsIURI *aHostURI, nsIChannel *aChannel,
|
2017-02-13 18:04:21 +00:00
|
|
|
char **aCookieString);
|
2010-03-25 23:02:28 +00:00
|
|
|
|
2017-08-03 09:59:31 +00:00
|
|
|
void GetCookieStringFromCookieHashTable(nsIURI *aHostURI, bool aIsForeign,
|
2018-06-20 17:38:22 +00:00
|
|
|
bool aIsTrackingResource,
|
2018-07-10 08:09:59 +00:00
|
|
|
bool aFirstPartyStorageAccessGranted,
|
2018-04-08 17:52:05 +00:00
|
|
|
bool aIsSafeTopLevelNav,
|
2018-04-12 10:52:51 +00:00
|
|
|
bool aIsSameSiteForeign,
|
2017-08-03 09:59:31 +00:00
|
|
|
const OriginAttributes &aAttrs,
|
|
|
|
nsCString &aCookieString);
|
|
|
|
|
2010-03-25 23:02:28 +00:00
|
|
|
nsresult SetCookieStringInternal(nsIURI *aHostURI, nsIChannel *aChannel,
|
|
|
|
const char *aCookieString,
|
2017-05-20 04:47:59 +00:00
|
|
|
const char *aServerTime, bool aFromHttp);
|
2010-03-25 23:02:28 +00:00
|
|
|
|
2017-08-03 11:00:41 +00:00
|
|
|
void RecordDocumentCookie(nsCookie *aCookie, const OriginAttributes &aAttrs);
|
|
|
|
|
2017-08-03 09:59:31 +00:00
|
|
|
void SetCookieInternal(nsCookieAttributes &aCookieAttributes,
|
|
|
|
const mozilla::OriginAttributes &aAttrs,
|
|
|
|
nsIChannel *aChannel, bool aFromHttp,
|
|
|
|
nsICookiePermission *aPermissionService);
|
|
|
|
|
|
|
|
uint32_t CountCookiesFromHashTable(const nsCString &aBaseDomain,
|
|
|
|
const OriginAttributes &aOriginAttrs);
|
|
|
|
|
2010-10-19 16:37:03 +00:00
|
|
|
void PrefChanged(nsIPrefBranch *aPrefBranch);
|
|
|
|
|
|
|
|
bool RequireThirdPartyCheck();
|
|
|
|
|
2019-02-06 15:58:43 +00:00
|
|
|
mozilla::ipc::IPCResult RecvTrackCookiesLoad(
|
|
|
|
nsTArray<CookieStruct> &&aCookiesList, const OriginAttributes &aAttrs);
|
2017-08-03 11:00:41 +00:00
|
|
|
|
2019-02-06 15:58:43 +00:00
|
|
|
mozilla::ipc::IPCResult RecvRemoveAll();
|
2017-08-03 10:00:12 +00:00
|
|
|
|
2019-02-06 15:58:43 +00:00
|
|
|
mozilla::ipc::IPCResult RecvRemoveBatchDeletedCookies(
|
2017-08-03 10:00:12 +00:00
|
|
|
nsTArray<CookieStruct> &&aCookiesList,
|
2019-02-06 15:58:43 +00:00
|
|
|
nsTArray<OriginAttributes> &&aAttrsList);
|
2017-08-03 10:00:12 +00:00
|
|
|
|
2019-02-06 15:58:43 +00:00
|
|
|
mozilla::ipc::IPCResult RecvRemoveCookie(const CookieStruct &aCookie,
|
|
|
|
const OriginAttributes &aAttrs);
|
2017-08-03 10:00:12 +00:00
|
|
|
|
2019-02-06 15:58:43 +00:00
|
|
|
mozilla::ipc::IPCResult RecvAddCookie(const CookieStruct &aCookie,
|
|
|
|
const OriginAttributes &aAttrs);
|
2017-08-03 10:00:12 +00:00
|
|
|
|
2017-08-22 07:48:00 +00:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
|
|
|
|
2017-08-03 11:00:41 +00:00
|
|
|
CookiesMap mCookiesMap;
|
2018-04-26 14:39:13 +00:00
|
|
|
nsCOMPtr<nsITimer> mCookieTimer;
|
2010-10-19 16:37:03 +00:00
|
|
|
nsCOMPtr<mozIThirdPartyUtil> mThirdPartyUtil;
|
2017-08-03 11:00:41 +00:00
|
|
|
nsCOMPtr<nsIEffectiveTLDService> mTLDService;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t mCookieBehavior;
|
2010-10-19 16:37:03 +00:00
|
|
|
bool mThirdPartySession;
|
2017-02-17 03:27:49 +00:00
|
|
|
bool mThirdPartyNonsecureSession;
|
2017-08-03 09:59:31 +00:00
|
|
|
bool mLeaveSecureAlone;
|
2017-08-22 07:48:00 +00:00
|
|
|
bool mIPCOpen;
|
2010-03-25 23:02:28 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
2010-03-25 23:02:28 +00:00
|
|
|
|
|
|
|
#endif // mozilla_net_CookieServiceChild_h__
|