mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1554377 - Cleanup nsCookie implementation - network.cookie.thirdparty.sessionOnly to StaticPrefs, r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D32614 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
ff8aaf2236
commit
1040f3de6a
@ -5718,6 +5718,13 @@ VARCACHE_PREF(
|
||||
RelaxedAtomicInt32, 0
|
||||
)
|
||||
|
||||
VARCACHE_PREF(
|
||||
Live,
|
||||
"network.cookie.thirdparty.sessionOnly",
|
||||
network_cookie_thirdparty_sessionOnly,
|
||||
bool, false
|
||||
)
|
||||
|
||||
// Enables the predictive service.
|
||||
VARCACHE_PREF(
|
||||
Live,
|
||||
|
@ -2327,7 +2327,6 @@ pref("network.proxy.no_proxies_on", "");
|
||||
pref("network.proxy.allow_hijacking_localhost", false);
|
||||
pref("network.proxy.failover_timeout", 1800); // 30 minutes
|
||||
pref("network.online", true); //online/offline
|
||||
pref("network.cookie.thirdparty.sessionOnly", false);
|
||||
pref("network.cookie.thirdparty.nonsecureSessionOnly", false);
|
||||
|
||||
// The interval in seconds to move the cookies in the child process.
|
||||
|
@ -37,8 +37,6 @@ namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
// Pref string constants
|
||||
static const char kPrefThirdPartySession[] =
|
||||
"network.cookie.thirdparty.sessionOnly";
|
||||
static const char kPrefThirdPartyNonsecureSession[] =
|
||||
"network.cookie.thirdparty.nonsecureSessionOnly";
|
||||
static const char kCookieMoveIntervalSecs[] =
|
||||
@ -60,9 +58,7 @@ NS_IMPL_ISUPPORTS(CookieServiceChild, nsICookieService, nsIObserver,
|
||||
nsITimerCallback, nsISupportsWeakReference)
|
||||
|
||||
CookieServiceChild::CookieServiceChild()
|
||||
: mThirdPartySession(false),
|
||||
mThirdPartyNonsecureSession(false),
|
||||
mIPCOpen(false) {
|
||||
: mThirdPartyNonsecureSession(false), mIPCOpen(false) {
|
||||
NS_ASSERTION(IsNeckoChild(), "not a child process");
|
||||
|
||||
mozilla::dom::ContentChild* cc =
|
||||
@ -91,7 +87,6 @@ CookieServiceChild::CookieServiceChild()
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
NS_WARNING_ASSERTION(prefBranch, "no prefservice");
|
||||
if (prefBranch) {
|
||||
prefBranch->AddObserver(kPrefThirdPartySession, this, true);
|
||||
prefBranch->AddObserver(kPrefThirdPartyNonsecureSession, this, true);
|
||||
prefBranch->AddObserver(kCookieMoveIntervalSecs, this, true);
|
||||
PrefChanged(prefBranch);
|
||||
@ -256,9 +251,6 @@ mozilla::ipc::IPCResult CookieServiceChild::RecvTrackCookiesLoad(
|
||||
|
||||
void CookieServiceChild::PrefChanged(nsIPrefBranch* aPrefBranch) {
|
||||
bool boolval;
|
||||
if (NS_SUCCEEDED(aPrefBranch->GetBoolPref(kPrefThirdPartySession, &boolval)))
|
||||
mThirdPartySession = !!boolval;
|
||||
|
||||
if (NS_SUCCEEDED(
|
||||
aPrefBranch->GetBoolPref(kPrefThirdPartyNonsecureSession, &boolval)))
|
||||
mThirdPartyNonsecureSession = boolval;
|
||||
@ -322,8 +314,8 @@ void CookieServiceChild::GetCookieStringFromCookieHashTable(
|
||||
nsCookieService::GetCookieSettings(aChannel);
|
||||
|
||||
CookieStatus cookieStatus = nsCookieService::CheckPrefs(
|
||||
cookieSettings, mThirdPartySession, mThirdPartyNonsecureSession, aHostURI,
|
||||
aIsForeign, aIsTrackingResource, aFirstPartyStorageAccessGranted, nullptr,
|
||||
cookieSettings, mThirdPartyNonsecureSession, aHostURI, aIsForeign,
|
||||
aIsTrackingResource, aFirstPartyStorageAccessGranted, nullptr,
|
||||
CountCookiesFromHashTable(baseDomain, attrs), attrs, &aRejectedReason);
|
||||
|
||||
if (cookieStatus != STATUS_ACCEPTED &&
|
||||
@ -426,7 +418,8 @@ bool CookieServiceChild::RequireThirdPartyCheck(nsILoadInfo* aLoadInfo) {
|
||||
cookieBehavior == nsICookieService::BEHAVIOR_REJECT_TRACKER ||
|
||||
cookieBehavior ==
|
||||
nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN ||
|
||||
mThirdPartySession || mThirdPartyNonsecureSession;
|
||||
StaticPrefs::network_cookie_thirdparty_sessionOnly() ||
|
||||
mThirdPartyNonsecureSession;
|
||||
}
|
||||
|
||||
void CookieServiceChild::RecordDocumentCookie(nsCookie* aCookie,
|
||||
@ -595,10 +588,9 @@ nsresult CookieServiceChild::SetCookieStringInternal(nsIURI* aHostURI,
|
||||
nsCookieService::GetCookieSettings(aChannel);
|
||||
|
||||
CookieStatus cookieStatus = nsCookieService::CheckPrefs(
|
||||
cookieSettings, mThirdPartySession, mThirdPartyNonsecureSession, aHostURI,
|
||||
isForeign, isTrackingResource, firstPartyStorageAccessGranted,
|
||||
aCookieString, CountCookiesFromHashTable(baseDomain, attrs), attrs,
|
||||
&rejectedReason);
|
||||
cookieSettings, mThirdPartyNonsecureSession, aHostURI, isForeign,
|
||||
isTrackingResource, firstPartyStorageAccessGranted, aCookieString,
|
||||
CountCookiesFromHashTable(baseDomain, attrs), attrs, &rejectedReason);
|
||||
|
||||
if (cookieStatus != STATUS_ACCEPTED &&
|
||||
cookieStatus != STATUS_ACCEPT_SESSION) {
|
||||
|
@ -104,7 +104,6 @@ class CookieServiceChild : public PCookieServiceChild,
|
||||
nsCOMPtr<nsITimer> mCookieTimer;
|
||||
nsCOMPtr<mozIThirdPartyUtil> mThirdPartyUtil;
|
||||
nsCOMPtr<nsIEffectiveTLDService> mTLDService;
|
||||
bool mThirdPartySession;
|
||||
bool mThirdPartyNonsecureSession;
|
||||
bool mIPCOpen;
|
||||
};
|
||||
|
@ -130,8 +130,6 @@ static const char kPrefMaxNumberOfCookies[] = "network.cookie.maxNumber";
|
||||
static const char kPrefMaxCookiesPerHost[] = "network.cookie.maxPerHost";
|
||||
static const char kPrefCookieQuotaPerHost[] = "network.cookie.quotaPerHost";
|
||||
static const char kPrefCookiePurgeAge[] = "network.cookie.purgeAge";
|
||||
static const char kPrefThirdPartySession[] =
|
||||
"network.cookie.thirdparty.sessionOnly";
|
||||
static const char kPrefThirdPartyNonsecureSession[] =
|
||||
"network.cookie.thirdparty.nonsecureSessionOnly";
|
||||
|
||||
@ -586,7 +584,6 @@ NS_IMPL_ISUPPORTS(nsCookieService, nsICookieService, nsICookieManager,
|
||||
|
||||
nsCookieService::nsCookieService()
|
||||
: mDBState(nullptr),
|
||||
mThirdPartySession(false),
|
||||
mThirdPartyNonsecureSession(false),
|
||||
mMaxNumberOfCookies(kMaxNumberOfCookies),
|
||||
mMaxCookiesPerHost(kMaxCookiesPerHost),
|
||||
@ -614,7 +611,6 @@ nsresult nsCookieService::Init() {
|
||||
prefBranch->AddObserver(kPrefMaxNumberOfCookies, this, true);
|
||||
prefBranch->AddObserver(kPrefMaxCookiesPerHost, this, true);
|
||||
prefBranch->AddObserver(kPrefCookiePurgeAge, this, true);
|
||||
prefBranch->AddObserver(kPrefThirdPartySession, this, true);
|
||||
prefBranch->AddObserver(kPrefThirdPartyNonsecureSession, this, true);
|
||||
PrefChanged(prefBranch);
|
||||
}
|
||||
@ -2177,9 +2173,9 @@ void nsCookieService::SetCookieStringInternal(
|
||||
aHostURI->GetHost(hostFromURI);
|
||||
CountCookiesFromHost(hostFromURI, &priorCookieCount);
|
||||
CookieStatus cookieStatus = CheckPrefs(
|
||||
cookieSettings, mThirdPartySession, mThirdPartyNonsecureSession, aHostURI,
|
||||
aIsForeign, aIsTrackingResource, aFirstPartyStorageAccessGranted,
|
||||
aCookieHeader.get(), priorCookieCount, aOriginAttrs, &rejectedReason);
|
||||
cookieSettings, mThirdPartyNonsecureSession, aHostURI, aIsForeign,
|
||||
aIsTrackingResource, aFirstPartyStorageAccessGranted, aCookieHeader.get(),
|
||||
priorCookieCount, aOriginAttrs, &rejectedReason);
|
||||
|
||||
MOZ_ASSERT_IF(rejectedReason, cookieStatus == STATUS_REJECTED);
|
||||
|
||||
@ -2350,9 +2346,6 @@ void nsCookieService::PrefChanged(nsIPrefBranch* aPrefBranch) {
|
||||
}
|
||||
|
||||
bool boolval;
|
||||
if (NS_SUCCEEDED(aPrefBranch->GetBoolPref(kPrefThirdPartySession, &boolval)))
|
||||
mThirdPartySession = boolval;
|
||||
|
||||
if (NS_SUCCEEDED(
|
||||
aPrefBranch->GetBoolPref(kPrefThirdPartyNonsecureSession, &boolval)))
|
||||
mThirdPartyNonsecureSession = boolval;
|
||||
@ -3004,8 +2997,8 @@ void nsCookieService::GetCookiesForURI(
|
||||
uint32_t priorCookieCount = 0;
|
||||
CountCookiesFromHost(hostFromURI, &priorCookieCount);
|
||||
CookieStatus cookieStatus = CheckPrefs(
|
||||
cookieSettings, mThirdPartySession, mThirdPartyNonsecureSession, aHostURI,
|
||||
aIsForeign, aIsTrackingResource, aFirstPartyStorageAccessGranted, nullptr,
|
||||
cookieSettings, mThirdPartyNonsecureSession, aHostURI, aIsForeign,
|
||||
aIsTrackingResource, aFirstPartyStorageAccessGranted, nullptr,
|
||||
priorCookieCount, aOriginAttrs, &rejectedReason);
|
||||
|
||||
MOZ_ASSERT_IF(rejectedReason, cookieStatus == STATUS_REJECTED);
|
||||
@ -3938,11 +3931,11 @@ static inline bool IsSubdomainOf(const nsCString& a, const nsCString& b) {
|
||||
}
|
||||
|
||||
CookieStatus nsCookieService::CheckPrefs(
|
||||
nsICookieSettings* aCookieSettings, bool aThirdPartySession,
|
||||
bool aThirdPartyNonsecureSession, nsIURI* aHostURI, bool aIsForeign,
|
||||
bool aIsTrackingResource, bool aFirstPartyStorageAccessGranted,
|
||||
const char* aCookieHeader, const int aNumOfCookies,
|
||||
const OriginAttributes& aOriginAttrs, uint32_t* aRejectedReason) {
|
||||
nsICookieSettings* aCookieSettings, bool aThirdPartyNonsecureSession,
|
||||
nsIURI* aHostURI, bool aIsForeign, bool aIsTrackingResource,
|
||||
bool aFirstPartyStorageAccessGranted, const char* aCookieHeader,
|
||||
const int aNumOfCookies, const OriginAttributes& aOriginAttrs,
|
||||
uint32_t* aRejectedReason) {
|
||||
nsresult rv;
|
||||
|
||||
MOZ_ASSERT(aRejectedReason);
|
||||
@ -4037,7 +4030,9 @@ CookieStatus nsCookieService::CheckPrefs(
|
||||
return STATUS_REJECTED;
|
||||
}
|
||||
|
||||
if (aThirdPartySession) return STATUS_ACCEPT_SESSION;
|
||||
if (StaticPrefs::network_cookie_thirdparty_sessionOnly()) {
|
||||
return STATUS_ACCEPT_SESSION;
|
||||
}
|
||||
|
||||
if (aThirdPartyNonsecureSession) {
|
||||
bool isHTTPS = false;
|
||||
|
@ -213,11 +213,11 @@ class nsCookieService final : public nsICookieService,
|
||||
nsIChannel* aChannel, bool& aSetCookie,
|
||||
mozIThirdPartyUtil* aThirdPartyUtil);
|
||||
static CookieStatus CheckPrefs(
|
||||
nsICookieSettings* aCookieSettings, bool aThirdPartySession,
|
||||
bool aThirdPartyNonsecureSession, nsIURI* aHostURI, bool aIsForeign,
|
||||
bool aIsTrackingResource, bool aIsFirstPartyStorageAccessGranted,
|
||||
const char* aCookieHeader, const int aNumOfCookies,
|
||||
const OriginAttributes& aOriginAttrs, uint32_t* aRejectedReason);
|
||||
nsICookieSettings* aCookieSettings, bool aThirdPartyNonsecureSession,
|
||||
nsIURI* aHostURI, bool aIsForeign, bool aIsTrackingResource,
|
||||
bool aIsFirstPartyStorageAccessGranted, const char* aCookieHeader,
|
||||
const int aNumOfCookies, const OriginAttributes& aOriginAttrs,
|
||||
uint32_t* aRejectedReason);
|
||||
static int64_t ParseServerTime(const nsCString& aServerTime);
|
||||
|
||||
static already_AddRefed<nsICookieSettings> GetCookieSettings(
|
||||
@ -368,7 +368,6 @@ class nsCookieService final : public nsICookieService,
|
||||
RefPtr<DBState> mDefaultDBState;
|
||||
RefPtr<DBState> mPrivateDBState;
|
||||
|
||||
bool mThirdPartySession;
|
||||
bool mThirdPartyNonsecureSession;
|
||||
uint16_t mMaxNumberOfCookies;
|
||||
uint16_t mMaxCookiesPerHost;
|
||||
|
Loading…
Reference in New Issue
Block a user