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"
|
2017-08-16 07:05:00 +03:00
|
|
|
#include "mozilla/SystemGroup.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"
|
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"
|
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
|
|
|
|
static const char kPrefCookieBehavior[] = "network.cookie.cookieBehavior";
|
|
|
|
static const char kPrefThirdPartySession[] =
|
|
|
|
"network.cookie.thirdparty.sessionOnly";
|
2017-02-17 06:27:49 +03:00
|
|
|
static const char kPrefThirdPartyNonsecureSession[] =
|
|
|
|
"network.cookie.thirdparty.nonsecureSessionOnly";
|
2017-08-03 12:59:31 +03:00
|
|
|
static const char kCookieLeaveSecurityAlone[] =
|
|
|
|
"network.cookie.leave-secure-alone";
|
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
|
|
|
|
|
|
|
CookieServiceChild::CookieServiceChild()
|
2015-07-17 09:01:00 +03:00
|
|
|
: mCookieBehavior(nsICookieService::BEHAVIOR_ACCEPT),
|
2010-10-19 20:37:03 +04:00
|
|
|
mThirdPartySession(false),
|
2017-02-17 06:27:49 +03:00
|
|
|
mThirdPartyNonsecureSession(false),
|
2017-08-03 12:59:31 +03:00
|
|
|
mLeaveSecureAlone(true),
|
2017-08-22 10:48:00 +03:00
|
|
|
mIPCOpen(false) {
|
2010-03-26 02:02:28 +03:00
|
|
|
NS_ASSERTION(IsNeckoChild(), "not a child process");
|
|
|
|
|
2017-05-26 04:08:00 +03:00
|
|
|
mozilla::dom::ContentChild *cc =
|
|
|
|
static_cast<mozilla::dom::ContentChild *>(gNeckoChild->Manager());
|
|
|
|
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);
|
|
|
|
|
2017-08-22 10:48:00 +03:00
|
|
|
mIPCOpen = true;
|
|
|
|
|
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) {
|
2011-10-17 18:59:28 +04:00
|
|
|
prefBranch->AddObserver(kPrefCookieBehavior, this, true);
|
|
|
|
prefBranch->AddObserver(kPrefThirdPartySession, this, true);
|
2017-02-17 06:27:49 +03:00
|
|
|
prefBranch->AddObserver(kPrefThirdPartyNonsecureSession, this, true);
|
2017-08-03 12:59:31 +03:00
|
|
|
prefBranch->AddObserver(kCookieLeaveSecurityAlone, this, true);
|
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()) {
|
|
|
|
CookiesList *cookiesList = iter.UserData();
|
|
|
|
CookiesList newCookiesList;
|
|
|
|
for (uint32_t i = 0; i < cookiesList->Length(); ++i) {
|
|
|
|
nsCookie *cookie = cookiesList->ElementAt(i);
|
|
|
|
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(),
|
|
|
|
cookie->OriginAttributesRef(), cookie->SameSite());
|
|
|
|
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
|
|
|
|
CookieServiceChild::Notify(nsITimer *aTimer) {
|
|
|
|
if (aTimer == mCookieTimer) {
|
|
|
|
MoveCookies();
|
|
|
|
} else {
|
|
|
|
MOZ_CRASH("Unknown timer");
|
|
|
|
}
|
|
|
|
return NS_OK;
|
2010-03-26 02:02:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CookieServiceChild::~CookieServiceChild() { gCookieService = nullptr; }
|
|
|
|
|
2017-08-22 10:48:00 +03:00
|
|
|
void CookieServiceChild::ActorDestroy(ActorDestroyReason why) {
|
|
|
|
mIPCOpen = false;
|
|
|
|
}
|
|
|
|
|
2017-08-03 14:00:41 +03:00
|
|
|
void CookieServiceChild::TrackCookieLoad(nsIChannel *aChannel) {
|
2017-08-22 10:48:00 +03:00
|
|
|
if (!mIPCOpen) {
|
|
|
|
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;
|
2017-08-03 14:00:41 +03:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
aChannel->GetURI(getter_AddRefs(uri));
|
|
|
|
if (RequireThirdPartyCheck()) {
|
|
|
|
mThirdPartyUtil->IsThirdPartyChannel(aChannel, uri, &isForeign);
|
|
|
|
}
|
2018-06-20 20:38:22 +03:00
|
|
|
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
|
|
|
if (httpChannel) {
|
|
|
|
isTrackingResource = httpChannel->GetIsTrackingResource();
|
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.
|
2019-01-22 22:46:10 +03:00
|
|
|
uint32_t rejectedReason = 0;
|
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
|
|
|
}
|
2017-08-03 14:00:41 +03:00
|
|
|
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
|
|
|
mozilla::OriginAttributes attrs;
|
|
|
|
if (loadInfo) {
|
|
|
|
attrs = loadInfo->GetOriginAttributes();
|
|
|
|
}
|
|
|
|
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,
|
2018-07-10 11:09:59 +03:00
|
|
|
firstPartyStorageAccessGranted, 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(
|
|
|
|
const CookieStruct &aCookie, const OriginAttributes &aAttrs) {
|
|
|
|
nsCString baseDomain;
|
|
|
|
nsCookieService::GetBaseDomainFromHost(mTLDService, aCookie.host(),
|
|
|
|
baseDomain);
|
|
|
|
nsCookieKey key(baseDomain, aAttrs);
|
|
|
|
CookiesList *cookiesList = nullptr;
|
|
|
|
mCookiesMap.Get(key, &cookiesList);
|
|
|
|
|
|
|
|
if (!cookiesList) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < cookiesList->Length(); i++) {
|
|
|
|
nsCookie *cookie = cookiesList->ElementAt(i);
|
|
|
|
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(
|
|
|
|
const CookieStruct &aCookie, const OriginAttributes &aAttrs) {
|
|
|
|
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,
|
2017-09-24 20:27:04 +03:00
|
|
|
aCookie.sameSite());
|
2017-08-03 13:00:12 +03:00
|
|
|
RecordDocumentCookie(cookie, aAttrs);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult CookieServiceChild::RecvRemoveBatchDeletedCookies(
|
|
|
|
nsTArray<CookieStruct> &&aCookiesList,
|
|
|
|
nsTArray<OriginAttributes> &&aAttrsList) {
|
|
|
|
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(
|
|
|
|
nsTArray<CookieStruct> &&aCookiesList, const OriginAttributes &aAttrs) {
|
|
|
|
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,
|
2017-09-24 20:27:04 +03:00
|
|
|
aCookiesList[i].sameSite());
|
2017-08-03 14:00:41 +03:00
|
|
|
RecordDocumentCookie(cookie, aAttrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2010-10-19 20:37:03 +04:00
|
|
|
void CookieServiceChild::PrefChanged(nsIPrefBranch *aPrefBranch) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t val;
|
2010-10-19 20:37:03 +04:00
|
|
|
if (NS_SUCCEEDED(aPrefBranch->GetIntPref(kPrefCookieBehavior, &val)))
|
2015-07-17 09:01:00 +03:00
|
|
|
mCookieBehavior = val >= nsICookieService::BEHAVIOR_ACCEPT &&
|
2018-09-21 08:31:41 +03:00
|
|
|
val <= nsICookieService::BEHAVIOR_LAST
|
2015-07-17 09:01:00 +03:00
|
|
|
? val
|
|
|
|
: nsICookieService::BEHAVIOR_ACCEPT;
|
2010-10-19 20:37:03 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool boolval;
|
2010-10-19 20:37:03 +04:00
|
|
|
if (NS_SUCCEEDED(aPrefBranch->GetBoolPref(kPrefThirdPartySession, &boolval)))
|
|
|
|
mThirdPartySession = !!boolval;
|
|
|
|
|
2017-02-17 06:27:49 +03:00
|
|
|
if (NS_SUCCEEDED(
|
|
|
|
aPrefBranch->GetBoolPref(kPrefThirdPartyNonsecureSession, &boolval)))
|
|
|
|
mThirdPartyNonsecureSession = boolval;
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
if (NS_SUCCEEDED(
|
|
|
|
aPrefBranch->GetBoolPref(kCookieLeaveSecurityAlone, &boolval)))
|
2017-10-03 09:37:11 +03:00
|
|
|
mLeaveSecureAlone = !!boolval;
|
2017-08-03 12:59:31 +03:00
|
|
|
|
2010-10-19 20:37:03 +04:00
|
|
|
if (!mThirdPartyUtil && RequireThirdPartyCheck()) {
|
|
|
|
mThirdPartyUtil = do_GetService(THIRDPARTYUTIL_CONTRACTID);
|
|
|
|
NS_ASSERTION(mThirdPartyUtil, "require ThirdPartyUtil service");
|
|
|
|
}
|
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(
|
2018-06-20 20:38:22 +03:00
|
|
|
nsIURI *aHostURI, bool aIsForeign, bool aIsTrackingResource,
|
2018-07-10 11:09:59 +03:00
|
|
|
bool aFirstPartyStorageAccessGranted, bool aIsSafeTopLevelNav,
|
2017-08-03 12:59:31 +03:00
|
|
|
bool aIsSameSiteForeign, const OriginAttributes &aOriginAttrs,
|
|
|
|
nsCString &aCookieString) {
|
|
|
|
nsCOMPtr<nsIEffectiveTLDService> TLDService =
|
|
|
|
do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
|
|
|
|
NS_ASSERTION(TLDService, "Can't get TLDService");
|
|
|
|
bool requireHostMatch;
|
|
|
|
nsAutoCString baseDomain;
|
|
|
|
nsCookieService::GetBaseDomain(TLDService, aHostURI, baseDomain,
|
|
|
|
requireHostMatch);
|
|
|
|
nsCookieKey key(baseDomain, aOriginAttrs);
|
|
|
|
CookiesList *cookiesList = nullptr;
|
|
|
|
mCookiesMap.Get(key, &cookiesList);
|
|
|
|
|
|
|
|
if (!cookiesList) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoCString hostFromURI, pathFromURI;
|
|
|
|
bool isSecure;
|
|
|
|
aHostURI->GetAsciiHost(hostFromURI);
|
2017-08-03 16:23:43 +03:00
|
|
|
aHostURI->GetPathQueryRef(pathFromURI);
|
2017-08-03 12:59:31 +03:00
|
|
|
aHostURI->SchemeIs("https", &isSecure);
|
|
|
|
int64_t currentTimeInUsec = PR_Now();
|
|
|
|
int64_t currentTime = currentTimeInUsec / PR_USEC_PER_SEC;
|
|
|
|
|
2018-09-05 18:00:15 +03:00
|
|
|
nsCOMPtr<nsICookiePermission> permissionService =
|
|
|
|
nsCookiePermission::GetOrCreate();
|
2017-08-03 12:59:31 +03:00
|
|
|
CookieStatus cookieStatus = nsCookieService::CheckPrefs(
|
|
|
|
permissionService, mCookieBehavior, mThirdPartySession,
|
2017-02-17 06:27:49 +03:00
|
|
|
mThirdPartyNonsecureSession, aHostURI, aIsForeign, aIsTrackingResource,
|
2018-07-10 11:09:59 +03:00
|
|
|
aFirstPartyStorageAccessGranted, nullptr,
|
2017-10-03 09:37:11 +03:00
|
|
|
CountCookiesFromHashTable(baseDomain, aOriginAttrs), aOriginAttrs,
|
2018-08-31 12:02:33 +03:00
|
|
|
nullptr);
|
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++) {
|
|
|
|
nsCookie *cookie = cookiesList->ElementAt(i);
|
|
|
|
// 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);
|
2018-04-14 04:52:28 +03:00
|
|
|
if (aIsSameSiteForeign && nsCookieService::IsSameSiteEnabled()) {
|
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
|
|
|
|
if (sameSiteAttr == nsICookie2::SAMESITE_STRICT) {
|
|
|
|
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
|
|
|
|
if (sameSiteAttr == nsICookie2::SAMESITE_LAX && !aIsSafeTopLevelNav) {
|
|
|
|
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(
|
|
|
|
const nsCString &aBaseDomain, const OriginAttributes &aOriginAttrs) {
|
|
|
|
CookiesList *cookiesList = nullptr;
|
|
|
|
|
|
|
|
nsCString baseDomain;
|
|
|
|
nsCookieKey key(aBaseDomain, aOriginAttrs);
|
|
|
|
mCookiesMap.Get(key, &cookiesList);
|
|
|
|
|
|
|
|
return cookiesList ? cookiesList->Length() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CookieServiceChild::SetCookieInternal(
|
|
|
|
nsCookieAttributes &aCookieAttributes,
|
|
|
|
const mozilla::OriginAttributes &aAttrs, nsIChannel *aChannel,
|
|
|
|
bool aFromHttp, nsICookiePermission *aPermissionService) {
|
|
|
|
int64_t currentTimeInUsec = PR_Now();
|
|
|
|
RefPtr<nsCookie> cookie = nsCookie::Create(
|
|
|
|
aCookieAttributes.name, aCookieAttributes.value, aCookieAttributes.host,
|
|
|
|
aCookieAttributes.path, aCookieAttributes.expiryTime, currentTimeInUsec,
|
|
|
|
nsCookie::GenerateUniqueCreationTime(currentTimeInUsec),
|
|
|
|
aCookieAttributes.isSession, aCookieAttributes.isSecure,
|
|
|
|
aCookieAttributes.isHttpOnly, aAttrs, aCookieAttributes.sameSite);
|
|
|
|
|
|
|
|
RecordDocumentCookie(cookie, aAttrs);
|
|
|
|
}
|
|
|
|
|
2010-10-19 20:37:03 +04:00
|
|
|
bool CookieServiceChild::RequireThirdPartyCheck() {
|
2015-07-17 09:01:00 +03:00
|
|
|
return mCookieBehavior == nsICookieService::BEHAVIOR_REJECT_FOREIGN ||
|
|
|
|
mCookieBehavior == nsICookieService::BEHAVIOR_LIMIT_FOREIGN ||
|
2018-08-25 09:47:34 +03:00
|
|
|
mCookieBehavior == nsICookieService::BEHAVIOR_REJECT_TRACKER ||
|
2017-02-17 06:27:49 +03:00
|
|
|
mThirdPartySession || mThirdPartyNonsecureSession;
|
2010-10-19 20:37:03 +04:00
|
|
|
}
|
|
|
|
|
2017-08-03 14:00:41 +03:00
|
|
|
void CookieServiceChild::RecordDocumentCookie(nsCookie *aCookie,
|
|
|
|
const OriginAttributes &aAttrs) {
|
|
|
|
nsAutoCString baseDomain;
|
|
|
|
nsCookieService::GetBaseDomainFromHost(mTLDService, aCookie->Host(),
|
|
|
|
baseDomain);
|
|
|
|
|
|
|
|
nsCookieKey key(baseDomain, aAttrs);
|
|
|
|
CookiesList *cookiesList = nullptr;
|
|
|
|
mCookiesMap.Get(key, &cookiesList);
|
|
|
|
|
|
|
|
if (!cookiesList) {
|
|
|
|
cookiesList = mCookiesMap.LookupOrAdd(key);
|
|
|
|
}
|
|
|
|
for (uint32_t i = 0; i < cookiesList->Length(); i++) {
|
|
|
|
nsCookie *cookie = cookiesList->ElementAt(i);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-03-26 02:02:28 +03:00
|
|
|
nsresult CookieServiceChild::GetCookieStringInternal(nsIURI *aHostURI,
|
|
|
|
nsIChannel *aChannel,
|
2017-02-13 21:04:21 +03:00
|
|
|
char **aCookieString) {
|
2010-03-26 02:02:28 +03:00
|
|
|
NS_ENSURE_ARG(aHostURI);
|
|
|
|
NS_ENSURE_ARG_POINTER(aCookieString);
|
|
|
|
|
2013-09-19 23:28:26 +04:00
|
|
|
*aCookieString = nullptr;
|
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;
|
|
|
|
|
2018-07-10 11:09:59 +03:00
|
|
|
nsCOMPtr<nsILoadInfo> loadInfo;
|
2017-01-12 19:38:48 +03:00
|
|
|
mozilla::OriginAttributes attrs;
|
2016-09-09 13:26:14 +03:00
|
|
|
if (aChannel) {
|
2018-07-10 11:09:59 +03:00
|
|
|
loadInfo = aChannel->GetLoadInfo();
|
2016-09-09 13:26:14 +03:00
|
|
|
if (loadInfo) {
|
|
|
|
attrs = loadInfo->GetOriginAttributes();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
// Asynchronously call the parent.
|
|
|
|
bool isForeign = true;
|
|
|
|
if (RequireThirdPartyCheck())
|
|
|
|
mThirdPartyUtil->IsThirdPartyChannel(aChannel, aHostURI, &isForeign);
|
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;
|
2018-06-20 20:38:22 +03:00
|
|
|
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
|
|
|
if (httpChannel) {
|
|
|
|
isTrackingResource = httpChannel->GetIsTrackingResource();
|
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(
|
2018-08-31 12:02:33 +03:00
|
|
|
httpChannel, aHostURI, nullptr)) {
|
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
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString result;
|
2018-09-22 06:00:54 +03:00
|
|
|
GetCookieStringFromCookieHashTable(
|
|
|
|
aHostURI, isForeign, isTrackingResource, firstPartyStorageAccessGranted,
|
|
|
|
isSafeTopLevelNav, isSameSiteForeign, attrs, result);
|
2017-08-03 14:00:41 +03:00
|
|
|
|
2010-03-26 02:02:28 +03:00
|
|
|
if (!result.IsEmpty()) *aCookieString = ToNewCString(result);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
|
|
|
|
nsIChannel *aChannel,
|
|
|
|
const char *aCookieString,
|
2017-05-20 07:47:59 +03:00
|
|
|
const char *aServerTime,
|
|
|
|
bool aFromHttp) {
|
2010-03-26 02:02:28 +03:00
|
|
|
NS_ENSURE_ARG(aHostURI);
|
|
|
|
NS_ENSURE_ARG_POINTER(aCookieString);
|
|
|
|
|
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;
|
2010-10-19 20:37:03 +04:00
|
|
|
if (RequireThirdPartyCheck())
|
|
|
|
mThirdPartyUtil->IsThirdPartyChannel(aChannel, aHostURI, &isForeign);
|
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;
|
2018-06-20 20:38:22 +03:00
|
|
|
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
|
|
|
if (httpChannel) {
|
|
|
|
isTrackingResource = httpChannel->GetIsTrackingResource();
|
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(
|
2018-08-31 12:02:33 +03:00
|
|
|
httpChannel, aHostURI, nullptr)) {
|
2018-07-13 13:02:19 +03:00
|
|
|
firstPartyStorageAccessGranted = true;
|
|
|
|
}
|
2018-06-20 20:38:22 +03:00
|
|
|
}
|
|
|
|
|
2010-03-26 02:02:28 +03:00
|
|
|
nsDependentCString cookieString(aCookieString);
|
2017-08-03 12:59:31 +03:00
|
|
|
nsDependentCString stringServerTime;
|
|
|
|
if (aServerTime) stringServerTime.Rebind(aServerTime);
|
2010-03-26 02:02:28 +03:00
|
|
|
|
2018-04-12 13:52:51 +03:00
|
|
|
URIParams hostURIParams;
|
|
|
|
SerializeURI(aHostURI, hostURIParams);
|
|
|
|
|
2018-09-12 18:14:32 +03:00
|
|
|
OptionalURIParams 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);
|
|
|
|
|
2016-09-09 13:26:14 +03:00
|
|
|
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
|
|
|
if (loadInfo) {
|
|
|
|
attrs = loadInfo->GetOriginAttributes();
|
|
|
|
}
|
2018-09-12 18:14:32 +03:00
|
|
|
} else {
|
|
|
|
SerializeURI(nullptr, channelURIParams);
|
2016-09-09 13:26:14 +03:00
|
|
|
}
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
// Asynchronously call the parent.
|
2017-08-22 10:48:00 +03:00
|
|
|
if (mIPCOpen) {
|
2018-04-12 13:52:51 +03:00
|
|
|
SendSetCookieString(hostURIParams, channelURIParams, isForeign,
|
2018-07-10 11:09:59 +03:00
|
|
|
isTrackingResource, firstPartyStorageAccessGranted,
|
2017-08-22 10:48:00 +03:00
|
|
|
cookieString, stringServerTime, attrs, aFromHttp);
|
|
|
|
}
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
bool requireHostMatch;
|
|
|
|
nsCString baseDomain;
|
|
|
|
nsCookieService::GetBaseDomain(mTLDService, aHostURI, baseDomain,
|
|
|
|
requireHostMatch);
|
|
|
|
|
2018-09-05 18:00:15 +03:00
|
|
|
nsCOMPtr<nsICookiePermission> permissionService =
|
|
|
|
nsCookiePermission::GetOrCreate();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
CookieStatus cookieStatus = nsCookieService::CheckPrefs(
|
|
|
|
permissionService, mCookieBehavior, mThirdPartySession,
|
2017-02-17 06:27:49 +03:00
|
|
|
mThirdPartyNonsecureSession, aHostURI, isForeign, isTrackingResource,
|
2018-07-10 11:09:59 +03:00
|
|
|
firstPartyStorageAccessGranted, aCookieString,
|
2017-10-03 09:37:11 +03:00
|
|
|
CountCookiesFromHashTable(baseDomain, attrs), attrs, nullptr);
|
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);
|
|
|
|
CookiesList *cookies = mCookiesMap.Get(key);
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
nsCString serverTimeString(aServerTime);
|
|
|
|
int64_t serverTime = nsCookieService::ParseServerTime(serverTimeString);
|
|
|
|
bool moreCookies;
|
|
|
|
do {
|
|
|
|
nsCookieAttributes cookieAttributes;
|
|
|
|
bool canSetCookie = false;
|
|
|
|
moreCookies = nsCookieService::CanSetCookie(
|
|
|
|
aHostURI, key, cookieAttributes, requireHostMatch, cookieStatus,
|
|
|
|
cookieString, serverTime, aFromHttp, aChannel, mLeaveSecureAlone,
|
2017-02-17 05:58:48 +03:00
|
|
|
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);
|
|
|
|
if (cookie->Name().Equals(cookieAttributes.name) &&
|
|
|
|
cookie->Host().Equals(cookieAttributes.host) &&
|
|
|
|
cookie->Path().Equals(cookieAttributes.path) &&
|
|
|
|
cookie->IsHttpOnly()) {
|
|
|
|
// Can't overwrite an httponly cookie from a script context.
|
|
|
|
canSetCookie = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 12:59:31 +03:00
|
|
|
if (canSetCookie) {
|
|
|
|
SetCookieInternal(cookieAttributes, attrs, aChannel, aFromHttp,
|
|
|
|
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
|
|
|
|
CookieServiceChild::Observe(nsISupports *aSubject, const char *aTopic,
|
2014-01-04 19:02:17 +04:00
|
|
|
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
|
|
|
|
CookieServiceChild::GetCookieString(nsIURI *aHostURI, nsIChannel *aChannel,
|
|
|
|
char **aCookieString) {
|
2017-02-13 21:04:21 +03:00
|
|
|
return GetCookieStringInternal(aHostURI, aChannel, aCookieString);
|
2010-03-26 02:02:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CookieServiceChild::GetCookieStringFromHttp(nsIURI *aHostURI, nsIURI *aFirstURI,
|
|
|
|
nsIChannel *aChannel,
|
|
|
|
char **aCookieString) {
|
2017-02-13 21:04:21 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2010-03-26 02:02:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CookieServiceChild::SetCookieString(nsIURI *aHostURI, nsIPrompt *aPrompt,
|
|
|
|
const char *aCookieString,
|
|
|
|
nsIChannel *aChannel) {
|
2017-05-20 07:47:59 +03:00
|
|
|
return SetCookieStringInternal(aHostURI, aChannel, aCookieString, nullptr,
|
|
|
|
false);
|
2010-03-26 02:02:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CookieServiceChild::SetCookieStringFromHttp(nsIURI *aHostURI, nsIURI *aFirstURI,
|
|
|
|
nsIPrompt *aPrompt,
|
|
|
|
const char *aCookieString,
|
|
|
|
const char *aServerTime,
|
2017-07-06 15:00:35 +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
|
|
|
|
CookieServiceChild::RunInTransaction(nsICookieTransactionCallback *aCallback) {
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|