2010-03-26 02:02:28 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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-26 02:02:28 +03:00
|
|
|
|
|
|
|
#include "mozilla/net/CookieServiceChild.h"
|
2017-08-03 14:00:41 +03:00
|
|
|
#include "mozilla/net/NeckoChannelParams.h"
|
2018-07-13 13:02:19 +03:00
|
|
|
#include "mozilla/AntiTrackingCommon.h"
|
2016-09-09 13:26:14 +03:00
|
|
|
#include "mozilla/LoadInfo.h"
|
|
|
|
#include "mozilla/BasePrincipal.h"
|
2017-09-05 01:05:10 +03:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
2017-05-26 04:08:00 +03:00
|
|
|
#include "mozilla/dom/ContentChild.h"
|
2012-08-23 23:33:46 +04:00
|
|
|
#include "mozilla/ipc/URIUtils.h"
|
2010-03-26 02:02:28 +03:00
|
|
|
#include "mozilla/net/NeckoChild.h"
|
2019-07-26 04:10:23 +03:00
|
|
|
#include "mozilla/StaticPrefs_network.h"
|
2017-08-16 07:05:00 +03:00
|
|
|
#include "mozilla/SystemGroup.h"
|
2019-04-12 08:30:43 +03:00
|
|
|
#include "mozilla/StoragePrincipalHelper.h"
|
2017-08-03 14:00:41 +03:00
|
|
|
#include "nsCookie.h"
|
|
|
|
#include "nsCookieService.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsNetCID.h"
|
2018-04-08 20:52:05 +03:00
|
|
|
#include "nsNetUtil.h"
|
2016-09-09 13:26:14 +03:00
|
|
|
#include "nsIChannel.h"
|
2019-08-21 16:24:45 +03:00
|
|
|
#include "nsIHttpChannel.h"
|
2018-09-05 18:00:15 +03:00
|
|
|
#include "nsCookiePermission.h"
|
2017-08-03 14:00:41 +03:00
|
|
|
#include "nsIEffectiveTLDService.h"
|
2010-03-26 02:02:28 +03:00
|
|
|
#include "nsIURI.h"
|
2010-10-19 20:37:03 +04:00
|
|
|
#include "nsIPrefService.h"
|
2012-01-17 05:48:29 +04:00
|
|
|
#include "nsIPrefBranch.h"
|
2015-07-07 05:17:00 +03:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2018-04-26 17:56:40 +03:00
|
|
|
#include "mozilla/Telemetry.h"
|
|
|
|
#include "mozilla/TimeStamp.h"
|
2019-03-08 12:04:34 +03:00
|
|
|
#include "ThirdPartyUtil.h"
|
2010-03-26 02:02:28 +03:00
|
|
|
|
2012-08-23 23:33:46 +04:00
|
|
|
using namespace mozilla::ipc;
|
2017-08-03 14:00:41 +03:00
|
|
|
using mozilla::OriginAttributes;
|
2012-08-23 23:33:46 +04:00
|
|
|
|
2010-03-26 02:02:28 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
2010-10-19 20:37:03 +04:00
|
|
|
// Pref string constants
|
2018-04-26 17:39:13 +03:00
|
|
|
static const char kCookieMoveIntervalSecs[] =
|
|
|
|
"network.cookie.move.interval_sec";
|
2010-10-19 20:37:03 +04:00
|
|
|
|
2017-09-05 01:05:10 +03:00
|
|
|
static StaticRefPtr<CookieServiceChild> gCookieService;
|
2018-04-26 17:39:13 +03:00
|
|
|
static uint32_t gMoveCookiesIntervalSeconds = 10;
|
2013-11-21 18:38:59 +04:00
|
|
|
|
2017-09-05 01:05:10 +03:00
|
|
|
already_AddRefed<CookieServiceChild> CookieServiceChild::GetSingleton() {
|
|
|
|
if (!gCookieService) {
|
2013-11-21 18:38:59 +04:00
|
|
|
gCookieService = new CookieServiceChild();
|
2017-09-05 01:05:10 +03:00
|
|
|
ClearOnShutdown(&gCookieService);
|
|
|
|
}
|
2010-03-26 02:02:28 +03:00
|
|
|
|
2017-09-05 01:05:10 +03:00
|
|
|
return do_AddRef(gCookieService);
|
2010-03-26 02:02:28 +03:00
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(CookieServiceChild, nsICookieService, nsIObserver,
|
|
|
|
nsITimerCallback, nsISupportsWeakReference)
|
2010-03-26 02:02:28 +03:00
|
|
|
|
2019-05-31 12:32:51 +03:00
|
|
|
CookieServiceChild::CookieServiceChild() {
|
2010-03-26 02:02:28 +03:00
|
|
|
NS_ASSERTION(IsNeckoChild(), "not a child process");
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
mozilla::dom::ContentChild* cc =
|
|
|
|
static_cast<mozilla::dom::ContentChild*>(gNeckoChild->Manager());
|
2017-05-26 04:08:00 +03:00
|
|
|
if (cc->IsShuttingDown()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-26 02:02:28 +03:00
|
|
|
// This corresponds to Release() in DeallocPCookieService.
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
|
|
|
|
NeckoChild::InitNeckoChild();
|
2017-08-16 07:05:00 +03:00
|
|
|
|
|
|
|
// Create a child PCookieService actor.
|
2010-03-26 02:02:28 +03:00
|
|
|
gNeckoChild->SendPCookieServiceConstructor(this);
|
|
|
|
|
2019-03-08 12:04:34 +03:00
|
|
|
mThirdPartyUtil = ThirdPartyUtil::GetInstance();
|
|
|
|
NS_ASSERTION(mThirdPartyUtil, "couldn't get ThirdPartyUtil service");
|
|
|
|
|
2017-08-03 14:00:41 +03:00
|
|
|
mTLDService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
|
|
|
|
NS_ASSERTION(mTLDService, "couldn't get TLDService");
|
|
|
|
|
2010-10-19 20:37:03 +04:00
|
|
|
// Init our prefs and observer.
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
2016-09-01 08:01:16 +03:00
|
|
|
NS_WARNING_ASSERTION(prefBranch, "no prefservice");
|
2010-10-19 20:37:03 +04:00
|
|
|
if (prefBranch) {
|
2018-04-26 17:39:13 +03:00
|
|
|
prefBranch->AddObserver(kCookieMoveIntervalSecs, this, true);
|
2010-10-19 20:37:03 +04:00
|
|
|
PrefChanged(prefBranch);
|
|
|
|
}
|
2018-04-26 17:39:13 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (observerService) {
|
|
|
|
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CookieServiceChild::MoveCookies() {
|
2018-04-26 17:56:40 +03:00
|
|
|
TimeStamp start = TimeStamp::Now();
|
2018-04-26 17:39:13 +03:00
|
|
|
for (auto iter = mCookiesMap.Iter(); !iter.Done(); iter.Next()) {
|
2019-05-01 11:47:10 +03:00
|
|
|
CookiesList* cookiesList = iter.UserData();
|
2018-04-26 17:39:13 +03:00
|
|
|
CookiesList newCookiesList;
|
|
|
|
for (uint32_t i = 0; i < cookiesList->Length(); ++i) {
|
2019-05-01 11:47:10 +03:00
|
|
|
nsCookie* cookie = cookiesList->ElementAt(i);
|
2018-04-26 17:39:13 +03:00
|
|
|
RefPtr<nsCookie> newCookie = nsCookie::Create(
|
|
|
|
cookie->Name(), cookie->Value(), cookie->Host(), cookie->Path(),
|
|
|
|
cookie->Expiry(), cookie->LastAccessed(), cookie->CreationTime(),
|
|
|
|
cookie->IsSession(), cookie->IsSecure(), cookie->IsHttpOnly(),
|
2019-06-05 15:19:54 +03:00
|
|
|
cookie->OriginAttributesRef(), cookie->SameSite(),
|
|
|
|
cookie->RawSameSite());
|
2018-04-26 17:39:13 +03:00
|
|
|
newCookiesList.AppendElement(newCookie);
|
|
|
|
}
|
|
|
|
cookiesList->SwapElements(newCookiesList);
|
|
|
|
}
|
2018-04-26 17:56:40 +03:00
|
|
|
|
|
|
|
Telemetry::AccumulateTimeDelta(Telemetry::COOKIE_TIME_MOVING_MS, start);
|
2018-04-26 17:39:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
CookieServiceChild::Notify(nsITimer* aTimer) {
|
2018-04-26 17:39:13 +03:00
|
|
|
if (aTimer == mCookieTimer) {
|
|
|
|
MoveCookies();
|
|
|
|
} else {
|
|
|
|
MOZ_CRASH("Unknown timer");
|
|
|
|
}
|
|
|
|
return NS_OK;
|
2010-03-26 02:02:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CookieServiceChild::~CookieServiceChild() { gCookieService = nullptr; }
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
void CookieServiceChild::TrackCookieLoad(nsIChannel* aChannel) {
|
2019-05-31 12:32:51 +03:00
|
|
|
if (!CanSend()) {
|
2017-08-22 10:48:00 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-03 14:00:41 +03:00
|
|
|
bool isForeign = false;
|
2018-06-20 20:38:22 +03:00
|
|
|
bool isTrackingResource = false;
|
2018-07-10 11:09:59 +03:00
|
|
|
bool firstPartyStorageAccessGranted = false;
|
2019-05-25 04:25:41 +03:00
|
|
|
uint32_t rejectedReason = 0;
|
2017-08-03 14:00:41 +03:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
aChannel->GetURI(getter_AddRefs(uri));
|
2019-03-08 12:04:34 +03:00
|
|
|
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
|
|
|
if (RequireThirdPartyCheck(loadInfo)) {
|
2017-08-03 14:00:41 +03:00
|
|
|
mThirdPartyUtil->IsThirdPartyChannel(aChannel, uri, &isForeign);
|
|
|
|
}
|
2018-06-20 20:38:22 +03:00
|
|
|
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
|
|
|
if (httpChannel) {
|
2019-03-17 09:55:50 +03:00
|
|
|
isTrackingResource = httpChannel->IsTrackingResource();
|
2018-08-25 09:48:50 +03:00
|
|
|
// Check first-party storage access even for non-tracking resources, since
|
|
|
|
// we will need the result when computing the access rights for the reject
|
|
|
|
// foreign cookie behavior mode.
|
2018-07-13 13:02:19 +03:00
|
|
|
if (isForeign && AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
2019-01-22 22:46:10 +03:00
|
|
|
httpChannel, uri, &rejectedReason)) {
|
2018-07-13 13:02:19 +03:00
|
|
|
firstPartyStorageAccessGranted = true;
|
|
|
|
}
|
2019-01-22 22:46:10 +03:00
|
|
|
|
|
|
|
// We need to notify about the outcome of the content blocking check here
|
|
|
|
// since the parent process can't do it for us as it won't have a channel
|
|
|
|
// object handy.
|
|
|
|
if (!firstPartyStorageAccessGranted) {
|
|
|
|
AntiTrackingCommon::NotifyBlockingDecision(
|
|
|
|
aChannel, AntiTrackingCommon::BlockingDecision::eBlock,
|
|
|
|
rejectedReason);
|
|
|
|
}
|
2018-06-20 20:38:22 +03:00
|
|
|
}
|
2019-02-20 15:27:25 +03:00
|
|
|
mozilla::OriginAttributes attrs = loadInfo->GetOriginAttributes();
|
2019-04-12 08:30:43 +03:00
|
|
|
StoragePrincipalHelper::PrepareOriginAttributes(aChannel, attrs);
|
2017-08-03 14:00:41 +03:00
|
|
|
URIParams uriParams;
|
|
|
|
SerializeURI(uri, uriParams);
|
2018-04-08 20:52:05 +03:00
|
|
|
bool isSafeTopLevelNav = NS_IsSafeTopLevelNav(aChannel);
|
2018-04-12 13:52:51 +03:00
|
|
|
bool isSameSiteForeign = NS_IsSameSiteForeign(aChannel, uri);
|
2018-06-20 20:38:22 +03:00
|
|
|
SendPrepareCookieList(uriParams, isForeign, isTrackingResource,
|
2019-05-25 04:25:41 +03:00
|
|
|
firstPartyStorageAccessGranted, rejectedReason,
|
|
|
|
isSafeTopLevelNav, isSameSiteForeign, attrs);
|
2017-08-03 14:00:41 +03:00
|
|
|
}
|
|
|
|
|
2017-08-03 13:00:12 +03:00
|
|
|
mozilla::ipc::IPCResult CookieServiceChild::RecvRemoveAll() {
|
|
|
|
mCookiesMap.Clear();
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult CookieServiceChild::RecvRemoveCookie(
|
2019-05-01 11:47:10 +03:00
|
|
|
const CookieStruct& aCookie, const OriginAttributes& aAttrs) {
|
2017-08-03 13:00:12 +03:00
|
|
|
nsCString baseDomain;
|
|
|
|
nsCookieService::GetBaseDomainFromHost(mTLDService, aCookie.host(),
|
|
|
|
baseDomain);
|
|
|
|
nsCookieKey key(baseDomain, aAttrs);
|
2019-05-01 11:47:10 +03:00
|
|
|
CookiesList* cookiesList = nullptr;
|
2017-08-03 13:00:12 +03:00
|
|
|
mCookiesMap.Get(key, &cookiesList);
|
|
|
|
|
|
|
|
if (!cookiesList) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < cookiesList->Length(); i++) {
|
2019-05-01 11:47:10 +03:00
|
|
|
nsCookie* cookie = cookiesList->ElementAt(i);
|
2017-08-03 13:00:12 +03:00
|
|
|
if (cookie->Name().Equals(aCookie.name()) &&
|
|
|
|
cookie->Host().Equals(aCookie.host()) &&
|
|
|
|
cookie->Path().Equals(aCookie.path())) {
|
|
|
|
cookiesList->RemoveElementAt(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult CookieServiceChild::RecvAddCookie(
|
2019-05-01 11:47:10 +03:00
|
|
|
const CookieStruct& aCookie, const OriginAttributes& aAttrs) {
|
2017-08-03 13:00:12 +03:00
|
|
|
RefPtr<nsCookie> cookie = nsCookie::Create(
|
|
|
|
aCookie.name(), aCookie.value(), aCookie.host(), aCookie.path(),
|
|
|
|
aCookie.expiry(), aCookie.lastAccessed(), aCookie.creationTime(),
|
2017-12-14 22:29:32 +03:00
|
|
|
aCookie.isSession(), aCookie.isSecure(), aCookie.isHttpOnly(), aAttrs,
|
2019-06-05 15:19:54 +03:00
|
|
|
aCookie.sameSite(), aCookie.rawSameSite());
|
2017-08-03 13:00:12 +03:00
|
|
|
RecordDocumentCookie(cookie, aAttrs);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult CookieServiceChild::RecvRemoveBatchDeletedCookies(
|
2019-05-01 11:47:10 +03:00
|
|
|
nsTArray<CookieStruct>&& aCookiesList,
|
|
|
|
nsTArray<OriginAttributes>&& aAttrsList) {
|
2017-08-03 13:00:12 +03:00
|
|
|
MOZ_ASSERT(aCookiesList.Length() == aAttrsList.Length());
|
|
|
|
for (uint32_t i = 0; i < aCookiesList.Length(); i++) {
|
|
|
|
CookieStruct cookieStruct = aCookiesList.ElementAt(i);
|
|
|
|
RecvRemoveCookie(cookieStruct, aAttrsList.ElementAt(i));
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-08-03 14:00:41 +03:00
|
|
|
mozilla::ipc::IPCResult CookieServiceChild::RecvTrackCookiesLoad(
|
2019-05-01 11:47:10 +03:00
|
|
|
nsTArray<CookieStruct>&& aCookiesList, const OriginAttributes& aAttrs) {
|
2017-08-03 14:00:41 +03:00
|
|
|
for (uint32_t i = 0; i < aCookiesList.Length(); i++) {
|
|
|
|
RefPtr<nsCookie> cookie = nsCookie::Create(
|
|
|
|
aCookiesList[i].name(), aCookiesList[i].value(), aCookiesList[i].host(),
|
|
|
|
aCookiesList[i].path(), aCookiesList[i].expiry(),
|
|
|
|
aCookiesList[i].lastAccessed(), aCookiesList[i].creationTime(),
|
|
|
|
aCookiesList[i].isSession(), aCookiesList[i].isSecure(), false, aAttrs,
|
2019-06-05 15:19:54 +03:00
|
|
|
aCookiesList[i].sameSite(), aCookiesList[i].rawSameSite());
|
2017-08-03 14:00:41 +03:00
|
|
|
RecordDocumentCookie(cookie, aAttrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
void CookieServiceChild::PrefChanged(nsIPrefBranch* aPrefBranch) {
|
2019-03-08 12:04:34 +03:00
|
|
|
int32_t val;
|
2018-04-26 17:39:13 +03:00
|
|
|
if (NS_SUCCEEDED(aPrefBranch->GetIntPref(kCookieMoveIntervalSecs, &val))) {
|
|
|
|
gMoveCookiesIntervalSeconds = clamped<uint32_t>(val, 0, 3600);
|
|
|
|
if (gMoveCookiesIntervalSeconds && !mCookieTimer) {
|
|
|
|
NS_NewTimerWithCallback(getter_AddRefs(mCookieTimer), this,
|
|
|
|
gMoveCookiesIntervalSeconds * 1000,
|
|
|
|
nsITimer::TYPE_REPEATING_SLACK_LOW_PRIORITY);
|
|
|
|
}
|
|
|
|
if (!gMoveCookiesIntervalSeconds && mCookieTimer) {
|
|
|
|
mCookieTimer->Cancel();
|
|
|
|
mCookieTimer = nullptr;
|
|
|
|
}
|
|
|
|
if (mCookieTimer) {
|
|
|
|
mCookieTimer->SetDelay(gMoveCookiesIntervalSeconds * 1000);
|
|
|
|
}
|
|
|
|
}
|
2010-10-19 20:37:03 +04:00
|
|
|
}
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
void CookieServiceChild::GetCookieStringFromCookieHashTable(
|
2019-05-01 11:47:10 +03:00
|
|
|
nsIURI* aHostURI, bool aIsForeign, bool aIsTrackingResource,
|
2019-05-25 04:25:41 +03:00
|
|
|
bool aFirstPartyStorageAccessGranted, uint32_t aRejectedReason,
|
|
|
|
bool aIsSafeTopLevelNav, bool aIsSameSiteForeign, nsIChannel* aChannel,
|
2019-05-31 12:36:44 +03:00
|
|
|
nsACString& aCookieString) {
|
2017-08-03 12:59:31 +03:00
|
|
|
nsCOMPtr<nsIEffectiveTLDService> TLDService =
|
|
|
|
do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
|
|
|
|
NS_ASSERTION(TLDService, "Can't get TLDService");
|
|
|
|
bool requireHostMatch;
|
|
|
|
nsAutoCString baseDomain;
|
2019-03-08 12:04:34 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsILoadInfo> loadInfo;
|
|
|
|
mozilla::OriginAttributes attrs;
|
|
|
|
if (aChannel) {
|
|
|
|
loadInfo = aChannel->LoadInfo();
|
|
|
|
attrs = loadInfo->GetOriginAttributes();
|
2019-04-12 08:30:43 +03:00
|
|
|
StoragePrincipalHelper::PrepareOriginAttributes(aChannel, attrs);
|
2019-03-08 12:04:34 +03:00
|
|
|
}
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
nsCookieService::GetBaseDomain(TLDService, aHostURI, baseDomain,
|
|
|
|
requireHostMatch);
|
2019-03-08 12:04:34 +03:00
|
|
|
nsCookieKey key(baseDomain, attrs);
|
2019-05-01 11:47:10 +03:00
|
|
|
CookiesList* cookiesList = nullptr;
|
2017-08-03 12:59:31 +03:00
|
|
|
mCookiesMap.Get(key, &cookiesList);
|
|
|
|
|
|
|
|
if (!cookiesList) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoCString hostFromURI, pathFromURI;
|
|
|
|
aHostURI->GetAsciiHost(hostFromURI);
|
2017-08-03 16:23:43 +03:00
|
|
|
aHostURI->GetPathQueryRef(pathFromURI);
|
2019-08-08 16:02:36 +03:00
|
|
|
bool isSecure = aHostURI->SchemeIs("https");
|
2017-08-03 12:59:31 +03:00
|
|
|
int64_t currentTimeInUsec = PR_Now();
|
|
|
|
int64_t currentTime = currentTimeInUsec / PR_USEC_PER_SEC;
|
|
|
|
|
2019-03-08 12:04:34 +03:00
|
|
|
nsCOMPtr<nsICookieSettings> cookieSettings =
|
|
|
|
nsCookieService::GetCookieSettings(aChannel);
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
CookieStatus cookieStatus = nsCookieService::CheckPrefs(
|
2019-05-31 12:32:33 +03:00
|
|
|
cookieSettings, aHostURI, aIsForeign, aIsTrackingResource,
|
2019-05-31 12:36:44 +03:00
|
|
|
aFirstPartyStorageAccessGranted, VoidCString(),
|
2019-05-25 04:25:41 +03:00
|
|
|
CountCookiesFromHashTable(baseDomain, attrs), attrs, &aRejectedReason);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
if (cookieStatus != STATUS_ACCEPTED &&
|
|
|
|
cookieStatus != STATUS_ACCEPT_SESSION) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cookiesList->Sort(CompareCookiesForSending());
|
|
|
|
for (uint32_t i = 0; i < cookiesList->Length(); i++) {
|
2019-05-01 11:47:10 +03:00
|
|
|
nsCookie* cookie = cookiesList->ElementAt(i);
|
2017-08-03 12:59:31 +03:00
|
|
|
// check the host, since the base domain lookup is conservative.
|
|
|
|
if (!nsCookieService::DomainMatches(cookie, hostFromURI)) continue;
|
|
|
|
|
2018-09-26 18:39:33 +03:00
|
|
|
// We don't show HttpOnly cookies in content processes.
|
|
|
|
if (cookie->IsHttpOnly()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
// if the cookie is secure and the host scheme isn't, we can't send it
|
|
|
|
if (cookie->IsSecure() && !isSecure) continue;
|
|
|
|
|
2018-04-08 20:52:05 +03:00
|
|
|
int32_t sameSiteAttr = 0;
|
|
|
|
cookie->GetSameSite(&sameSiteAttr);
|
2019-05-15 16:33:45 +03:00
|
|
|
if (aIsSameSiteForeign) {
|
2018-04-08 20:52:05 +03:00
|
|
|
// it if's a cross origin request and the cookie is same site only
|
|
|
|
// (strict) don't send it
|
2019-05-31 12:36:44 +03:00
|
|
|
if (sameSiteAttr == nsICookie::SAMESITE_STRICT) {
|
2018-04-08 20:52:05 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// if it's a cross origin request, the cookie is same site lax, but it's
|
|
|
|
// not a top-level navigation, don't send it
|
2019-05-31 12:36:44 +03:00
|
|
|
if (sameSiteAttr == nsICookie::SAMESITE_LAX && !aIsSafeTopLevelNav) {
|
2018-04-08 20:52:05 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
// if the nsIURI path doesn't match the cookie path, don't send it back
|
|
|
|
if (!nsCookieService::PathMatches(cookie, pathFromURI)) continue;
|
|
|
|
|
|
|
|
// check if the cookie has expired
|
|
|
|
if (cookie->Expiry() <= currentTime) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cookie->Name().IsEmpty() || !cookie->Value().IsEmpty()) {
|
|
|
|
if (!aCookieString.IsEmpty()) {
|
2017-09-04 08:14:11 +03:00
|
|
|
aCookieString.AppendLiteral("; ");
|
2017-08-03 12:59:31 +03:00
|
|
|
}
|
|
|
|
if (!cookie->Name().IsEmpty()) {
|
|
|
|
aCookieString.Append(cookie->Name().get());
|
2017-09-04 08:14:11 +03:00
|
|
|
aCookieString.AppendLiteral("=");
|
2017-08-03 12:59:31 +03:00
|
|
|
aCookieString.Append(cookie->Value().get());
|
|
|
|
} else {
|
|
|
|
aCookieString.Append(cookie->Value().get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t CookieServiceChild::CountCookiesFromHashTable(
|
2019-05-01 11:47:10 +03:00
|
|
|
const nsCString& aBaseDomain, const OriginAttributes& aOriginAttrs) {
|
|
|
|
CookiesList* cookiesList = nullptr;
|
2017-08-03 12:59:31 +03:00
|
|
|
|
|
|
|
nsCString baseDomain;
|
|
|
|
nsCookieKey key(aBaseDomain, aOriginAttrs);
|
|
|
|
mCookiesMap.Get(key, &cookiesList);
|
|
|
|
|
|
|
|
return cookiesList ? cookiesList->Length() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CookieServiceChild::SetCookieInternal(
|
2019-05-31 12:31:30 +03:00
|
|
|
const CookieStruct& aCookieData, const mozilla::OriginAttributes& aAttrs,
|
|
|
|
nsIChannel* aChannel, bool aFromHttp,
|
|
|
|
nsICookiePermission* aPermissionService) {
|
2017-08-03 12:59:31 +03:00
|
|
|
int64_t currentTimeInUsec = PR_Now();
|
|
|
|
RefPtr<nsCookie> cookie = nsCookie::Create(
|
2019-05-31 12:31:30 +03:00
|
|
|
aCookieData.name(), aCookieData.value(), aCookieData.host(),
|
|
|
|
aCookieData.path(), aCookieData.expiry(), currentTimeInUsec,
|
2017-08-03 12:59:31 +03:00
|
|
|
nsCookie::GenerateUniqueCreationTime(currentTimeInUsec),
|
2019-05-31 12:31:30 +03:00
|
|
|
aCookieData.isSession(), aCookieData.isSecure(), aCookieData.isHttpOnly(),
|
2019-06-05 15:19:54 +03:00
|
|
|
aAttrs, aCookieData.sameSite(), aCookieData.rawSameSite());
|
2017-08-03 12:59:31 +03:00
|
|
|
|
|
|
|
RecordDocumentCookie(cookie, aAttrs);
|
|
|
|
}
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
bool CookieServiceChild::RequireThirdPartyCheck(nsILoadInfo* aLoadInfo) {
|
2019-03-19 16:23:28 +03:00
|
|
|
if (!aLoadInfo) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-03-08 12:04:34 +03:00
|
|
|
nsCOMPtr<nsICookieSettings> cookieSettings;
|
|
|
|
nsresult rv = aLoadInfo->GetCookieSettings(getter_AddRefs(cookieSettings));
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t cookieBehavior = cookieSettings->GetCookieBehavior();
|
|
|
|
return cookieBehavior == nsICookieService::BEHAVIOR_REJECT_FOREIGN ||
|
|
|
|
cookieBehavior == nsICookieService::BEHAVIOR_LIMIT_FOREIGN ||
|
|
|
|
cookieBehavior == nsICookieService::BEHAVIOR_REJECT_TRACKER ||
|
2019-05-25 04:25:46 +03:00
|
|
|
cookieBehavior ==
|
|
|
|
nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN ||
|
2019-05-31 12:32:13 +03:00
|
|
|
StaticPrefs::network_cookie_thirdparty_sessionOnly() ||
|
2019-05-31 12:32:33 +03:00
|
|
|
StaticPrefs::network_cookie_thirdparty_nonsecureSessionOnly();
|
2010-10-19 20:37:03 +04:00
|
|
|
}
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
void CookieServiceChild::RecordDocumentCookie(nsCookie* aCookie,
|
|
|
|
const OriginAttributes& aAttrs) {
|
2017-08-03 14:00:41 +03:00
|
|
|
nsAutoCString baseDomain;
|
|
|
|
nsCookieService::GetBaseDomainFromHost(mTLDService, aCookie->Host(),
|
|
|
|
baseDomain);
|
|
|
|
|
|
|
|
nsCookieKey key(baseDomain, aAttrs);
|
2019-05-01 11:47:10 +03:00
|
|
|
CookiesList* cookiesList = nullptr;
|
2017-08-03 14:00:41 +03:00
|
|
|
mCookiesMap.Get(key, &cookiesList);
|
|
|
|
|
|
|
|
if (!cookiesList) {
|
|
|
|
cookiesList = mCookiesMap.LookupOrAdd(key);
|
|
|
|
}
|
|
|
|
for (uint32_t i = 0; i < cookiesList->Length(); i++) {
|
2019-05-01 11:47:10 +03:00
|
|
|
nsCookie* cookie = cookiesList->ElementAt(i);
|
2017-08-03 14:00:41 +03:00
|
|
|
if (cookie->Name().Equals(aCookie->Name()) &&
|
|
|
|
cookie->Host().Equals(aCookie->Host()) &&
|
|
|
|
cookie->Path().Equals(aCookie->Path())) {
|
2017-08-03 13:00:12 +03:00
|
|
|
if (cookie->Value().Equals(aCookie->Value()) &&
|
|
|
|
cookie->Expiry() == aCookie->Expiry() &&
|
|
|
|
cookie->IsSecure() == aCookie->IsSecure() &&
|
2018-04-08 20:52:05 +03:00
|
|
|
cookie->SameSite() == aCookie->SameSite() &&
|
2017-08-03 13:00:12 +03:00
|
|
|
cookie->IsSession() == aCookie->IsSession() &&
|
|
|
|
cookie->IsHttpOnly() == aCookie->IsHttpOnly()) {
|
|
|
|
cookie->SetLastAccessed(aCookie->LastAccessed());
|
|
|
|
return;
|
|
|
|
}
|
2017-08-03 14:00:41 +03:00
|
|
|
cookiesList->RemoveElementAt(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t currentTime = PR_Now() / PR_USEC_PER_SEC;
|
|
|
|
if (aCookie->Expiry() <= currentTime) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-26 18:39:33 +03:00
|
|
|
cookiesList->AppendElement(aCookie);
|
2017-08-03 14:00:41 +03:00
|
|
|
}
|
|
|
|
|
2019-05-31 12:36:44 +03:00
|
|
|
nsresult CookieServiceChild::GetCookieStringInternal(
|
|
|
|
nsIURI* aHostURI, nsIChannel* aChannel, nsACString& aCookieString) {
|
2010-03-26 02:02:28 +03:00
|
|
|
NS_ENSURE_ARG(aHostURI);
|
|
|
|
|
2019-05-31 12:36:44 +03:00
|
|
|
aCookieString.Truncate();
|
2010-03-26 02:02:28 +03:00
|
|
|
|
2015-02-24 23:54:40 +03:00
|
|
|
// Fast past: don't bother sending IPC messages about nullprincipal'd
|
|
|
|
// documents.
|
|
|
|
nsAutoCString scheme;
|
|
|
|
aHostURI->GetScheme(scheme);
|
|
|
|
if (scheme.EqualsLiteral("moz-nullprincipal")) return NS_OK;
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
// Asynchronously call the parent.
|
|
|
|
bool isForeign = true;
|
2019-03-08 12:04:34 +03:00
|
|
|
nsCOMPtr<nsILoadInfo> loadInfo = aChannel ? aChannel->LoadInfo() : nullptr;
|
|
|
|
if (RequireThirdPartyCheck(loadInfo)) {
|
2017-08-03 12:59:31 +03:00
|
|
|
mThirdPartyUtil->IsThirdPartyChannel(aChannel, aHostURI, &isForeign);
|
2019-03-08 12:04:34 +03:00
|
|
|
}
|
2018-04-08 20:52:05 +03:00
|
|
|
|
2018-06-20 20:38:22 +03:00
|
|
|
bool isTrackingResource = false;
|
2018-07-13 13:02:19 +03:00
|
|
|
bool firstPartyStorageAccessGranted = false;
|
2019-05-25 04:25:41 +03:00
|
|
|
uint32_t rejectedReason = 0;
|
2018-06-20 20:38:22 +03:00
|
|
|
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
|
|
|
if (httpChannel) {
|
2019-03-17 09:55:50 +03:00
|
|
|
isTrackingResource = httpChannel->IsTrackingResource();
|
2018-08-25 09:48:50 +03:00
|
|
|
// Check first-party storage access even for non-tracking resources, since
|
|
|
|
// we will need the result when computing the access rights for the reject
|
|
|
|
// foreign cookie behavior mode.
|
2018-07-13 13:02:19 +03:00
|
|
|
if (isForeign && AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
2019-05-25 04:25:41 +03:00
|
|
|
httpChannel, aHostURI, &rejectedReason)) {
|
2018-07-13 13:02:19 +03:00
|
|
|
firstPartyStorageAccessGranted = true;
|
|
|
|
}
|
2018-07-10 11:09:59 +03:00
|
|
|
}
|
|
|
|
|
2018-04-08 20:52:05 +03:00
|
|
|
bool isSafeTopLevelNav = NS_IsSafeTopLevelNav(aChannel);
|
2018-04-12 13:52:51 +03:00
|
|
|
bool isSameSiteForeign = NS_IsSameSiteForeign(aChannel, aHostURI);
|
2018-04-08 20:52:05 +03:00
|
|
|
|
2018-09-22 06:00:54 +03:00
|
|
|
GetCookieStringFromCookieHashTable(
|
|
|
|
aHostURI, isForeign, isTrackingResource, firstPartyStorageAccessGranted,
|
2019-05-31 12:36:44 +03:00
|
|
|
rejectedReason, isSafeTopLevelNav, isSameSiteForeign, aChannel,
|
|
|
|
aCookieString);
|
2010-03-26 02:02:28 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-31 12:36:44 +03:00
|
|
|
nsresult CookieServiceChild::SetCookieStringInternal(
|
|
|
|
nsIURI* aHostURI, nsIChannel* aChannel, const nsACString& aCookieString,
|
|
|
|
const nsACString& aServerTime, bool aFromHttp) {
|
2010-03-26 02:02:28 +03:00
|
|
|
NS_ENSURE_ARG(aHostURI);
|
|
|
|
|
2015-02-24 23:54:40 +03:00
|
|
|
// Fast past: don't bother sending IPC messages about nullprincipal'd
|
|
|
|
// documents.
|
|
|
|
nsAutoCString scheme;
|
|
|
|
aHostURI->GetScheme(scheme);
|
|
|
|
if (scheme.EqualsLiteral("moz-nullprincipal")) return NS_OK;
|
|
|
|
|
2010-10-19 20:37:03 +04:00
|
|
|
// Determine whether the request is foreign. Failure is acceptable.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isForeign = true;
|
2019-03-08 12:04:34 +03:00
|
|
|
nsCOMPtr<nsILoadInfo> loadInfo = aChannel ? aChannel->LoadInfo() : nullptr;
|
|
|
|
if (RequireThirdPartyCheck(loadInfo)) {
|
2010-10-19 20:37:03 +04:00
|
|
|
mThirdPartyUtil->IsThirdPartyChannel(aChannel, aHostURI, &isForeign);
|
2019-03-08 12:04:34 +03:00
|
|
|
}
|
2010-03-26 02:02:28 +03:00
|
|
|
|
2018-06-20 20:38:22 +03:00
|
|
|
bool isTrackingResource = false;
|
2018-07-13 13:02:19 +03:00
|
|
|
bool firstPartyStorageAccessGranted = false;
|
2019-05-25 04:25:41 +03:00
|
|
|
uint32_t rejectedReason = 0;
|
2018-06-20 20:38:22 +03:00
|
|
|
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
|
|
|
if (httpChannel) {
|
2019-03-17 09:55:50 +03:00
|
|
|
isTrackingResource = httpChannel->IsTrackingResource();
|
2018-08-25 09:48:50 +03:00
|
|
|
// Check first-party storage access even for non-tracking resources, since
|
|
|
|
// we will need the result when computing the access rights for the reject
|
|
|
|
// foreign cookie behavior mode.
|
2018-07-13 13:02:19 +03:00
|
|
|
if (isForeign && AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
2019-05-25 04:25:41 +03:00
|
|
|
httpChannel, aHostURI, &rejectedReason)) {
|
2018-07-13 13:02:19 +03:00
|
|
|
firstPartyStorageAccessGranted = true;
|
|
|
|
}
|
2018-06-20 20:38:22 +03:00
|
|
|
}
|
|
|
|
|
2019-05-31 12:36:44 +03:00
|
|
|
nsCString cookieString(aCookieString);
|
2010-03-26 02:02:28 +03:00
|
|
|
|
2018-04-12 13:52:51 +03:00
|
|
|
URIParams hostURIParams;
|
|
|
|
SerializeURI(aHostURI, hostURIParams);
|
|
|
|
|
2019-03-06 17:05:50 +03:00
|
|
|
Maybe<URIParams> channelURIParams;
|
2017-01-12 19:38:48 +03:00
|
|
|
mozilla::OriginAttributes attrs;
|
2016-09-09 13:26:14 +03:00
|
|
|
if (aChannel) {
|
2018-09-12 18:14:32 +03:00
|
|
|
nsCOMPtr<nsIURI> channelURI;
|
|
|
|
aChannel->GetURI(getter_AddRefs(channelURI));
|
|
|
|
SerializeURI(channelURI, channelURIParams);
|
|
|
|
|
2019-03-08 12:04:34 +03:00
|
|
|
MOZ_ASSERT(loadInfo);
|
2019-02-20 15:27:25 +03:00
|
|
|
attrs = loadInfo->GetOriginAttributes();
|
2019-04-12 08:30:43 +03:00
|
|
|
StoragePrincipalHelper::PrepareOriginAttributes(aChannel, attrs);
|
2018-09-12 18:14:32 +03:00
|
|
|
} else {
|
|
|
|
SerializeURI(nullptr, channelURIParams);
|
2016-09-09 13:26:14 +03:00
|
|
|
}
|
|
|
|
|
2019-03-08 12:04:34 +03:00
|
|
|
Maybe<LoadInfoArgs> optionalLoadInfoArgs;
|
|
|
|
LoadInfoToLoadInfoArgs(loadInfo, &optionalLoadInfoArgs);
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
// Asynchronously call the parent.
|
2019-05-31 12:32:51 +03:00
|
|
|
if (CanSend()) {
|
2019-03-08 12:04:34 +03:00
|
|
|
SendSetCookieString(hostURIParams, channelURIParams, optionalLoadInfoArgs,
|
|
|
|
isForeign, isTrackingResource,
|
2019-05-25 04:25:41 +03:00
|
|
|
firstPartyStorageAccessGranted, rejectedReason, attrs,
|
2019-05-31 12:36:44 +03:00
|
|
|
cookieString, nsCString(aServerTime), aFromHttp);
|
2017-08-22 10:48:00 +03:00
|
|
|
}
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
bool requireHostMatch;
|
|
|
|
nsCString baseDomain;
|
|
|
|
nsCookieService::GetBaseDomain(mTLDService, aHostURI, baseDomain,
|
|
|
|
requireHostMatch);
|
|
|
|
|
2019-03-08 12:04:34 +03:00
|
|
|
nsCOMPtr<nsICookieSettings> cookieSettings =
|
|
|
|
nsCookieService::GetCookieSettings(aChannel);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
CookieStatus cookieStatus = nsCookieService::CheckPrefs(
|
2019-05-31 12:32:33 +03:00
|
|
|
cookieSettings, aHostURI, isForeign, isTrackingResource,
|
|
|
|
firstPartyStorageAccessGranted, aCookieString,
|
2019-05-31 12:32:13 +03:00
|
|
|
CountCookiesFromHashTable(baseDomain, attrs), attrs, &rejectedReason);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
if (cookieStatus != STATUS_ACCEPTED &&
|
|
|
|
cookieStatus != STATUS_ACCEPT_SESSION) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-09-26 18:39:33 +03:00
|
|
|
nsCookieKey key(baseDomain, attrs);
|
2019-05-01 11:47:10 +03:00
|
|
|
CookiesList* cookies = mCookiesMap.Get(key);
|
2018-09-26 18:39:33 +03:00
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
nsCString serverTimeString(aServerTime);
|
|
|
|
int64_t serverTime = nsCookieService::ParseServerTime(serverTimeString);
|
|
|
|
bool moreCookies;
|
|
|
|
do {
|
2019-05-31 12:31:30 +03:00
|
|
|
CookieStruct cookieData;
|
2017-08-03 12:59:31 +03:00
|
|
|
bool canSetCookie = false;
|
|
|
|
moreCookies = nsCookieService::CanSetCookie(
|
2019-05-31 12:31:30 +03:00
|
|
|
aHostURI, key, cookieData, requireHostMatch, cookieStatus, cookieString,
|
|
|
|
serverTime, aFromHttp, aChannel, canSetCookie, mThirdPartyUtil);
|
2017-08-03 12:59:31 +03:00
|
|
|
|
2018-09-26 18:39:33 +03:00
|
|
|
// We need to see if the cookie we're setting would overwrite an httponly
|
|
|
|
// one. This would not affect anything we send over the net (those come from
|
|
|
|
// the parent, which already checks this), but script could see an
|
|
|
|
// inconsistent view of things.
|
|
|
|
if (cookies && canSetCookie && !aFromHttp) {
|
|
|
|
for (uint32_t i = 0; i < cookies->Length(); ++i) {
|
|
|
|
RefPtr<nsCookie> cookie = cookies->ElementAt(i);
|
2019-05-31 12:31:30 +03:00
|
|
|
if (cookie->Name().Equals(cookieData.name()) &&
|
|
|
|
cookie->Host().Equals(cookieData.host()) &&
|
|
|
|
cookie->Path().Equals(cookieData.path()) && cookie->IsHttpOnly()) {
|
2018-09-26 18:39:33 +03:00
|
|
|
// Can't overwrite an httponly cookie from a script context.
|
|
|
|
canSetCookie = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
if (canSetCookie) {
|
2019-03-08 12:04:34 +03:00
|
|
|
nsCOMPtr<nsICookiePermission> permissionService =
|
|
|
|
nsCookiePermission::GetOrCreate();
|
2019-05-31 12:31:30 +03:00
|
|
|
SetCookieInternal(cookieData, attrs, aChannel, aFromHttp,
|
2017-08-03 12:59:31 +03:00
|
|
|
permissionService);
|
|
|
|
}
|
|
|
|
|
|
|
|
// document.cookie can only set one cookie at a time.
|
|
|
|
if (!aFromHttp) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (moreCookies);
|
2010-03-26 02:02:28 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-19 20:37:03 +04:00
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
CookieServiceChild::Observe(nsISupports* aSubject, const char* aTopic,
|
|
|
|
const char16_t* aData) {
|
2018-04-26 17:39:13 +03:00
|
|
|
if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
|
|
|
|
if (mCookieTimer) {
|
|
|
|
mCookieTimer->Cancel();
|
|
|
|
mCookieTimer = nullptr;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (observerService) {
|
|
|
|
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
|
|
|
}
|
|
|
|
} else if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(aSubject);
|
|
|
|
if (prefBranch) {
|
|
|
|
PrefChanged(prefBranch);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(false, "unexpected topic!");
|
|
|
|
}
|
2010-10-19 20:37:03 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-03-26 02:02:28 +03:00
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
CookieServiceChild::GetCookieString(nsIURI* aHostURI, nsIChannel* aChannel,
|
2019-05-31 12:36:44 +03:00
|
|
|
nsACString& aCookieString) {
|
2017-02-13 21:04:21 +03:00
|
|
|
return GetCookieStringInternal(aHostURI, aChannel, aCookieString);
|
2010-03-26 02:02:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
CookieServiceChild::GetCookieStringFromHttp(nsIURI* aHostURI, nsIURI* aFirstURI,
|
|
|
|
nsIChannel* aChannel,
|
2019-05-31 12:36:44 +03:00
|
|
|
nsACString& aCookieString) {
|
2017-02-13 21:04:21 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2010-03-26 02:02:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
CookieServiceChild::SetCookieString(nsIURI* aHostURI, nsIPrompt* aPrompt,
|
2019-05-31 12:36:44 +03:00
|
|
|
const nsACString& aCookieString,
|
2019-05-01 11:47:10 +03:00
|
|
|
nsIChannel* aChannel) {
|
2019-05-31 12:36:44 +03:00
|
|
|
return SetCookieStringInternal(aHostURI, aChannel, aCookieString,
|
|
|
|
VoidCString(), false);
|
2010-03-26 02:02:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
CookieServiceChild::SetCookieStringFromHttp(nsIURI* aHostURI, nsIURI* aFirstURI,
|
|
|
|
nsIPrompt* aPrompt,
|
2019-05-31 12:36:44 +03:00
|
|
|
const nsACString& aCookieString,
|
|
|
|
const nsACString& aServerTime,
|
2019-05-01 11:47:10 +03:00
|
|
|
nsIChannel* aChannel) {
|
2017-05-20 07:47:59 +03:00
|
|
|
return SetCookieStringInternal(aHostURI, aChannel, aCookieString, aServerTime,
|
|
|
|
true);
|
2010-03-26 02:02:28 +03:00
|
|
|
}
|
|
|
|
|
2017-06-06 06:36:00 +03:00
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
CookieServiceChild::RunInTransaction(nsICookieTransactionCallback* aCallback) {
|
2017-06-06 06:36:00 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|