Bug 1616570 - Part 1: Rename CookieSettings to CookieJarSettings. r=Ehsan

Given that we are going to add ContentBlockingAllowList in
CookieSettings, so CookieSettings will be responsible for more stuff than the
cookie behavior and cookie permission. We should use a proper name to
reflect the purpose of it. The name 'CookieSettings' is misleading that
this is only for cookie related stuff. So, we decide to rename
'CookieSettins' to 'CookieJarSettings' which serves better meaning here.

Differential Revision: https://phabricator.services.mozilla.com/D63935

--HG--
rename : netwerk/cookie/CookieSettings.cpp => netwerk/cookie/CookieJarSettings.cpp
rename : netwerk/cookie/nsICookieSettings.idl => netwerk/cookie/nsICookieJarSettings.idl
extra : moz-landing-system : lando
This commit is contained in:
Tim Huang 2020-03-04 08:59:08 +00:00
parent d4bc188504
commit 04d44bae12
113 changed files with 723 additions and 696 deletions

View File

@ -21,7 +21,9 @@ XPCOMUtils.defineLazyServiceGetter(
function restore_prefs() {
Services.prefs.clearUserPref("network.cookie.cookieBehavior");
Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
Services.prefs.clearUserPref("network.cookieSettings.unblocked_for_testing");
Services.prefs.clearUserPref(
"network.cookieJarSettings.unblocked_for_testing"
);
}
registerCleanupFunction(restore_prefs);
@ -52,7 +54,7 @@ async function test_cookie_settings({
thirdPartyCookiesEnabled,
cookiesExpireAfterSession,
rejectTrackers,
cookieSettingsLocked,
cookieJarSettingsLocked,
}) {
let firstPartyURI = NetUtil.newURI("http://example.com/");
let thirdPartyURI = NetUtil.newURI("http://example.org/");
@ -111,12 +113,12 @@ async function test_cookie_settings({
is(
Services.prefs.prefIsLocked("network.cookie.cookieBehavior"),
cookieSettingsLocked,
cookieJarSettingsLocked,
"Cookie behavior pref lock status should be what is expected"
);
is(
Services.prefs.prefIsLocked("network.cookie.lifetimePolicy"),
cookieSettingsLocked,
cookieJarSettingsLocked,
"Cookie lifetime pref lock status should be what is expected"
);
@ -127,9 +129,9 @@ async function test_cookie_settings({
await tab.linkedBrowser.contentWindow.gotoPref("panePrivacy");
await SpecialPowers.spawn(
tab.linkedBrowser,
[{ cookiesEnabled, cookieSettingsLocked }],
[{ cookiesEnabled, cookieJarSettingsLocked }],
// eslint-disable-next-line no-shadow
async function({ cookiesEnabled, cookieSettingsLocked }) {
async function({ cookiesEnabled, cookieJarSettingsLocked }) {
let deleteOnCloseCheckbox = content.document.getElementById(
"deleteOnClose"
);
@ -139,7 +141,7 @@ async function test_cookie_settings({
"deleteOnCloseCheckbox should not be null."
);
let expectControlsDisabled = !cookiesEnabled || cookieSettingsLocked;
let expectControlsDisabled = !cookiesEnabled || cookieJarSettingsLocked;
is(
deleteOnCloseCheckbox.disabled,
expectControlsDisabled,
@ -197,14 +199,14 @@ add_task(async function prepare_tracker_tables() {
add_task(async function test_initial_state() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
await test_cookie_settings({
cookiesEnabled: true,
thirdPartyCookiesEnabled: true,
cookiesExpireAfterSession: false,
cookieSettingsLocked: false,
cookieJarSettingsLocked: false,
});
restore_prefs();
});
@ -213,7 +215,7 @@ add_task(async function test_undefined_unlocked() {
Services.prefs.setIntPref("network.cookie.cookieBehavior", 3);
Services.prefs.setIntPref("network.cookie.lifetimePolicy", 2);
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
await setupPolicyEngineWithJson({
@ -236,7 +238,7 @@ add_task(async function test_undefined_unlocked() {
add_task(async function test_disabled() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
await setupPolicyEngineWithJson({
@ -251,14 +253,14 @@ add_task(async function test_disabled() {
cookiesEnabled: false,
thirdPartyCookiesEnabled: true,
cookiesExpireAfterSession: false,
cookieSettingsLocked: false,
cookieJarSettingsLocked: false,
});
restore_prefs();
});
add_task(async function test_third_party_disabled() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
await setupPolicyEngineWithJson({
@ -273,14 +275,14 @@ add_task(async function test_third_party_disabled() {
cookiesEnabled: true,
thirdPartyCookiesEnabled: false,
cookiesExpireAfterSession: false,
cookieSettingsLocked: false,
cookieJarSettingsLocked: false,
});
restore_prefs();
});
add_task(async function test_disabled_and_third_party_disabled() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
await setupPolicyEngineWithJson({
@ -296,14 +298,14 @@ add_task(async function test_disabled_and_third_party_disabled() {
cookiesEnabled: false,
thirdPartyCookiesEnabled: false,
cookiesExpireAfterSession: false,
cookieSettingsLocked: false,
cookieJarSettingsLocked: false,
});
restore_prefs();
});
add_task(async function test_disabled_and_third_party_disabled_locked() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
await setupPolicyEngineWithJson({
@ -320,14 +322,14 @@ add_task(async function test_disabled_and_third_party_disabled_locked() {
cookiesEnabled: false,
thirdPartyCookiesEnabled: false,
cookiesExpireAfterSession: false,
cookieSettingsLocked: true,
cookieJarSettingsLocked: true,
});
restore_prefs();
});
add_task(async function test_undefined_locked() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
await setupPolicyEngineWithJson({
@ -342,14 +344,14 @@ add_task(async function test_undefined_locked() {
cookiesEnabled: true,
thirdPartyCookiesEnabled: true,
cookiesExpireAfterSession: false,
cookieSettingsLocked: true,
cookieJarSettingsLocked: true,
});
restore_prefs();
});
add_task(async function test_cookie_expire() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
await setupPolicyEngineWithJson({
@ -364,14 +366,14 @@ add_task(async function test_cookie_expire() {
cookiesEnabled: true,
thirdPartyCookiesEnabled: true,
cookiesExpireAfterSession: true,
cookieSettingsLocked: false,
cookieJarSettingsLocked: false,
});
restore_prefs();
});
add_task(async function test_cookie_reject_trackers() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
await setupPolicyEngineWithJson({
@ -387,14 +389,14 @@ add_task(async function test_cookie_reject_trackers() {
thirdPartyCookiesEnabled: true,
cookiesExpireAfterSession: false,
rejectTrackers: true,
cookieSettingsLocked: false,
cookieJarSettingsLocked: false,
});
restore_prefs();
});
add_task(async function test_cookie_expire_locked() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
await setupPolicyEngineWithJson({
@ -410,14 +412,14 @@ add_task(async function test_cookie_expire_locked() {
cookiesEnabled: true,
thirdPartyCookiesEnabled: true,
cookiesExpireAfterSession: true,
cookieSettingsLocked: true,
cookieJarSettingsLocked: true,
});
restore_prefs();
});
add_task(async function test_disabled_cookie_expire_locked() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
await setupPolicyEngineWithJson({
@ -435,7 +437,7 @@ add_task(async function test_disabled_cookie_expire_locked() {
cookiesEnabled: false,
thirdPartyCookiesEnabled: false,
cookiesExpireAfterSession: true,
cookieSettingsLocked: true,
cookieJarSettingsLocked: true,
});
restore_prefs();
});

View File

@ -125,7 +125,7 @@
#include "mozilla/dom/StyleSheetList.h"
#include "mozilla/dom/SVGUseElement.h"
#include "mozilla/dom/UserActivation.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "nsGenericHTMLElement.h"
#include "mozilla/dom/CDATASection.h"
#include "mozilla/dom/ProcessingInstruction.h"
@ -3211,7 +3211,7 @@ nsresult Document::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
rv = InitFeaturePolicy(aChannel);
NS_ENSURE_SUCCESS(rv, rv);
rv = loadInfo->GetCookieSettings(getter_AddRefs(mCookieSettings));
rv = loadInfo->GetCookieJarSettings(getter_AddRefs(mCookieJarSettings));
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -5680,7 +5680,7 @@ void Document::GetCookie(nsAString& aCookie, ErrorResult& rv) {
}
if (ShouldPartitionStorage(storageAccess) &&
!StoragePartitioningEnabled(storageAccess, CookieSettings())) {
!StoragePartitioningEnabled(storageAccess, CookieJarSettings())) {
return;
}
@ -5739,7 +5739,7 @@ void Document::SetCookie(const nsAString& aCookie, ErrorResult& rv) {
}
if (ShouldPartitionStorage(storageAccess) &&
!StoragePartitioningEnabled(storageAccess, CookieSettings())) {
!StoragePartitioningEnabled(storageAccess, CookieJarSettings())) {
return;
}
@ -14999,7 +14999,7 @@ DocumentAutoplayPolicy Document::AutoplayPolicy() const {
}
void Document::MaybeAllowStorageForOpenerAfterUserInteraction() {
if (!CookieSettings()->GetRejectThirdPartyTrackers()) {
if (!CookieJarSettings()->GetRejectThirdPartyTrackers()) {
return;
}
@ -15567,7 +15567,7 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
}
// Only enforce third-party checks when there is a reason to enforce them.
if (!CookieSettings()->GetRejectThirdPartyTrackers()) {
if (!CookieJarSettings()->GetRejectThirdPartyTrackers()) {
// Step 3. If the document's frame is the main frame, resolve.
if (IsTopLevelContentDocument()) {
promise->MaybeResolveWithUndefined();
@ -15612,7 +15612,7 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
// user settings, anti-clickjacking heuristics, or prompting the
// user for explicit permission. Reject if some rule is not fulfilled.
if (CookieSettings()->GetRejectThirdPartyTrackers()) {
if (CookieJarSettings()->GetRejectThirdPartyTrackers()) {
// Only do something special for third-party tracking content.
if (StorageDisabledByAntiTracking(this, nullptr)) {
// Note: If this has returned true, the top-level document is guaranteed
@ -16006,20 +16006,20 @@ void Document::RecomputeLanguageFromCharset() {
mLanguageFromCharset = std::move(language);
}
nsICookieSettings* Document::CookieSettings() {
nsICookieJarSettings* Document::CookieJarSettings() {
// If we are here, this is probably a javascript: URL document. In any case,
// we must have a nsCookieSettings. Let's create it.
if (!mCookieSettings) {
// we must have a nsCookieJarSettings. Let's create it.
if (!mCookieJarSettings) {
Document* inProcessParent = GetInProcessParentDocument();
mCookieSettings =
mCookieJarSettings =
inProcessParent
? net::CookieSettings::Create(
inProcessParent->CookieSettings()->GetCookieBehavior())
: net::CookieSettings::Create();
? net::CookieJarSettings::Create(
inProcessParent->CookieJarSettings()->GetCookieBehavior())
: net::CookieJarSettings::Create();
}
return mCookieSettings;
return mCookieJarSettings;
}
nsIPrincipal* Document::EffectiveStoragePrincipal() const {
@ -16046,7 +16046,7 @@ nsIPrincipal* Document::EffectiveStoragePrincipal() const {
// normal principal will be used.
if (ShouldPartitionStorage(rejectedReason) &&
!StoragePartitioningEnabled(
rejectedReason, const_cast<Document*>(this)->CookieSettings())) {
rejectedReason, const_cast<Document*>(this)->CookieJarSettings())) {
return mActiveStoragePrincipal = NodePrincipal();
}

View File

@ -15,7 +15,7 @@
#include "nsCOMArray.h" // for member
#include "nsCompatibility.h" // for member
#include "nsCOMPtr.h" // for member
#include "nsICookieSettings.h"
#include "nsICookieJarSettings.h"
#include "nsGkAtoms.h" // for static class members
#include "nsNameSpaceManager.h" // for static class members
#include "nsIApplicationCache.h"
@ -1425,8 +1425,8 @@ class Document : public nsINode,
// flag.
bool StorageAccessSandboxed() const;
// Returns the cookie settings for this and sub contexts.
nsICookieSettings* CookieSettings();
// Returns the cookie jar settings for this and sub contexts.
nsICookieJarSettings* CookieJarSettings();
// Increments the document generation.
inline void Changed() { ++mGeneration; }
@ -5054,7 +5054,7 @@ class Document : public nsINode,
bool mPendingInitialTranslation;
nsCOMPtr<nsICookieSettings> mCookieSettings;
nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;
// Document generation. Gets incremented everytime it changes.
int32_t mGeneration;

View File

@ -83,7 +83,7 @@ class EventSourceImpl final : public nsIObserver,
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
EventSourceImpl(EventSource* aEventSource,
nsICookieSettings* aCookieSettings);
nsICookieJarSettings* aCookieJarSettings);
enum { CONNECTING = 0U, OPEN = 1U, CLOSED = 2U };
@ -291,7 +291,7 @@ class EventSourceImpl final : public nsIObserver,
uint64_t mInnerWindowID;
private:
nsCOMPtr<nsICookieSettings> mCookieSettings;
nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;
// Pointer to the target thread for checking whether we are
// on the target thread. This is intentionally a non-owning
@ -319,7 +319,7 @@ NS_IMPL_ISUPPORTS(EventSourceImpl, nsIObserver, nsIStreamListener,
nsIEventTarget, nsIThreadRetargetableStreamListener)
EventSourceImpl::EventSourceImpl(EventSource* aEventSource,
nsICookieSettings* aCookieSettings)
nsICookieJarSettings* aCookieJarSettings)
: mEventSource(aEventSource),
mReconnectionTime(0),
mStatus(PARSE_STATE_OFF),
@ -331,7 +331,7 @@ EventSourceImpl::EventSourceImpl(EventSource* aEventSource,
mScriptLine(0),
mScriptColumn(0),
mInnerWindowID(0),
mCookieSettings(aCookieSettings),
mCookieJarSettings(aCookieJarSettings),
mTargetThread(NS_GetCurrentThread()) {
MOZ_ASSERT(mEventSource);
if (!mIsMainThread) {
@ -973,7 +973,7 @@ nsresult EventSourceImpl::InitChannelAndRequestEventSource() {
nsCOMPtr<nsIChannel> channel;
// If we have the document, use it
if (doc) {
MOZ_ASSERT(mCookieSettings == doc->CookieSettings());
MOZ_ASSERT(mCookieJarSettings == doc->CookieJarSettings());
nsCOMPtr<nsILoadGroup> loadGroup = doc->GetDocumentLoadGroup();
rv = NS_NewChannel(getter_AddRefs(channel), mSrc, doc, securityFlags,
@ -986,7 +986,7 @@ nsresult EventSourceImpl::InitChannelAndRequestEventSource() {
// otherwise use the principal
rv = NS_NewChannel(getter_AddRefs(channel), mSrc, mPrincipal, securityFlags,
nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE,
mCookieSettings,
mCookieJarSettings,
nullptr, // aPerformanceStorage
nullptr, // loadGroup
nullptr, // aCallbacks
@ -1772,15 +1772,15 @@ EventSourceImpl::CheckListenerChain() {
////////////////////////////////////////////////////////////////////////////////
EventSource::EventSource(nsIGlobalObject* aGlobal,
nsICookieSettings* aCookieSettings,
nsICookieJarSettings* aCookieJarSettings,
bool aWithCredentials)
: DOMEventTargetHelper(aGlobal),
mWithCredentials(aWithCredentials),
mIsMainThread(true),
mKeepingAlive(false) {
MOZ_ASSERT(aGlobal);
MOZ_ASSERT(aCookieSettings);
mImpl = new EventSourceImpl(this, aCookieSettings);
MOZ_ASSERT(aCookieJarSettings);
mImpl = new EventSourceImpl(this, aCookieJarSettings);
}
EventSource::~EventSource() = default;
@ -1805,7 +1805,7 @@ already_AddRefed<EventSource> EventSource::Constructor(
return nullptr;
}
nsCOMPtr<nsICookieSettings> cookieSettings;
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
nsCOMPtr<nsPIDOMWindowInner> ownerWindow = do_QueryInterface(global);
if (ownerWindow) {
Document* doc = ownerWindow->GetExtantDoc();
@ -1814,16 +1814,16 @@ already_AddRefed<EventSource> EventSource::Constructor(
return nullptr;
}
cookieSettings = doc->CookieSettings();
cookieJarSettings = doc->CookieJarSettings();
} else {
// Worker side.
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
cookieSettings = workerPrivate->CookieSettings();
cookieJarSettings = workerPrivate->CookieJarSettings();
}
RefPtr<EventSource> eventSource = new EventSource(
global, cookieSettings, aEventSourceInitDict.mWithCredentials);
global, cookieJarSettings, aEventSourceInitDict.mWithCredentials);
RefPtr<EventSourceImpl> eventSourceImp = eventSource->mImpl;
if (NS_IsMainThread()) {

View File

@ -19,7 +19,7 @@
#include "nsDeque.h"
class nsIGlobalObject;
class nsICookieSettings;
class nsICookieJarSettings;
namespace mozilla {
@ -75,8 +75,8 @@ class EventSource final : public DOMEventTargetHelper {
void Close();
private:
EventSource(nsIGlobalObject* aGlobal, nsICookieSettings* aCookieSettings,
bool aWithCredentials);
EventSource(nsIGlobalObject* aGlobal,
nsICookieJarSettings* aCookieJarSettings, bool aWithCredentials);
virtual ~EventSource();
// prevent bad usage
EventSource(const EventSource& x) = delete;

View File

@ -87,7 +87,7 @@
#include "mozilla/dom/WorkerCommon.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/extensions/WebExtensionPolicy.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/EventStateManager.h"

View File

@ -248,7 +248,7 @@
#include "mozilla/dom/WindowGlobalChild.h"
#include "mozilla/dom/BrowserChild.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "AccessCheck.h"
#include "SessionStorageCache.h"
@ -4493,7 +4493,7 @@ Storage* nsGlobalWindowInner::GetLocalStorage(ErrorResult& aError) {
if (ShouldPartitionStorage(access)) {
if (!mDoc) {
access = StorageAccess::eDeny;
} else if (!StoragePartitioningEnabled(access, mDoc->CookieSettings())) {
} else if (!StoragePartitioningEnabled(access, mDoc->CookieJarSettings())) {
static const char* kPrefName =
"privacy.restrict3rdpartystorage.partitionedHosts";
@ -4512,14 +4512,15 @@ Storage* nsGlobalWindowInner::GetLocalStorage(ErrorResult& aError) {
return nullptr;
}
nsCOMPtr<nsICookieSettings> cookieSettings;
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
if (mDoc) {
cookieSettings = mDoc->CookieSettings();
cookieJarSettings = mDoc->CookieJarSettings();
} else {
cookieSettings = net::CookieSettings::CreateBlockingAll();
cookieJarSettings = net::CookieJarSettings::CreateBlockingAll();
}
bool partitioningEnabled = StoragePartitioningEnabled(access, cookieSettings);
bool partitioningEnabled =
StoragePartitioningEnabled(access, cookieJarSettings);
bool shouldPartition = ShouldPartitionStorage(access);
bool partition = partitioningEnabled && shouldPartition;
@ -5602,8 +5603,9 @@ nsIPrincipal* nsGlobalWindowInner::GetTopLevelAntiTrackingPrincipal() {
return nullptr;
}
bool stopAtOurLevel = mDoc && mDoc->CookieSettings()->GetCookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT_TRACKER;
bool stopAtOurLevel =
mDoc && mDoc->CookieJarSettings()->GetCookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT_TRACKER;
if (stopAtOurLevel && topLevelOuterWindow == outerWindow) {
return nullptr;

View File

@ -2483,7 +2483,7 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
mHasStorageAccess = false;
nsIURI* uri = aDocument->GetDocumentURI();
if (newInnerWindow &&
aDocument->CookieSettings()->GetRejectThirdPartyTrackers() &&
aDocument->CookieJarSettings()->GetRejectThirdPartyTrackers() &&
nsContentUtils::IsThirdPartyWindowOrChannel(newInnerWindow, nullptr,
uri) &&
nsContentUtils::IsThirdPartyTrackingResourceWindow(newInnerWindow)) {

View File

@ -281,12 +281,12 @@ nsSyncLoader::GetInterface(const nsIID& aIID, void** aResult) {
nsresult nsSyncLoadService::LoadDocument(
nsIURI* aURI, nsContentPolicyType aContentPolicyType,
nsIPrincipal* aLoaderPrincipal, nsSecurityFlags aSecurityFlags,
nsILoadGroup* aLoadGroup, nsICookieSettings* aCookieSettings,
nsILoadGroup* aLoadGroup, nsICookieJarSettings* aCookieJarSettings,
bool aForceToXML, ReferrerPolicy aReferrerPolicy, Document** aResult) {
nsCOMPtr<nsIChannel> channel;
nsresult rv =
NS_NewChannel(getter_AddRefs(channel), aURI, aLoaderPrincipal,
aSecurityFlags, aContentPolicyType, aCookieSettings,
aSecurityFlags, aContentPolicyType, aCookieJarSettings,
nullptr, // PerformanceStorage
aLoadGroup);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -18,7 +18,7 @@
#include "nsILoadInfo.h"
#include "nsIReferrerInfo.h"
class nsICookieSettings;
class nsICookieJarSettings;
class nsIInputStream;
class nsILoadGroup;
class nsIStreamListener;
@ -51,7 +51,7 @@ class nsSyncLoadService {
static nsresult LoadDocument(
nsIURI* aURI, nsContentPolicyType aContentPolicyType,
nsIPrincipal* aLoaderPrincipal, nsSecurityFlags aSecurityFlags,
nsILoadGroup* aLoadGroup, nsICookieSettings* aCookieSettings,
nsILoadGroup* aLoadGroup, nsICookieJarSettings* aCookieJarSettings,
bool aForceToXML, mozilla::dom::ReferrerPolicy aReferrerPolicy,
mozilla::dom::Document** aResult);

View File

@ -239,7 +239,7 @@ already_AddRefed<BroadcastChannel> BroadcastChannel::Constructor(
StorageAccess storageAccess;
nsCOMPtr<nsICookieSettings> cs;
nsCOMPtr<nsICookieJarSettings> cjs;
if (NS_IsMainThread()) {
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(global);
if (NS_WARN_IF(!window)) {
@ -280,7 +280,7 @@ already_AddRefed<BroadcastChannel> BroadcastChannel::Constructor(
Document* doc = window->GetExtantDoc();
if (doc) {
cs = doc->CookieSettings();
cjs = doc->CookieJarSettings();
}
} else {
JSContext* cx = aGlobal.Context();
@ -309,14 +309,14 @@ already_AddRefed<BroadcastChannel> BroadcastChannel::Constructor(
storageAccess = workerPrivate->StorageAccess();
bc->mWorkerRef = workerRef;
cs = workerPrivate->CookieSettings();
cjs = workerPrivate->CookieJarSettings();
}
// We want to allow opaque origins.
if (storagePrincipalInfo.type() != PrincipalInfo::TNullPrincipalInfo &&
(storageAccess == StorageAccess::eDeny ||
(ShouldPartitionStorage(storageAccess) &&
!StoragePartitioningEnabled(storageAccess, cs)))) {
!StoragePartitioningEnabled(storageAccess, cjs)))) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}

View File

@ -34,7 +34,7 @@
#include "mozilla/dom/Response.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/URLSearchParams.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "BodyExtractor.h"
#include "EmptyBody.h"
@ -398,7 +398,7 @@ class MainThreadFetchRunnable : public Runnable {
// so pass false as the last argument to FetchDriver().
fetch = new FetchDriver(mRequest, principal, loadGroup,
workerPrivate->MainThreadEventTarget(),
workerPrivate->CookieSettings(),
workerPrivate->CookieJarSettings(),
workerPrivate->GetPerformanceStorage(), false);
nsAutoCString spec;
if (proxy->GetWorkerPrivate()->GetBaseURI()) {
@ -474,7 +474,7 @@ already_AddRefed<Promise> FetchRequest(nsIGlobalObject* aGlobal,
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
nsCOMPtr<Document> doc;
nsCOMPtr<nsILoadGroup> loadGroup;
nsCOMPtr<nsICookieSettings> cookieSettings;
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
nsIPrincipal* principal;
bool isTrackingFetch = false;
if (window) {
@ -485,7 +485,7 @@ already_AddRefed<Promise> FetchRequest(nsIGlobalObject* aGlobal,
}
principal = doc->NodePrincipal();
loadGroup = doc->GetDocumentLoadGroup();
cookieSettings = doc->CookieSettings();
cookieJarSettings = doc->CookieJarSettings();
isTrackingFetch = doc->IsScriptTracking(cx);
} else {
@ -495,7 +495,7 @@ already_AddRefed<Promise> FetchRequest(nsIGlobalObject* aGlobal,
return nullptr;
}
cookieSettings = mozilla::net::CookieSettings::Create();
cookieJarSettings = mozilla::net::CookieJarSettings::Create();
}
if (!loadGroup) {
@ -510,7 +510,7 @@ already_AddRefed<Promise> FetchRequest(nsIGlobalObject* aGlobal,
p, observer, signalImpl, request->MozErrors());
RefPtr<FetchDriver> fetch = new FetchDriver(
r, principal, loadGroup, aGlobal->EventTargetFor(TaskCategory::Other),
cookieSettings, nullptr, // PerformanceStorage
cookieJarSettings, nullptr, // PerformanceStorage
isTrackingFetch);
fetch->SetDocument(doc);
resolver->SetLoadGroup(loadGroup);

View File

@ -326,14 +326,14 @@ NS_IMPL_ISUPPORTS(FetchDriver, nsIStreamListener, nsIChannelEventSink,
FetchDriver::FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
nsILoadGroup* aLoadGroup,
nsIEventTarget* aMainThreadEventTarget,
nsICookieSettings* aCookieSettings,
nsICookieJarSettings* aCookieJarSettings,
PerformanceStorage* aPerformanceStorage,
bool aIsTrackingFetch)
: mPrincipal(aPrincipal),
mLoadGroup(aLoadGroup),
mRequest(aRequest),
mMainThreadEventTarget(aMainThreadEventTarget),
mCookieSettings(aCookieSettings),
mCookieJarSettings(aCookieJarSettings),
mPerformanceStorage(aPerformanceStorage),
mNeedToObserveOnDataAvailable(false),
mIsTrackingFetch(aIsTrackingFetch),
@ -510,7 +510,7 @@ nsresult FetchDriver::HttpFetch(
nsLoadFlags loadFlags = nsIRequest::LOAD_BACKGROUND | bypassFlag;
if (mDocument) {
MOZ_ASSERT(mDocument->NodePrincipal() == mPrincipal);
MOZ_ASSERT(mDocument->CookieSettings() == mCookieSettings);
MOZ_ASSERT(mDocument->CookieJarSettings() == mCookieJarSettings);
rv = NS_NewChannel(getter_AddRefs(chan), uri, mDocument, secFlags,
mRequest->ContentPolicyType(),
nullptr, /* aPerformanceStorage */
@ -519,13 +519,13 @@ nsresult FetchDriver::HttpFetch(
} else if (mClientInfo.isSome()) {
rv = NS_NewChannel(getter_AddRefs(chan), uri, mPrincipal, mClientInfo.ref(),
mController, secFlags, mRequest->ContentPolicyType(),
mCookieSettings, mPerformanceStorage, mLoadGroup,
mCookieJarSettings, mPerformanceStorage, mLoadGroup,
nullptr, /* aCallbacks */
loadFlags, ios);
} else {
rv =
NS_NewChannel(getter_AddRefs(chan), uri, mPrincipal, secFlags,
mRequest->ContentPolicyType(), mCookieSettings,
mRequest->ContentPolicyType(), mCookieJarSettings,
mPerformanceStorage, mLoadGroup, nullptr, /* aCallbacks */
loadFlags, ios);
}

View File

@ -20,7 +20,7 @@
#include "mozilla/DebugOnly.h"
class nsIConsoleReportCollector;
class nsICookieSettings;
class nsICookieJarSettings;
class nsICSPEventListener;
class nsIEventTarget;
class nsIOutputStream;
@ -101,7 +101,7 @@ class FetchDriver final : public nsIStreamListener,
FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
nsILoadGroup* aLoadGroup, nsIEventTarget* aMainThreadEventTarget,
nsICookieSettings* aCookieSettings,
nsICookieJarSettings* aCookieJarSettings,
PerformanceStorage* aPerformanceStorage, bool aIsTrackingFetch);
nsresult Fetch(AbortSignalImpl* aSignalImpl, FetchDriverObserver* aObserver);
@ -141,7 +141,7 @@ class FetchDriver final : public nsIStreamListener,
nsAutoPtr<SRICheckDataVerifier> mSRIDataVerifier;
nsCOMPtr<nsIEventTarget> mMainThreadEventTarget;
nsCOMPtr<nsICookieSettings> mCookieSettings;
nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;
// This is set only when Fetch is used in workers.
RefPtr<PerformanceStorage> mPerformanceStorage;

View File

@ -328,8 +328,8 @@ nsresult IDBFactory::AllowedForWindowInternal(
}
if (ShouldPartitionStorage(access) &&
!StoragePartitioningEnabled(access,
aWindow->GetExtantDoc()->CookieSettings())) {
!StoragePartitioningEnabled(
access, aWindow->GetExtantDoc()->CookieJarSettings())) {
return NS_ERROR_DOM_SECURITY_ERR;
}

View File

@ -4521,7 +4521,7 @@ already_AddRefed<mozilla::docshell::POfflineCacheUpdateParent>
ContentParent::AllocPOfflineCacheUpdateParent(
const URIParams& aManifestURI, const URIParams& aDocumentURI,
const PrincipalInfo& aLoadingPrincipalInfo, const bool& aStickDocument,
const CookieSettingsArgs& aCookieSettingsArgs) {
const CookieJarSettingsArgs& aCookieJarSettingsArgs) {
RefPtr<mozilla::docshell::OfflineCacheUpdateParent> update =
new mozilla::docshell::OfflineCacheUpdateParent();
return update.forget();
@ -4530,14 +4530,15 @@ ContentParent::AllocPOfflineCacheUpdateParent(
mozilla::ipc::IPCResult ContentParent::RecvPOfflineCacheUpdateConstructor(
POfflineCacheUpdateParent* aActor, const URIParams& aManifestURI,
const URIParams& aDocumentURI, const PrincipalInfo& aLoadingPrincipal,
const bool& aStickDocument, const CookieSettingsArgs& aCookieSettingsArgs) {
const bool& aStickDocument,
const CookieJarSettingsArgs& aCookieJarSettingsArgs) {
MOZ_ASSERT(aActor);
RefPtr<mozilla::docshell::OfflineCacheUpdateParent> update =
static_cast<mozilla::docshell::OfflineCacheUpdateParent*>(aActor);
nsresult rv = update->Schedule(aManifestURI, aDocumentURI, aLoadingPrincipal,
aStickDocument, aCookieSettingsArgs);
aStickDocument, aCookieJarSettingsArgs);
if (NS_FAILED(rv) && IsAlive()) {
// Inform the child of failure.
Unused << update->SendFinish(false, false);

View File

@ -488,13 +488,13 @@ class ContentParent final
already_AddRefed<POfflineCacheUpdateParent> AllocPOfflineCacheUpdateParent(
const URIParams& aManifestURI, const URIParams& aDocumentURI,
const PrincipalInfo& aLoadingPrincipalInfo, const bool& aStickDocument,
const CookieSettingsArgs& aCookieSettingsArgs);
const CookieJarSettingsArgs& aCookieJarSettingsArgs);
virtual mozilla::ipc::IPCResult RecvPOfflineCacheUpdateConstructor(
POfflineCacheUpdateParent* aActor, const URIParams& aManifestURI,
const URIParams& aDocumentURI, const PrincipalInfo& aLoadingPrincipal,
const bool& stickDocument,
const CookieSettingsArgs& aCookieSettingsArgs) override;
const CookieJarSettingsArgs& aCookieJarSettingsArgs) override;
mozilla::ipc::IPCResult RecvSetOfflinePermission(
const IPC::Principal& principal);

View File

@ -1158,7 +1158,7 @@ parent:
*/
async POfflineCacheUpdate(URIParams manifestURI, URIParams documentURI,
PrincipalInfo loadingPrincipal, bool stickDocument,
CookieSettingsArgs cookieSettings);
CookieJarSettingsArgs cookieJarSettings);
/**
* Sets "offline-app" permission for the principal. Called when we hit

View File

@ -372,10 +372,10 @@ void nsDOMOfflineResourceList::MozAdd(const nsAString& aURI, ErrorResult& aRv) {
}
RefPtr<Document> doc = GetOwner()->GetExtantDoc();
nsCOMPtr<nsICookieSettings> cs = doc ? doc->CookieSettings() : nullptr;
nsCOMPtr<nsICookieJarSettings> cjs = doc ? doc->CookieJarSettings() : nullptr;
rv = update->InitPartial(mManifestURI, clientID, mDocumentURI,
mLoadingPrincipal, cs);
mLoadingPrincipal, cjs);
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(rv);
return;

View File

@ -20,7 +20,7 @@
#include "mozilla/AntiTrackingCommon.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/net/HttpBaseChannel.h"
#include "mozilla/dom/Element.h"
#include "mozilla/StaticPrefs_network.h"
@ -195,14 +195,14 @@ ReferrerPolicy ReferrerInfo::GetDefaultReferrerPolicy(nsIHttpChannel* aChannel,
if (aChannel) {
loadInfo = aChannel->LoadInfo();
}
nsCOMPtr<nsICookieSettings> cs;
nsCOMPtr<nsICookieJarSettings> cjs;
if (loadInfo) {
Unused << loadInfo->GetCookieSettings(getter_AddRefs(cs));
Unused << loadInfo->GetCookieJarSettings(getter_AddRefs(cjs));
}
if (!cs) {
cs = net::CookieSettings::Create();
if (!cjs) {
cjs = net::CookieJarSettings::Create();
}
if (aChannel && aURI && cs->GetRejectThirdPartyTrackers()) {
if (aChannel && aURI && cjs->GetRejectThirdPartyTrackers()) {
uint32_t rejectedReason = 0;
thirdPartyTrackerIsolated =
!AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(

View File

@ -44,7 +44,7 @@
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/net/NeckoChannelParams.h"
#include "mozilla/Services.h"
#include "mozilla/DebugOnly.h"
@ -1708,11 +1708,11 @@ nsresult ServiceWorkerPrivate::SpawnWorkerIfNeeded(WakeUpReason aWhy,
// moment, ServiceWorkers are not exposed in partitioned contexts.
info.mStoragePrincipal = info.mPrincipal;
info.mCookieSettings = mozilla::net::CookieSettings::Create();
MOZ_ASSERT(info.mCookieSettings);
info.mCookieJarSettings = mozilla::net::CookieJarSettings::Create();
MOZ_ASSERT(info.mCookieJarSettings);
info.mStorageAccess =
StorageAllowedForServiceWorker(info.mPrincipal, info.mCookieSettings);
StorageAllowedForServiceWorker(info.mPrincipal, info.mCookieJarSettings);
info.mOriginAttributes = mInfo->GetOriginAttributes();

View File

@ -138,12 +138,12 @@ nsresult ServiceWorkerPrivateImpl::Initialize() {
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
nsCOMPtr<nsICookieSettings> cookieSettings =
mozilla::net::CookieSettings::Create();
MOZ_ASSERT(cookieSettings);
nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
mozilla::net::CookieJarSettings::Create();
MOZ_ASSERT(cookieJarSettings);
StorageAccess storageAccess =
StorageAllowedForServiceWorker(principal, cookieSettings);
StorageAllowedForServiceWorker(principal, cookieJarSettings);
ServiceWorkerData serviceWorkerData;
serviceWorkerData.cacheName() = mOuter->mInfo->CacheName();

View File

@ -18,7 +18,7 @@
#include "mozilla/dom/WorkerCommon.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "nsICacheInfoChannel.h"
#include "nsIStreamLoader.h"
#include "nsIThreadRetargetableRequest.h"
@ -660,15 +660,15 @@ nsresult CompareNetwork::Initialize(nsIPrincipal* aPrincipal,
mIsMainScript ? nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER
: nsIContentPolicy::TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS;
// Create a new cookieSettings.
nsCOMPtr<nsICookieSettings> cookieSettings =
mozilla::net::CookieSettings::Create();
// Create a new cookieJarSettings.
nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
mozilla::net::CookieJarSettings::Create();
// Note that because there is no "serviceworker" RequestContext type, we can
// use the TYPE_INTERNAL_SCRIPT content policy types when loading a service
// worker.
rv = NS_NewChannel(getter_AddRefs(mChannel), uri, aPrincipal, secFlags,
contentPolicyType, cookieSettings,
contentPolicyType, cookieJarSettings,
nullptr /* aPerformanceStorage */, loadGroup,
nullptr /* aCallbacks */, mLoadFlags);
if (NS_WARN_IF(NS_FAILED(rv))) {

View File

@ -250,7 +250,7 @@ function task(fn) {
}
}
// The test will run on a separate window in order to apply the new cookie settings.
// The test will run on a separate window in order to apply the new cookie jar settings.
async function runTestInWindow(test) {
let w = window.open("window_storagePermissions.html");
await new Promise(resolve => {

View File

@ -52,7 +52,7 @@
#include "nsIMIMEInfo.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/HTMLSharedElement.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/Printf.h"
#include "ReferrerInfo.h"
@ -1220,16 +1220,16 @@ nsresult nsWebBrowserPersist::SaveURIInternal(
loadFlags |= nsIRequest::LOAD_FROM_CACHE;
}
// Create a new cookieSettings for this download in order to send cookies
// Create a new cookieJarSettings for this download in order to send cookies
// based on the current state of the prefs/permissions.
nsCOMPtr<nsICookieSettings> cookieSettings =
mozilla::net::CookieSettings::Create();
nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
mozilla::net::CookieJarSettings::Create();
// Open a channel to the URI
nsCOMPtr<nsIChannel> inputChannel;
rv = NS_NewChannel(getter_AddRefs(inputChannel), aURI, aTriggeringPrincipal,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
aContentPolicyType, cookieSettings,
aContentPolicyType, cookieJarSettings,
nullptr, // aPerformanceStorage
nullptr, // aLoadGroup
static_cast<nsIInterfaceRequestor*>(this), loadFlags);

View File

@ -34,7 +34,7 @@
#include "nsXPCOM.h"
#include "nsContentUtils.h"
#include "nsError.h"
#include "nsICookieSettings.h"
#include "nsICookieJarSettings.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIURL.h"
#include "nsThreadUtils.h"
@ -130,7 +130,7 @@ class WebSocketImpl final : public nsIInterfaceRequestor,
nsresult ParseURL(const nsAString& aURL);
nsresult InitializeConnection(nsIPrincipal* aPrincipal,
nsICookieSettings* aCookieSettings);
nsICookieJarSettings* aCookieJarSettings);
// These methods when called can release the WebSocket object
void FailConnection(uint16_t reasonCode,
@ -1093,7 +1093,7 @@ class ConnectRunnable final : public WebSocketMainThreadRunnable {
}
mConnectionFailed = NS_FAILED(mImpl->InitializeConnection(
doc->NodePrincipal(), mWorkerPrivate->CookieSettings()));
doc->NodePrincipal(), mWorkerPrivate->CookieJarSettings()));
return true;
}
@ -1103,7 +1103,7 @@ class ConnectRunnable final : public WebSocketMainThreadRunnable {
mConnectionFailed = NS_FAILED(
mImpl->InitializeConnection(aTopLevelWorkerPrivate->GetPrincipal(),
mWorkerPrivate->CookieSettings()));
mWorkerPrivate->CookieJarSettings()));
return true;
}
@ -1270,7 +1270,7 @@ already_AddRefed<WebSocket> WebSocket::ConstructorCommon(
// url parameter, so don't throw if InitializeConnection fails, and call
// onerror/onclose asynchronously
connectionFailed = NS_FAILED(webSocketImpl->InitializeConnection(
principal, doc ? doc->CookieSettings() : nullptr));
principal, doc ? doc->CookieJarSettings() : nullptr));
} else {
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
@ -1696,7 +1696,7 @@ class nsAutoCloseWS final {
};
nsresult WebSocketImpl::InitializeConnection(
nsIPrincipal* aPrincipal, nsICookieSettings* aCookieSettings) {
nsIPrincipal* aPrincipal, nsICookieJarSettings* aCookieJarSettings) {
AssertIsOnMainThread();
MOZ_ASSERT(!mChannel, "mChannel should be null");
@ -1740,8 +1740,8 @@ nsresult WebSocketImpl::InitializeConnection(
MOZ_ASSERT(!doc || doc->NodePrincipal()->Equals(aPrincipal));
rv = wsChannel->InitLoadInfoNative(
doc, doc ? doc->NodePrincipal() : aPrincipal, aPrincipal, aCookieSettings,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
doc, doc ? doc->NodePrincipal() : aPrincipal, aPrincipal,
aCookieJarSettings, nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_WEBSOCKET, 0);
MOZ_ASSERT(NS_SUCCEEDED(rv));

View File

@ -1998,9 +1998,9 @@ void RuntimeService::PropagateFirstPartyStorageAccessGranted(
nsPIDOMWindowInner* aWindow) {
AssertIsOnMainThread();
MOZ_ASSERT(aWindow);
MOZ_ASSERT_IF(
aWindow->GetExtantDoc(),
aWindow->GetExtantDoc()->CookieSettings()->GetRejectThirdPartyTrackers());
MOZ_ASSERT_IF(aWindow->GetExtantDoc(), aWindow->GetExtantDoc()
->CookieJarSettings()
->GetRejectThirdPartyTrackers());
nsTArray<WorkerPrivate*> workers;
GetWorkersForWindow(aWindow, workers);
@ -2415,9 +2415,9 @@ void ResumeWorkersForWindow(nsPIDOMWindowInner* aWindow) {
void PropagateFirstPartyStorageAccessGrantedToWorkers(
nsPIDOMWindowInner* aWindow) {
AssertIsOnMainThread();
MOZ_ASSERT_IF(
aWindow->GetExtantDoc(),
aWindow->GetExtantDoc()->CookieSettings()->GetRejectThirdPartyTrackers());
MOZ_ASSERT_IF(aWindow->GetExtantDoc(), aWindow->GetExtantDoc()
->CookieJarSettings()
->GetRejectThirdPartyTrackers());
RuntimeService* runtime = RuntimeService::GetService();
if (runtime) {

View File

@ -134,7 +134,7 @@ nsresult ChannelFromScriptURL(
const Maybe<ServiceWorkerDescriptor>& aController, bool aIsMainScript,
WorkerScriptType aWorkerScriptType,
nsContentPolicyType aMainScriptContentPolicyType, nsLoadFlags aLoadFlags,
nsICookieSettings* aCookieSettings, nsIReferrerInfo* aReferrerInfo,
nsICookieJarSettings* aCookieJarSettings, nsIReferrerInfo* aReferrerInfo,
nsIChannel** aChannel) {
AssertIsOnMainThread();
@ -226,13 +226,13 @@ nsresult ChannelFromScriptURL(
if (aClientInfo.isSome()) {
rv = NS_NewChannel(getter_AddRefs(channel), uri, principal,
aClientInfo.ref(), aController, secFlags,
contentPolicyType, aCookieSettings, performanceStorage,
loadGroup, nullptr, // aCallbacks
contentPolicyType, aCookieJarSettings,
performanceStorage, loadGroup, nullptr, // aCallbacks
aLoadFlags, ios);
} else {
rv = NS_NewChannel(getter_AddRefs(channel), uri, principal, secFlags,
contentPolicyType, aCookieSettings, performanceStorage,
loadGroup, nullptr, // aCallbacks
contentPolicyType, aCookieJarSettings,
performanceStorage, loadGroup, nullptr, // aCallbacks
aLoadFlags, ios);
}
@ -998,8 +998,8 @@ class ScriptLoaderRunnable final : public nsIRunnable, public nsINamed {
ios, secMan, url, mClientInfo, mController,
IsMainWorkerScript(), mWorkerScriptType,
mWorkerPrivate->ContentPolicyType(), loadFlags,
mWorkerPrivate->CookieSettings(), referrerInfo,
getter_AddRefs(channel));
mWorkerPrivate->CookieJarSettings(),
referrerInfo, getter_AddRefs(channel));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -1868,7 +1868,7 @@ class ChannelGetterRunnable final : public WorkerMainThreadRunnable {
nsCOMPtr<Document> parentDoc = mWorkerPrivate->GetDocument();
mLoadInfo.mLoadGroup = mWorkerPrivate->GetLoadGroup();
mLoadInfo.mCookieSettings = mWorkerPrivate->CookieSettings();
mLoadInfo.mCookieJarSettings = mWorkerPrivate->CookieJarSettings();
// Nested workers use default uri encoding.
nsCOMPtr<nsIURI> url;
@ -1890,7 +1890,7 @@ class ChannelGetterRunnable final : public WorkerMainThreadRunnable {
mLoadInfo.mLoadingPrincipal, parentDoc, mLoadInfo.mLoadGroup, url,
clientInfo,
// Nested workers are always dedicated.
nsIContentPolicy::TYPE_INTERNAL_WORKER, mLoadInfo.mCookieSettings,
nsIContentPolicy::TYPE_INTERNAL_WORKER, mLoadInfo.mCookieJarSettings,
mLoadInfo.mReferrerInfo, getter_AddRefs(channel));
NS_ENSURE_SUCCESS(mResult, true);
@ -2249,7 +2249,7 @@ nsresult ChannelFromScriptURLMainThread(
nsIPrincipal* aPrincipal, Document* aParentDoc, nsILoadGroup* aLoadGroup,
nsIURI* aScriptURL, const Maybe<ClientInfo>& aClientInfo,
nsContentPolicyType aMainScriptContentPolicyType,
nsICookieSettings* aCookieSettings, nsIReferrerInfo* aReferrerInfo,
nsICookieJarSettings* aCookieJarSettings, nsIReferrerInfo* aReferrerInfo,
nsIChannel** aChannel) {
AssertIsOnMainThread();
@ -2261,7 +2261,7 @@ nsresult ChannelFromScriptURLMainThread(
return ChannelFromScriptURL(
aPrincipal, aParentDoc, nullptr, aLoadGroup, ios, secMan, aScriptURL,
aClientInfo, Maybe<ServiceWorkerDescriptor>(), true, WorkerScript,
aMainScriptContentPolicyType, nsIRequest::LOAD_NORMAL, aCookieSettings,
aMainScriptContentPolicyType, nsIRequest::LOAD_NORMAL, aCookieJarSettings,
aReferrerInfo, aChannel);
}

View File

@ -15,7 +15,7 @@ class nsIURI;
class nsILoadGroup;
class nsIChannel;
class nsICookieSettings;
class nsICookieJarSettings;
namespace mozilla {
@ -34,8 +34,9 @@ namespace workerinternals {
nsresult ChannelFromScriptURLMainThread(
nsIPrincipal* aPrincipal, Document* aParentDoc, nsILoadGroup* aLoadGroup,
nsIURI* aScriptURL, const Maybe<ClientInfo>& aClientInfo,
nsContentPolicyType aContentPolicyType, nsICookieSettings* aCookieSettings,
nsIReferrerInfo* aReferrerInfo, nsIChannel** aChannel);
nsContentPolicyType aContentPolicyType,
nsICookieJarSettings* aCookieJarSettings, nsIReferrerInfo* aReferrerInfo,
nsIChannel** aChannel);
nsresult ChannelFromScriptURLWorkerThread(JSContext* aCx,
WorkerPrivate* aParent,

View File

@ -19,7 +19,7 @@
class nsIChannel;
class nsIContentSecurityPolicy;
class nsICookieSettings;
class nsICookieJarSettings;
class nsILoadGroup;
class nsIPrincipal;
class nsIRunnable;
@ -54,7 +54,7 @@ struct WorkerLoadInfoData {
nsCOMPtr<nsIPrincipal> mStoragePrincipal;
// Taken from the parent context.
nsCOMPtr<nsICookieSettings> mCookieSettings;
nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;
nsCOMPtr<nsIScriptContext> mScriptContext;
nsCOMPtr<nsPIDOMWindowInner> mWindow;

View File

@ -65,7 +65,7 @@
#include "ScriptLoader.h"
#include "mozilla/dom/ServiceWorkerEvents.h"
#include "mozilla/dom/ServiceWorkerManager.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "WorkerCSPEventListener.h"
#include "WorkerDebugger.h"
#include "WorkerDebuggerManager.h"
@ -2644,7 +2644,7 @@ nsresult WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
loadInfo.mFromWindow = true;
loadInfo.mWindowID = globalWindow->WindowID();
loadInfo.mStorageAccess = StorageAllowedForWindow(globalWindow);
loadInfo.mCookieSettings = document->CookieSettings();
loadInfo.mCookieJarSettings = document->CookieJarSettings();
loadInfo.mOriginAttributes =
nsContentUtils::GetOriginAttributes(document);
loadInfo.mParentController = globalWindow->GetController();
@ -2690,8 +2690,8 @@ nsresult WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
loadInfo.mFromWindow = false;
loadInfo.mWindowID = UINT64_MAX;
loadInfo.mStorageAccess = StorageAccess::eAllow;
loadInfo.mCookieSettings = mozilla::net::CookieSettings::Create();
MOZ_ASSERT(loadInfo.mCookieSettings);
loadInfo.mCookieJarSettings = mozilla::net::CookieJarSettings::Create();
MOZ_ASSERT(loadInfo.mCookieJarSettings);
loadInfo.mOriginAttributes = OriginAttributes();
}
@ -2714,7 +2714,7 @@ nsresult WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
rv = ChannelFromScriptURLMainThread(
loadInfo.mLoadingPrincipal, document, loadInfo.mLoadGroup, url,
clientInfo, ContentPolicyType(aWorkerType), loadInfo.mCookieSettings,
clientInfo, ContentPolicyType(aWorkerType), loadInfo.mCookieJarSettings,
loadInfo.mReferrerInfo, getter_AddRefs(loadInfo.mChannel));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -775,10 +775,10 @@ class WorkerPrivate : public RelativeTimeline {
return mLoadInfo.mStorageAccess;
}
nsICookieSettings* CookieSettings() const {
nsICookieJarSettings* CookieJarSettings() const {
// Any thread.
MOZ_ASSERT(mLoadInfo.mCookieSettings);
return mLoadInfo.mCookieSettings;
MOZ_ASSERT(mLoadInfo.mCookieJarSettings);
return mLoadInfo.mCookieJarSettings;
}
const OriginAttributes& GetOriginAttributes() const {

View File

@ -472,7 +472,8 @@ already_AddRefed<IDBFactory> WorkerGlobalScope::GetIndexedDB(
}
if (ShouldPartitionStorage(access) &&
!StoragePartitioningEnabled(access, mWorkerPrivate->CookieSettings())) {
!StoragePartitioningEnabled(access,
mWorkerPrivate->CookieJarSettings())) {
NS_WARNING("IndexedDB is not allowed in this worker!");
aErrorResult = NS_ERROR_DOM_SECURITY_ERR;
return nullptr;

View File

@ -45,7 +45,7 @@
#include "mozilla/dom/WorkerRunnable.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
namespace mozilla {
@ -346,7 +346,7 @@ nsresult RemoteWorkerChild::ExecWorkerOnMainThread(RemoteWorkerData&& aData) {
info.mStorageAccess = aData.storageAccess();
info.mOriginAttributes =
BasePrincipal::Cast(principal)->OriginAttributesRef();
info.mCookieSettings = net::CookieSettings::Create();
info.mCookieJarSettings = net::CookieJarSettings::Create();
// Default CSP permissions for now. These will be overrided if necessary
// based on the script CSP headers during load in ScriptLoader.
@ -404,7 +404,7 @@ nsresult RemoteWorkerChild::ExecWorkerOnMainThread(RemoteWorkerData&& aData) {
rv = ChannelFromScriptURLMainThread(
info.mLoadingPrincipal, nullptr /* parent document */, info.mLoadGroup,
info.mResolvedScriptURI, clientInfo,
nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER, info.mCookieSettings,
nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER, info.mCookieJarSettings,
info.mReferrerInfo, getter_AddRefs(info.mChannel));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;

View File

@ -70,8 +70,8 @@ already_AddRefed<SharedWorker> SharedWorker::Constructor(
}
if (ShouldPartitionStorage(storageAllowed) &&
!StoragePartitioningEnabled(storageAllowed,
window->GetExtantDoc()->CookieSettings())) {
!StoragePartitioningEnabled(
storageAllowed, window->GetExtantDoc()->CookieJarSettings())) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}

View File

@ -7,7 +7,7 @@
#include "XMLHttpRequest.h"
#include "XMLHttpRequestMainThread.h"
#include "XMLHttpRequestWorker.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "nsGlobalWindowInner.h"
namespace mozilla {
@ -27,7 +27,7 @@ already_AddRefed<XMLHttpRequest> XMLHttpRequest::Constructor(
return nullptr;
}
nsCOMPtr<nsICookieSettings> cookieSettings;
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(global);
if (window) {
Document* document = window->GetExtantDoc();
@ -36,14 +36,14 @@ already_AddRefed<XMLHttpRequest> XMLHttpRequest::Constructor(
return nullptr;
}
cookieSettings = document->CookieSettings();
cookieJarSettings = document->CookieJarSettings();
} else {
// We are here because this is a sandbox.
cookieSettings = net::CookieSettings::Create();
cookieJarSettings = net::CookieJarSettings::Create();
}
RefPtr<XMLHttpRequestMainThread> req = new XMLHttpRequestMainThread();
req->Construct(principal->GetPrincipal(), global, cookieSettings, false);
req->Construct(principal->GetPrincipal(), global, cookieJarSettings, false);
req->InitParameters(aParams.mMozAnon, aParams.mMozSystem);
return req.forget();
}

View File

@ -2418,7 +2418,7 @@ nsresult XMLHttpRequestMainThread::CreateChannel() {
rv = NS_NewChannel(getter_AddRefs(mChannel), mRequestURL, mPrincipal,
mClientInfo.ref(), mController, secFlags,
nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
mCookieSettings,
mCookieJarSettings,
mPerformanceStorage, // aPerformanceStorage
loadGroup,
nullptr, // aCallbacks
@ -2427,7 +2427,7 @@ nsresult XMLHttpRequestMainThread::CreateChannel() {
// Otherwise use the principal.
rv = NS_NewChannel(getter_AddRefs(mChannel), mRequestURL, mPrincipal,
secFlags, nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
mCookieSettings,
mCookieJarSettings,
mPerformanceStorage, // aPerformanceStorage
loadGroup,
nullptr, // aCallbacks

View File

@ -213,7 +213,7 @@ class XMLHttpRequestMainThread final : public XMLHttpRequest,
XMLHttpRequestMainThread();
void Construct(nsIPrincipal* aPrincipal, nsIGlobalObject* aGlobalObject,
nsICookieSettings* aCookieSettings, bool aForWorker,
nsICookieJarSettings* aCookieJarSettings, bool aForWorker,
nsIURI* aBaseURI = nullptr, nsILoadGroup* aLoadGroup = nullptr,
PerformanceStorage* aPerformanceStorage = nullptr,
nsICSPEventListener* aCSPEventListener = nullptr) {
@ -222,7 +222,7 @@ class XMLHttpRequestMainThread final : public XMLHttpRequest,
BindToOwner(aGlobalObject);
mBaseURI = aBaseURI;
mLoadGroup = aLoadGroup;
mCookieSettings = aCookieSettings;
mCookieJarSettings = aCookieJarSettings;
mForWorker = aForWorker;
mPerformanceStorage = aPerformanceStorage;
mCSPEventListener = aCSPEventListener;
@ -516,7 +516,7 @@ class XMLHttpRequestMainThread final : public XMLHttpRequest,
nsCOMPtr<nsIStreamListener> mXMLParserStreamListener;
nsCOMPtr<nsICookieSettings> mCookieSettings;
nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;
RefPtr<PerformanceStorage> mPerformanceStorage;
nsCOMPtr<nsICSPEventListener> mCSPEventListener;

View File

@ -768,7 +768,7 @@ bool Proxy::Init() {
mXHR = new XMLHttpRequestMainThread();
mXHR->Construct(mWorkerPrivate->GetPrincipal(),
ownerWindow ? ownerWindow->AsGlobal() : nullptr,
mWorkerPrivate->CookieSettings(), true,
mWorkerPrivate->CookieJarSettings(), true,
mWorkerPrivate->GetBaseURI(), mWorkerPrivate->GetLoadGroup(),
mWorkerPrivate->GetPerformanceStorage(),
mWorkerPrivate->CSPEventListener());

View File

@ -66,7 +66,7 @@ nsresult nsXMLPrettyPrinter::PrettyPrint(Document* aDocument,
rv = nsSyncLoadService::LoadDocument(
xslUri, nsIContentPolicy::TYPE_XSLT, nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nullptr,
aDocument->CookieSettings(), true, ReferrerPolicy::_empty,
aDocument->CookieJarSettings(), true, ReferrerPolicy::_empty,
getter_AddRefs(xslDocument));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -38,7 +38,7 @@ nsresult txParseDocumentFromURI(const nsAString& aHref,
documentURI, nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
loaderDocument->NodePrincipal(),
nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS, loadGroup,
loaderDocument->CookieSettings(), true,
loaderDocument->CookieJarSettings(), true,
loaderDocument->GetReferrerPolicy(), &theDocument);
if (NS_FAILED(rv)) {

View File

@ -561,7 +561,7 @@ nsresult txSyncCompileObserver::loadURI(const nsAString& aUri,
rv = nsSyncLoadService::LoadDocument(
uri, nsIContentPolicy::TYPE_XSLT, referrerPrincipal,
nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS, nullptr,
source ? source->OwnerDoc()->CookieSettings() : nullptr, false,
source ? source->OwnerDoc()->CookieJarSettings() : nullptr, false,
aReferrerPolicy, getter_AddRefs(document));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -245,7 +245,7 @@ nsresult nsAutoConfig::downloadAutoConfig() {
getter_AddRefs(channel), url, nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // nsICookieSettings
nullptr, // nsICookieJarSettings
nullptr, // PerformanceStorage
nullptr, // loadGroup
nullptr, // aCallbacks

View File

@ -888,7 +888,7 @@ static nsresult NewImageChannel(
// requestingNode.
rv = NS_NewChannel(aResult, aURI, nsContentUtils::GetSystemPrincipal(),
securityFlags, aPolicyType,
nullptr, // nsICookieSettings
nullptr, // nsICookieJarSettings
nullptr, // PerformanceStorage
nullptr, // loadGroup
callbacks, aLoadFlags);

View File

@ -13,7 +13,7 @@
#include "mozilla/NullPrincipal.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/net/NeckoChannelParams.h"
#include "ExpandedPrincipal.h"
#include "nsIScriptSecurityManager.h"
@ -529,13 +529,13 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo,
nsAutoString cspNonce;
Unused << NS_WARN_IF(NS_FAILED(aLoadInfo->GetCspNonce(cspNonce)));
nsCOMPtr<nsICookieSettings> cookieSettings;
rv = aLoadInfo->GetCookieSettings(getter_AddRefs(cookieSettings));
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
rv = aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
NS_ENSURE_SUCCESS(rv, rv);
CookieSettingsArgs cookieSettingsArgs;
static_cast<CookieSettings*>(cookieSettings.get())
->Serialize(cookieSettingsArgs);
CookieJarSettingsArgs cookieJarSettingsArgs;
static_cast<CookieJarSettings*>(cookieJarSettings.get())
->Serialize(cookieJarSettingsArgs);
Maybe<CSPInfo> maybeCspToInheritInfo;
nsCOMPtr<nsIContentSecurityPolicy> cspToInherit =
@ -580,7 +580,7 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo,
aLoadInfo->GetDocumentHasLoaded(),
aLoadInfo->GetAllowListFutureDocumentsCreatedFromThisRedirectChain(),
cspNonce, aLoadInfo->GetSkipContentSniffing(),
aLoadInfo->GetIsFromProcessingFrameAttributes(), cookieSettingsArgs,
aLoadInfo->GetIsFromProcessingFrameAttributes(), cookieJarSettingsArgs,
aLoadInfo->GetRequestBlockingReason(), maybeCspToInheritInfo));
return NS_OK;
@ -723,9 +723,9 @@ nsresult LoadInfoArgsToLoadInfo(
ServiceWorkerDescriptor(loadInfoArgs.controller().ref()));
}
nsCOMPtr<nsICookieSettings> cookieSettings;
CookieSettings::Deserialize(loadInfoArgs.cookieSettings(),
getter_AddRefs(cookieSettings));
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
CookieJarSettings::Deserialize(loadInfoArgs.cookieJarSettings(),
getter_AddRefs(cookieJarSettings));
nsCOMPtr<nsIContentSecurityPolicy> cspToInherit;
Maybe<mozilla::ipc::CSPInfo> cspToInheritInfo =
@ -748,7 +748,7 @@ nsresult LoadInfoArgsToLoadInfo(
RefPtr<mozilla::LoadInfo> loadInfo = new mozilla::LoadInfo(
loadingPrincipal, triggeringPrincipal, principalToInherit,
sandboxedLoadingPrincipal, topLevelPrincipal,
topLevelStorageAreaPrincipal, resultPrincipalURI, cookieSettings,
topLevelStorageAreaPrincipal, resultPrincipalURI, cookieJarSettings,
cspToInherit, clientInfo, reservedClientInfo, initialClientInfo,
controller, loadInfoArgs.securityFlags(), loadInfoArgs.sandboxFlags(),
loadInfoArgs.contentPolicyType(),
@ -797,7 +797,7 @@ void LoadInfoToParentLoadInfoForwarder(
false, // documentHasUserInteracted
false, // documentHasLoaded
false, // allowListFutureDocumentsCreatedFromThisRedirectChain
Maybe<CookieSettingsArgs>(),
Maybe<CookieJarSettingsArgs>(),
nsILoadInfo::BLOCKING_REASON_NONE); // requestBlockingReason
return;
}
@ -811,15 +811,17 @@ void LoadInfoToParentLoadInfoForwarder(
uint32_t tainting = nsILoadInfo::TAINTING_BASIC;
Unused << aLoadInfo->GetTainting(&tainting);
Maybe<CookieSettingsArgs> cookieSettingsArgs;
Maybe<CookieJarSettingsArgs> cookieJarSettingsArgs;
nsCOMPtr<nsICookieSettings> cookieSettings;
nsresult rv = aLoadInfo->GetCookieSettings(getter_AddRefs(cookieSettings));
CookieSettings* cs = static_cast<CookieSettings*>(cookieSettings.get());
if (NS_SUCCEEDED(rv) && cookieSettings && cs->HasBeenChanged()) {
CookieSettingsArgs args;
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
nsresult rv =
aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
CookieJarSettings* cs =
static_cast<CookieJarSettings*>(cookieJarSettings.get());
if (NS_SUCCEEDED(rv) && cookieJarSettings && cs->HasBeenChanged()) {
CookieJarSettingsArgs args;
cs->Serialize(args);
cookieSettingsArgs = Some(args);
cookieJarSettingsArgs = Some(args);
}
*aForwarderArgsOut = ParentLoadInfoForwarderArgs(
@ -830,7 +832,7 @@ void LoadInfoToParentLoadInfoForwarder(
aLoadInfo->GetDocumentHasUserInteracted(),
aLoadInfo->GetDocumentHasLoaded(),
aLoadInfo->GetAllowListFutureDocumentsCreatedFromThisRedirectChain(),
cookieSettingsArgs, aLoadInfo->GetRequestBlockingReason());
cookieJarSettingsArgs, aLoadInfo->GetRequestBlockingReason());
}
nsresult MergeParentLoadInfoForwarder(
@ -875,14 +877,15 @@ nsresult MergeParentLoadInfoForwarder(
MOZ_ALWAYS_SUCCEEDS(aLoadInfo->SetRequestBlockingReason(
aForwarderArgs.requestBlockingReason()));
const Maybe<CookieSettingsArgs>& cookieSettingsArgs =
aForwarderArgs.cookieSettings();
if (cookieSettingsArgs.isSome()) {
nsCOMPtr<nsICookieSettings> cookieSettings;
nsresult rv = aLoadInfo->GetCookieSettings(getter_AddRefs(cookieSettings));
if (NS_SUCCEEDED(rv) && cookieSettings) {
static_cast<CookieSettings*>(cookieSettings.get())
->Merge(cookieSettingsArgs.ref());
const Maybe<CookieJarSettingsArgs>& cookieJarSettingsArgs =
aForwarderArgs.cookieJarSettings();
if (cookieJarSettingsArgs.isSome()) {
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
nsresult rv =
aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
if (NS_SUCCEEDED(rv) && cookieJarSettings) {
static_cast<CookieJarSettings*>(cookieJarSettings.get())
->Merge(cookieJarSettingsArgs.ref());
}
}

View File

@ -240,7 +240,7 @@ class MOZ_STACK_CLASS ComponentLoaderInfo {
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_SCRIPT,
nullptr, // nsICookieSettings
nullptr, // nsICookieJarSettings
nullptr, // aPerformanceStorage
nullptr, // aLoadGroup
nullptr, // aCallbacks

View File

@ -257,7 +257,7 @@ bool mozJSSubScriptLoader::ReadScript(JS::MutableHandle<JSScript*> script,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // nsICookieSettings
nullptr, // nsICookieJarSettings
nullptr, // PerformanceStorage
nullptr, // aLoadGroup
nullptr, // aCallbacks

View File

@ -1470,7 +1470,7 @@ nsresult Loader::LoadSheet(SheetLoadData& aLoadData, SheetState aSheetState,
}
nsCOMPtr<nsILoadGroup> loadGroup;
nsCOMPtr<nsICookieSettings> cookieSettings;
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
if (mDocument) {
loadGroup = mDocument->GetDocumentLoadGroup();
// load for a document with no loadgrup indicates that something is
@ -1481,7 +1481,7 @@ nsresult Loader::LoadSheet(SheetLoadData& aLoadData, SheetState aSheetState,
return NS_ERROR_UNEXPECTED;
}
cookieSettings = mDocument->CookieSettings();
cookieJarSettings = mDocument->CookieJarSettings();
}
#ifdef DEBUG
@ -1523,7 +1523,7 @@ nsresult Loader::LoadSheet(SheetLoadData& aLoadData, SheetState aSheetState,
// triggeringPrincipal should always be the systemPrincipal.
rv = NS_NewChannel(getter_AddRefs(channel), aLoadData.mURI,
nsContentUtils::GetSystemPrincipal(), securityFlags,
contentPolicyType, cookieSettings,
contentPolicyType, cookieJarSettings,
/* aPerformanceStorage */ nullptr, loadGroup);
}

View File

@ -7197,9 +7197,9 @@
value: true
mirror: always
# Allow CookieSettings to be unblocked for channels without a document.
# Allow CookieJarSettings to be unblocked for channels without a document.
# This is for testing only.
- name: network.cookieSettings.unblocked_for_testing
- name: network.cookieJarSettings.unblocked_for_testing
type: bool
value: false
mirror: always

View File

@ -17,7 +17,7 @@
#include "mozilla/dom/BrowserChild.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/NullPrincipal.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozIThirdPartyUtil.h"
@ -223,7 +223,7 @@ LoadInfo::LoadInfo(
// Let's inherit the cookie behavior and permission from the parent
// document.
mCookieSettings = aLoadingContext->OwnerDoc()->CookieSettings();
mCookieJarSettings = aLoadingContext->OwnerDoc()->CookieJarSettings();
}
mInnerWindowID = aLoadingContext->OwnerDoc()->InnerWindowID();
@ -418,7 +418,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
// Let's take the current cookie behavior and current cookie permission
// for the documents' loadInfo. Note that for any other loadInfos,
// cookieBehavior will be BEHAVIOR_REJECT for security reasons.
mCookieSettings = CookieSettings::Create();
mCookieJarSettings = CookieJarSettings::Create();
}
LoadInfo::LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
@ -496,7 +496,7 @@ LoadInfo::LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
// Let's take the current cookie behavior and current cookie permission
// for the documents' loadInfo. Note that for any other loadInfos,
// cookieBehavior will be BEHAVIOR_REJECT for security reasons.
mCookieSettings = CookieSettings::Create();
mCookieJarSettings = CookieJarSettings::Create();
}
LoadInfo::LoadInfo(const LoadInfo& rhs)
@ -507,7 +507,7 @@ LoadInfo::LoadInfo(const LoadInfo& rhs)
mTopLevelPrincipal(rhs.mTopLevelPrincipal),
mTopLevelStorageAreaPrincipal(rhs.mTopLevelStorageAreaPrincipal),
mResultPrincipalURI(rhs.mResultPrincipalURI),
mCookieSettings(rhs.mCookieSettings),
mCookieJarSettings(rhs.mCookieJarSettings),
mCspToInherit(rhs.mCspToInherit),
mClientInfo(rhs.mClientInfo),
// mReservedClientSource must be handled specially during redirect
@ -571,7 +571,8 @@ LoadInfo::LoadInfo(
nsIPrincipal* aPrincipalToInherit, nsIPrincipal* aSandboxedLoadingPrincipal,
nsIPrincipal* aTopLevelPrincipal,
nsIPrincipal* aTopLevelStorageAreaPrincipal, nsIURI* aResultPrincipalURI,
nsICookieSettings* aCookieSettings, nsIContentSecurityPolicy* aCspToInherit,
nsICookieJarSettings* aCookieJarSettings,
nsIContentSecurityPolicy* aCspToInherit,
const Maybe<ClientInfo>& aClientInfo,
const Maybe<ClientInfo>& aReservedClientInfo,
const Maybe<ClientInfo>& aInitialClientInfo,
@ -607,7 +608,7 @@ LoadInfo::LoadInfo(
mTopLevelPrincipal(aTopLevelPrincipal),
mTopLevelStorageAreaPrincipal(aTopLevelStorageAreaPrincipal),
mResultPrincipalURI(aResultPrincipalURI),
mCookieSettings(aCookieSettings),
mCookieJarSettings(aCookieJarSettings),
mCspToInherit(aCspToInherit),
mClientInfo(aClientInfo),
mReservedClientInfo(aReservedClientInfo),
@ -867,41 +868,41 @@ LoadInfo::GetCookiePolicy(uint32_t* aResult) {
namespace {
already_AddRefed<nsICookieSettings> CreateCookieSettings(
already_AddRefed<nsICookieJarSettings> CreateCookieJarSettings(
nsContentPolicyType aContentPolicyType) {
if (StaticPrefs::network_cookieSettings_unblocked_for_testing()) {
return CookieSettings::Create();
if (StaticPrefs::network_cookieJarSettings_unblocked_for_testing()) {
return CookieJarSettings::Create();
}
// These contentPolictTypes require a real CookieSettings because favicon and
// save-as requests must send cookies. Anything else should not send/receive
// cookies.
// These contentPolictTypes require a real CookieJarSettings because favicon
// and save-as requests must send cookies. Anything else should not
// send/receive cookies.
if (aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON ||
aContentPolicyType == nsIContentPolicy::TYPE_SAVEAS_DOWNLOAD) {
return CookieSettings::Create();
return CookieJarSettings::Create();
}
return CookieSettings::CreateBlockingAll();
return CookieJarSettings::CreateBlockingAll();
}
} // namespace
NS_IMETHODIMP
LoadInfo::GetCookieSettings(nsICookieSettings** aCookieSettings) {
if (!mCookieSettings) {
mCookieSettings = CreateCookieSettings(mInternalContentPolicyType);
LoadInfo::GetCookieJarSettings(nsICookieJarSettings** aCookieJarSettings) {
if (!mCookieJarSettings) {
mCookieJarSettings = CreateCookieJarSettings(mInternalContentPolicyType);
}
nsCOMPtr<nsICookieSettings> cookieSettings = mCookieSettings;
cookieSettings.forget(aCookieSettings);
nsCOMPtr<nsICookieJarSettings> cookieJarSettings = mCookieJarSettings;
cookieJarSettings.forget(aCookieJarSettings);
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::SetCookieSettings(nsICookieSettings* aCookieSettings) {
MOZ_ASSERT(aCookieSettings);
// We allow the overwrite of CookieSettings.
mCookieSettings = aCookieSettings;
LoadInfo::SetCookieJarSettings(nsICookieJarSettings* aCookieJarSettings) {
MOZ_ASSERT(aCookieJarSettings);
// We allow the overwrite of CookieJarSettings.
mCookieJarSettings = aCookieJarSettings;
return NS_OK;
}

View File

@ -20,7 +20,7 @@
#include "mozilla/dom/ClientInfo.h"
#include "mozilla/dom/ServiceWorkerDescriptor.h"
class nsICookieSettings;
class nsICookieJarSettings;
class nsINode;
class nsPIDOMWindowOuter;
@ -132,7 +132,8 @@ class LoadInfo final : public nsILoadInfo {
nsIPrincipal* aSandboxedLoadingPrincipal,
nsIPrincipal* aTopLevelPrincipal,
nsIPrincipal* aTopLevelStorageAreaPrincipal,
nsIURI* aResultPrincipalURI, nsICookieSettings* aCookieSettings,
nsIURI* aResultPrincipalURI,
nsICookieJarSettings* aCookieJarSettings,
nsIContentSecurityPolicy* aCspToInherit,
const Maybe<mozilla::dom::ClientInfo>& aClientInfo,
const Maybe<mozilla::dom::ClientInfo>& aReservedClientInfo,
@ -204,7 +205,7 @@ class LoadInfo final : public nsILoadInfo {
nsCOMPtr<nsIPrincipal> mTopLevelStorageAreaPrincipal;
nsCOMPtr<nsIURI> mResultPrincipalURI;
nsCOMPtr<nsICSPEventListener> mCSPEventListener;
nsCOMPtr<nsICookieSettings> mCookieSettings;
nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;
nsCOMPtr<nsIContentSecurityPolicy> mCspToInherit;
Maybe<mozilla::dom::ClientInfo> mClientInfo;

View File

@ -196,7 +196,7 @@ static inline already_AddRefed<nsIChannel> SetupIPCheckChannel(bool ipv4) {
getter_AddRefs(channel), uri, nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // nsICookieSettings
nullptr, // nsICookieJarSettings
nullptr, // aPerformanceStorage
nullptr, // aLoadGroup
nullptr,

View File

@ -1183,7 +1183,7 @@ nsresult Predictor::Prefetch(nsIURI* uri, nsIURI* referrer,
nsresult rv = NS_NewChannel(
getter_AddRefs(channel), uri, nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER, nullptr, /* nsICookieSettings */
nsIContentPolicy::TYPE_OTHER, nullptr, /* nsICookieJarSettings */
nullptr, /* aPerformanceStorage */
nullptr, /* aLoadGroup */
nullptr, /* aCallbacks */

View File

@ -10,7 +10,7 @@
interface nsIChannel;
interface nsIContentSecurityPolicy;
interface nsICookieSettings;
interface nsICookieJarSettings;
interface nsICSPEventListener;
interface nsINode;
interface nsIPrincipal;
@ -433,10 +433,10 @@ interface nsILoadInfo : nsISupports
[infallible] readonly attribute unsigned long cookiePolicy;
/**
* The cookie settings inherited from the top-level document's loadInfo.
* The cookie jar settings inherited from the top-level document's loadInfo.
* It cannot be null.
*/
attribute nsICookieSettings cookieSettings;
attribute nsICookieJarSettings cookieJarSettings;
/**
* If forceInheritPrincipal is true, the data coming from the channel should

View File

@ -220,7 +220,7 @@ nsresult nsIncrementalDownload::ProcessTimeout() {
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // nsICookieSettings
nullptr, // nsICookieJarSettings
nullptr, // PerformanceStorage
nullptr, // loadGroup
this, // aCallbacks

View File

@ -309,7 +309,7 @@ nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri,
nsIPrincipal* aLoadingPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsICookieSettings* aCookieSettings /* = nullptr */,
nsICookieJarSettings* aCookieJarSettings /* = nullptr */,
PerformanceStorage* aPerformanceStorage /* = nullptr */,
nsILoadGroup* aLoadGroup /* = nullptr */,
nsIInterfaceRequestor* aCallbacks /* = nullptr */,
@ -322,7 +322,7 @@ nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri,
aLoadingPrincipal,
nullptr, // aTriggeringPrincipal
Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags,
aContentPolicyType, aCookieSettings, aPerformanceStorage, aLoadGroup,
aContentPolicyType, aCookieJarSettings, aPerformanceStorage, aLoadGroup,
aCallbacks, aLoadFlags, aIoService, aSandboxFlags);
}
@ -332,7 +332,7 @@ nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri,
const Maybe<ServiceWorkerDescriptor>& aController,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsICookieSettings* aCookieSettings /* = nullptr */,
nsICookieJarSettings* aCookieJarSettings /* = nullptr */,
PerformanceStorage* aPerformanceStorage /* = nullptr */,
nsILoadGroup* aLoadGroup /* = nullptr */,
nsIInterfaceRequestor* aCallbacks /* = nullptr */,
@ -350,7 +350,7 @@ nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri,
aLoadingPrincipal,
nullptr, // aTriggeringPrincipal
loadingClientInfo, aController, aSecurityFlags,
aContentPolicyType, aCookieSettings,
aContentPolicyType, aCookieJarSettings,
aPerformanceStorage, aLoadGroup, aCallbacks,
aLoadFlags, aIoService, aSandboxFlags);
}
@ -361,7 +361,7 @@ nsresult NS_NewChannelInternal(
const Maybe<ClientInfo>& aLoadingClientInfo,
const Maybe<ServiceWorkerDescriptor>& aController,
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
nsICookieSettings* aCookieSettings /* = nullptr */,
nsICookieJarSettings* aCookieJarSettings /* = nullptr */,
PerformanceStorage* aPerformanceStorage /* = nullptr */,
nsILoadGroup* aLoadGroup /* = nullptr */,
nsIInterfaceRequestor* aCallbacks /* = nullptr */,
@ -407,15 +407,15 @@ nsresult NS_NewChannelInternal(
NS_ENSURE_SUCCESS(rv, rv);
}
if (aPerformanceStorage || aCookieSettings) {
if (aPerformanceStorage || aCookieJarSettings) {
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
if (aPerformanceStorage) {
loadInfo->SetPerformanceStorage(aPerformanceStorage);
}
if (aCookieSettings) {
loadInfo->SetCookieSettings(aCookieSettings);
if (aCookieJarSettings) {
loadInfo->SetCookieJarSettings(aCookieJarSettings);
}
}
@ -440,7 +440,7 @@ NS_NewChannelWithTriggeringPrincipal(
outChannel, aUri, aLoadingNode, aLoadingNode->NodePrincipal(),
aTriggeringPrincipal, Maybe<ClientInfo>(),
Maybe<ServiceWorkerDescriptor>(), aSecurityFlags, aContentPolicyType,
aLoadingNode->OwnerDoc()->CookieSettings(), aPerformanceStorage,
aLoadingNode->OwnerDoc()->CookieJarSettings(), aPerformanceStorage,
aLoadGroup, aCallbacks, aLoadFlags, aIoService);
}
@ -449,7 +449,7 @@ nsresult NS_NewChannelWithTriggeringPrincipal(
nsIChannel** outChannel, nsIURI* aUri, nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aTriggeringPrincipal, nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsICookieSettings* aCookieSettings /* = nullptr */,
nsICookieJarSettings* aCookieJarSettings /* = nullptr */,
PerformanceStorage* aPerformanceStorage /* = nullptr */,
nsILoadGroup* aLoadGroup /* = nullptr */,
nsIInterfaceRequestor* aCallbacks /* = nullptr */,
@ -462,8 +462,8 @@ nsresult NS_NewChannelWithTriggeringPrincipal(
nullptr, // aLoadingNode
aLoadingPrincipal, aTriggeringPrincipal, Maybe<ClientInfo>(),
Maybe<ServiceWorkerDescriptor>(), aSecurityFlags, aContentPolicyType,
aCookieSettings, aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags,
aIoService);
aCookieJarSettings, aPerformanceStorage, aLoadGroup, aCallbacks,
aLoadFlags, aIoService);
}
// See NS_NewChannelInternal for usage and argument description
@ -472,7 +472,7 @@ nsresult NS_NewChannelWithTriggeringPrincipal(
nsIPrincipal* aTriggeringPrincipal, const ClientInfo& aLoadingClientInfo,
const Maybe<ServiceWorkerDescriptor>& aController,
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
nsICookieSettings* aCookieSettings /* = nullptr */,
nsICookieJarSettings* aCookieJarSettings /* = nullptr */,
PerformanceStorage* aPerformanceStorage /* = nullptr */,
nsILoadGroup* aLoadGroup /* = nullptr */,
nsIInterfaceRequestor* aCallbacks /* = nullptr */,
@ -488,8 +488,8 @@ nsresult NS_NewChannelWithTriggeringPrincipal(
outChannel, aUri,
nullptr, // aLoadingNode
aLoadingPrincipal, aTriggeringPrincipal, loadingClientInfo, aController,
aSecurityFlags, aContentPolicyType, aCookieSettings, aPerformanceStorage,
aLoadGroup, aCallbacks, aLoadFlags, aIoService);
aSecurityFlags, aContentPolicyType, aCookieJarSettings,
aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService);
}
nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri,
@ -506,7 +506,7 @@ nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri,
outChannel, aUri, aLoadingNode, aLoadingNode->NodePrincipal(),
nullptr, // aTriggeringPrincipal
Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags,
aContentPolicyType, aLoadingNode->OwnerDoc()->CookieSettings(),
aContentPolicyType, aLoadingNode->OwnerDoc()->CookieJarSettings(),
aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService,
aSandboxFlags);
}
@ -932,7 +932,7 @@ nsresult NS_NewStreamLoaderInternal(
nullptr, // aTriggeringPrincipal
Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags,
aContentPolicyType,
nullptr, // nsICookieSettings
nullptr, // nsICookieJarSettings
nullptr, // PerformanceStorage
aLoadGroup, aCallbacks, aLoadFlags);

View File

@ -33,7 +33,7 @@ class nsIAuthPrompt;
class nsIAuthPrompt2;
class nsIChannel;
class nsIChannelPolicy;
class nsICookieSettings;
class nsICookieJarSettings;
class nsIDownloadObserver;
class nsIEventTarget;
class nsIFileProtocolHandler;
@ -159,7 +159,7 @@ nsresult NS_NewChannelInternal(
const mozilla::Maybe<mozilla::dom::ClientInfo>& aLoadingClientInfo,
const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController,
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
nsICookieSettings* aCookieSettings = nullptr,
nsICookieJarSettings* aCookieJarSettings = nullptr,
mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
nsILoadGroup* aLoadGroup = nullptr,
nsIInterfaceRequestor* aCallbacks = nullptr,
@ -192,7 +192,7 @@ nsresult NS_NewChannelWithTriggeringPrincipal(
nsIChannel** outChannel, nsIURI* aUri, nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aTriggeringPrincipal, nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsICookieSettings* aCookieSettings = nullptr,
nsICookieJarSettings* aCookieJarSettings = nullptr,
mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
nsILoadGroup* aLoadGroup = nullptr,
nsIInterfaceRequestor* aCallbacks = nullptr,
@ -206,7 +206,7 @@ nsresult NS_NewChannelWithTriggeringPrincipal(
const mozilla::dom::ClientInfo& aLoadingClientInfo,
const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController,
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
nsICookieSettings* aCookieSettings = nullptr,
nsICookieJarSettings* aCookieJarSettings = nullptr,
mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
nsILoadGroup* aLoadGroup = nullptr,
nsIInterfaceRequestor* aCallbacks = nullptr,
@ -227,7 +227,7 @@ nsresult NS_NewChannel(
nsresult NS_NewChannel(
nsIChannel** outChannel, nsIURI* aUri, nsIPrincipal* aLoadingPrincipal,
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
nsICookieSettings* aCookieSettings = nullptr,
nsICookieJarSettings* aCookieJarSettings = nullptr,
mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
nsILoadGroup* aLoadGroup = nullptr,
nsIInterfaceRequestor* aCallbacks = nullptr,
@ -240,7 +240,7 @@ nsresult NS_NewChannel(
const mozilla::dom::ClientInfo& aLoadingClientInfo,
const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController,
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
nsICookieSettings* aCookieSettings = nullptr,
nsICookieJarSettings* aCookieJarSettings = nullptr,
mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
nsILoadGroup* aLoadGroup = nullptr,
nsIInterfaceRequestor* aCallbacks = nullptr,

View File

@ -636,7 +636,7 @@ void nsPACMan::ContinueLoadingAfterPACUriKnown() {
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // nsICookieSettings
nullptr, // nsICookieJarSettings
nullptr, // PerformanceStorage
nullptr, // aLoadGroup
nullptr, // aCallbacks

View File

@ -4,8 +4,10 @@
* 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/. */
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/net/NeckoChannelParams.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/SystemGroup.h"
#include "mozilla/Unused.h"
#include "nsGlobalWindowInner.h"
#if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
@ -13,6 +15,7 @@
#endif
#include "nsPermission.h"
#include "nsPermissionManager.h"
#include "nsICookieService.h"
namespace mozilla {
namespace net {
@ -64,39 +67,39 @@ class ReleaseCookiePermissions final : public Runnable {
} // namespace
// static
already_AddRefed<nsICookieSettings> CookieSettings::CreateBlockingAll() {
already_AddRefed<nsICookieJarSettings> CookieJarSettings::CreateBlockingAll() {
MOZ_ASSERT(NS_IsMainThread());
RefPtr<CookieSettings> cookieSettings =
new CookieSettings(nsICookieService::BEHAVIOR_REJECT, eFixed);
return cookieSettings.forget();
RefPtr<CookieJarSettings> cookieJarSettings =
new CookieJarSettings(nsICookieService::BEHAVIOR_REJECT, eFixed);
return cookieJarSettings.forget();
}
// static
already_AddRefed<nsICookieSettings> CookieSettings::Create() {
already_AddRefed<nsICookieJarSettings> CookieJarSettings::Create() {
MOZ_ASSERT(NS_IsMainThread());
RefPtr<CookieSettings> cookieSettings = new CookieSettings(
RefPtr<CookieJarSettings> cookieJarSettings = new CookieJarSettings(
StaticPrefs::network_cookie_cookieBehavior(), eProgressive);
return cookieSettings.forget();
return cookieJarSettings.forget();
}
// static
already_AddRefed<nsICookieSettings> CookieSettings::Create(
already_AddRefed<nsICookieJarSettings> CookieJarSettings::Create(
uint32_t aCookieBehavior) {
MOZ_ASSERT(NS_IsMainThread());
RefPtr<CookieSettings> cookieSettings =
new CookieSettings(aCookieBehavior, eProgressive);
return cookieSettings.forget();
RefPtr<CookieJarSettings> cookieJarSettings =
new CookieJarSettings(aCookieBehavior, eProgressive);
return cookieJarSettings.forget();
}
CookieSettings::CookieSettings(uint32_t aCookieBehavior, State aState)
CookieJarSettings::CookieJarSettings(uint32_t aCookieBehavior, State aState)
: mCookieBehavior(aCookieBehavior), mState(aState), mToBeMerged(false) {
MOZ_ASSERT(NS_IsMainThread());
}
CookieSettings::~CookieSettings() {
CookieJarSettings::~CookieJarSettings() {
if (!NS_IsMainThread() && !mCookiePermissions.IsEmpty()) {
nsCOMPtr<nsIEventTarget> systemGroupEventTarget =
mozilla::SystemGroup::EventTargetFor(mozilla::TaskCategory::Other);
@ -110,13 +113,14 @@ CookieSettings::~CookieSettings() {
}
NS_IMETHODIMP
CookieSettings::GetCookieBehavior(uint32_t* aCookieBehavior) {
CookieJarSettings::GetCookieBehavior(uint32_t* aCookieBehavior) {
*aCookieBehavior = mCookieBehavior;
return NS_OK;
}
NS_IMETHODIMP
CookieSettings::GetRejectThirdPartyTrackers(bool* aRejectThirdPartyTrackers) {
CookieJarSettings::GetRejectThirdPartyTrackers(
bool* aRejectThirdPartyTrackers) {
*aRejectThirdPartyTrackers =
mCookieBehavior == nsICookieService::BEHAVIOR_REJECT_TRACKER ||
mCookieBehavior ==
@ -125,7 +129,7 @@ CookieSettings::GetRejectThirdPartyTrackers(bool* aRejectThirdPartyTrackers) {
}
NS_IMETHODIMP
CookieSettings::GetLimitForeignContexts(bool* aLimitForeignContexts) {
CookieJarSettings::GetLimitForeignContexts(bool* aLimitForeignContexts) {
*aLimitForeignContexts =
mCookieBehavior == nsICookieService::BEHAVIOR_LIMIT_FOREIGN ||
(StaticPrefs::privacy_dynamic_firstparty_limitForeign() &&
@ -135,7 +139,7 @@ CookieSettings::GetLimitForeignContexts(bool* aLimitForeignContexts) {
}
NS_IMETHODIMP
CookieSettings::GetPartitionForeign(bool* aPartitionForeign) {
CookieJarSettings::GetPartitionForeign(bool* aPartitionForeign) {
*aPartitionForeign =
mCookieBehavior ==
nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN;
@ -143,7 +147,7 @@ CookieSettings::GetPartitionForeign(bool* aPartitionForeign) {
}
NS_IMETHODIMP
CookieSettings::SetPartitionForeign(bool aPartitionForeign) {
CookieJarSettings::SetPartitionForeign(bool aPartitionForeign) {
if (aPartitionForeign) {
mCookieBehavior =
nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN;
@ -152,8 +156,8 @@ CookieSettings::SetPartitionForeign(bool aPartitionForeign) {
}
NS_IMETHODIMP
CookieSettings::CookiePermission(nsIPrincipal* aPrincipal,
uint32_t* aCookiePermission) {
CookieJarSettings::CookiePermission(nsIPrincipal* aPrincipal,
uint32_t* aCookiePermission) {
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_ARG_POINTER(aPrincipal);
NS_ENSURE_ARG_POINTER(aCookiePermission);
@ -224,7 +228,7 @@ CookieSettings::CookiePermission(nsIPrincipal* aPrincipal,
return NS_OK;
}
void CookieSettings::Serialize(CookieSettingsArgs& aData) {
void CookieJarSettings::Serialize(CookieJarSettingsArgs& aData) {
MOZ_ASSERT(NS_IsMainThread());
aData.isFixed() = mState == eFixed;
@ -237,7 +241,7 @@ void CookieSettings::Serialize(CookieSettingsArgs& aData) {
continue;
}
PrincipalInfo principalInfo;
ipc::PrincipalInfo principalInfo;
rv = PrincipalToPrincipalInfo(principal, &principalInfo,
true /* aSkipBaseDomain */);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -257,8 +261,9 @@ void CookieSettings::Serialize(CookieSettingsArgs& aData) {
mToBeMerged = false;
}
/* static */ void CookieSettings::Deserialize(
const CookieSettingsArgs& aData, nsICookieSettings** aCookieSettings) {
/* static */ void CookieJarSettings::Deserialize(
const CookieJarSettingsArgs& aData,
nsICookieJarSettings** aCookieJarSettings) {
MOZ_ASSERT(NS_IsMainThread());
CookiePermissionList list;
@ -279,15 +284,15 @@ void CookieSettings::Serialize(CookieSettingsArgs& aData) {
list.AppendElement(permission);
}
RefPtr<CookieSettings> cookieSettings = new CookieSettings(
RefPtr<CookieJarSettings> cookieJarSettings = new CookieJarSettings(
aData.cookieBehavior(), aData.isFixed() ? eFixed : eProgressive);
cookieSettings->mCookiePermissions.SwapElements(list);
cookieJarSettings->mCookiePermissions.SwapElements(list);
cookieSettings.forget(aCookieSettings);
cookieJarSettings.forget(aCookieJarSettings);
}
void CookieSettings::Merge(const CookieSettingsArgs& aData) {
void CookieJarSettings::Merge(const CookieJarSettingsArgs& aData) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(
mCookieBehavior == aData.cookieBehavior() ||
@ -341,7 +346,7 @@ void CookieSettings::Merge(const CookieSettingsArgs& aData) {
}
}
NS_IMPL_ISUPPORTS(CookieSettings, nsICookieSettings)
NS_IMPL_ISUPPORTS(CookieJarSettings, nsICookieJarSettings)
} // namespace net
} // namespace mozilla

View File

@ -0,0 +1,162 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_net_CookieJarSettings_h
#define mozilla_net_CookieJarSettings_h
#include "nsICookieJarSettings.h"
#include "nsDataHashtable.h"
#include "nsTArray.h"
class nsIPermission;
namespace mozilla {
namespace net {
class CookieJarSettingsArgs;
/**
* CookieJarSettings
* ~~~~~~~~~~~~~~
*
* CookieJarSettings is a snapshot of the cookie jar's configurations in a
* precise moment of time, such as the cookie policy and cookie permissions.
* This object is used by top-level documents to have a consistent cookie jar
* configuration also in case the user changes it. New configurations will apply
* only to new top-level documents.
*
* CookieJarSettings creation
* ~~~~~~~~~~~~~~~~~~~~~~~
*
* CookieJarSettings is created when the top-level document's nsIChannel's
* nsILoadInfo is constructed. Any sub-resource and any sub-document inherits it
* from that nsILoadInfo. Also dedicated workers and their resources inherit it
* from the parent document.
*
* SharedWorkers and ServiceWorkers have their own CookieJarSettings because
* they don't have a single parent document (SharedWorkers could have more than
* one, ServiceWorkers have none).
*
* In Chrome code, we have a new CookieJarSettings when we download resources
* via 'Save-as...' and we also have a new CookieJarSettings for favicon
* downloading.
*
* Content-scripts WebExtensions also have their own CookieJarSettings because
* they don't have a direct access to the document they are running into.
*
* Anything else will have a special CookieJarSettings which blocks everything
* (CookieJarSettings::GetBlockingAll()) by forcing BEHAVIOR_REJECT as policy.
* When this happens, that context will not have access to the cookie jar and no
* cookies are sent or received.
*
* Propagation of CookieJarSettings
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* CookieJarSettings are shared inside the same top-level document via its
* nsIChannel's nsILoadInfo. This is done automatically if you pass a nsINode
* to NS_NewChannel(), and it must be done manually if you use a different
* channel constructor. For instance, this happens for any worker networking
* operation.
*
* We use the same CookieJarSettings for any resource belonging to the top-level
* document even if cross-origin. This makes the browser behave consistently a
* scenario where A loads B which loads A again, and cookie policy/permission
* changes in the meantime.
*
* Cookie Permissions propagation
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* CookieJarSettings populates the known cookie permissions only when required.
* Initially the list is empty, but when CookieJarSettings::CookiePermission()
* is called, the requested permission is stored in the internal list if it
* doesn't exist yet.
*
* This is actually nice because it relies on the permission propagation from
* parent to content process. No extra IPC is required.
*
* Note that we store permissions with UNKNOWN_ACTION values too because they
* can be set after the loading of the top-level document and we don't want to
* return a different value when this happens.
*
* Use of CookieJarSettings
* ~~~~~~~~~~~~~~~~~~~~~
*
* In theory, there should not be direct access to cookie permissions or
* cookieBehavior pref. Everything should pass through CookieJarSettings.
*
* A reference to CookieJarSettings can be obtained from
* nsILoadInfo::GetCookieJarSettings(), from Document::CookieJarSettings() and
* from the WorkerPrivate::CookieJarSettings().
*
* CookieJarSettings is thread-safe, but the permission list must be touched
* only on the main-thread.
*
* Testing
* ~~~~~~~
*
* If you need to test the changing of cookie policy or a cookie permission, you
* need to workaround CookieJarSettings. This can be done opening a new window
* and running the test into that new global.
*/
/**
* Class that provides an nsICookieJarSettings implementation.
*/
class CookieJarSettings final : public nsICookieJarSettings {
public:
typedef nsTArray<RefPtr<nsIPermission>> CookiePermissionList;
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSICOOKIEJARSETTINGS
static already_AddRefed<nsICookieJarSettings> CreateBlockingAll();
static already_AddRefed<nsICookieJarSettings> Create();
static already_AddRefed<nsICookieJarSettings> Create(
uint32_t aCookieBehavior);
static CookieJarSettings* Cast(nsICookieJarSettings* aCS) {
return static_cast<CookieJarSettings*>(aCS);
}
void Serialize(CookieJarSettingsArgs& aData);
static void Deserialize(const CookieJarSettingsArgs& aData,
nsICookieJarSettings** aCookieJarSettings);
void Merge(const CookieJarSettingsArgs& aData);
// We don't want to send this object from parent to child process if there are
// no reasons. HasBeenChanged() returns true if the object has changed its
// internal state and it must be sent beck to the content process.
bool HasBeenChanged() const { return mToBeMerged; }
private:
enum State {
// No cookie permissions are allowed to be stored in this object.
eFixed,
// Cookie permissions can be stored in case they are unknown when they are
// asked or when they are sent from the parent process.
eProgressive,
};
CookieJarSettings(uint32_t aCookieBehavior, State aState);
~CookieJarSettings();
uint32_t mCookieBehavior;
CookiePermissionList mCookiePermissions;
State mState;
bool mToBeMerged;
};
} // namespace net
} // namespace mozilla
#endif // mozilla_net_CookieJarSettings_h

View File

@ -279,11 +279,11 @@ void CookieServiceChild::GetCookieStringFromCookieHashTable(
int64_t currentTimeInUsec = PR_Now();
int64_t currentTime = currentTimeInUsec / PR_USEC_PER_SEC;
nsCOMPtr<nsICookieSettings> cookieSettings =
nsCookieService::GetCookieSettings(aChannel);
nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
nsCookieService::GetCookieJarSettings(aChannel);
CookieStatus cookieStatus = nsCookieService::CheckPrefs(
cookieSettings, aHostURI, aIsForeign, aIsThirdPartyTrackingResource,
cookieJarSettings, aHostURI, aIsForeign, aIsThirdPartyTrackingResource,
aIsThirdPartySocialTrackingResource, aFirstPartyStorageAccessGranted,
VoidCString(), CountCookiesFromHashTable(baseDomain, attrs), attrs,
&aRejectedReason);
@ -377,13 +377,14 @@ void CookieServiceChild::SetCookieInternal(
return false;
}
nsCOMPtr<nsICookieSettings> cookieSettings;
nsresult rv = aLoadInfo->GetCookieSettings(getter_AddRefs(cookieSettings));
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
nsresult rv =
aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
uint32_t cookieBehavior = cookieSettings->GetCookieBehavior();
uint32_t cookieBehavior = cookieJarSettings->GetCookieBehavior();
return cookieBehavior == nsICookieService::BEHAVIOR_REJECT_FOREIGN ||
cookieBehavior == nsICookieService::BEHAVIOR_LIMIT_FOREIGN ||
cookieBehavior == nsICookieService::BEHAVIOR_REJECT_TRACKER ||
@ -518,11 +519,12 @@ nsresult CookieServiceChild::SetCookieStringInternal(
nsCookieService::GetBaseDomain(mTLDService, aHostURI, baseDomain,
requireHostMatch);
nsCOMPtr<nsICookieSettings> cookieSettings =
nsCookieService::GetCookieSettings(aChannel);
nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
nsCookieService::GetCookieJarSettings(aChannel);
CookieStatus cookieStatus = nsCookieService::CheckPrefs(
cookieSettings, aHostURI, result.contains(ThirdPartyAnalysis::IsForeign),
cookieJarSettings, aHostURI,
result.contains(ThirdPartyAnalysis::IsForeign),
result.contains(ThirdPartyAnalysis::IsThirdPartyTrackingResource),
result.contains(ThirdPartyAnalysis::IsThirdPartySocialTrackingResource),
result.contains(ThirdPartyAnalysis::IsFirstPartyStorageAccessGranted),

View File

@ -1,158 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_net_CookieSettings_h
#define mozilla_net_CookieSettings_h
#include "nsICookieSettings.h"
#include "nsDataHashtable.h"
class nsIPermission;
namespace mozilla {
namespace net {
class CookieSettingsArgs;
/**
* CookieSettings
* ~~~~~~~~~~~~~~
*
* CookieSettings is a snapshot of cookie policy and cookie permissions in a
* precise moment of time. This object is used by top-level documents to have a
* consistent cookie configuration also in case the user changes it. New cookie
* configurations will apply only to new top-level documents.
*
* CookieSettings creation
* ~~~~~~~~~~~~~~~~~~~~~~~
*
* CookieSettings is created when the top-level document's nsIChannel's
* nsILoadInfo is constructed. Any sub-resource and any sub-document inherits it
* from that nsILoadInfo. Also dedicated workers and their resources inherit it
* from the parent document.
*
* SharedWorkers and ServiceWorkers have their own CookieSettings because they
* don't have a single parent document (SharedWorkers could have more than one,
* ServiceWorkers have none).
*
* In Chrome code, we have a new CookieSettings when we download resources via
* 'Save-as...' and we also have a new CookieSettings for favicon downloading.
*
* Content-scripts WebExtensions also have their own CookieSettings because they
* don't have a direct access to the document they are running into.
*
* Anything else will have a special CookieSettings which blocks everything
* (CookieSettings::CreateBlockingAll()) by forcing BEHAVIOR_REJECT as policy.
* When this happens, that context will not have access to the cookie jar and no
* cookies are sent or received.
*
* Propagation of CookieSettings
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* CookieSettings are shared inside the same top-level document via its
* nsIChannel's nsILoadInfo. This is done automatically if you pass a nsINode
* to NS_NewChannel(), and it must be done manually if you use a different
* channel constructor. For instance, this happens for any worker networking
* operation.
*
* We use the same CookieSettings for any resource belonging to the top-level
* document even if cross-origin. This makes the browser behave consistently a
* scenario where A loads B which loads A again, and cookie policy/permission
* changes in the meantime.
*
* Cookie Permissions propagation
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* CookieSettings populates the known cookie permissions only when required.
* Initially the list is empty, but when CookieSettings::CookiePermission() is
* called, the requested permission is stored in the internal list if it doesn't
* exist yet.
*
* This is actually nice because it relies on the permission propagation from
* parent to content process. No extra IPC is required.
*
* Note that we store permissions with UNKNOWN_ACTION values too because they
* can be set after the loading of the top-level document and we don't want to
* return a different value when this happens.
*
* Use of CookieSettings
* ~~~~~~~~~~~~~~~~~~~~~
*
* In theory, there should not be direct access to cookie permissions or
* cookieBehavior pref. Everything should pass through CookieSettings.
*
* A reference to CookieSettings can be obtained from
* nsILoadInfo::GetCookieSettings(), from Document::CookieSettings() and from
* the WorkerPrivate::CookieSettings().
*
* CookieSettings is thread-safe, but the permission list must be touched only
* on the main-thread.
*
* Testing
* ~~~~~~~
*
* If you need to test the changing of cookie policy or a cookie permission, you
* need to workaround CookieSettings. This can be done opening a new window and
* running the test into that new global.
*/
/**
* Class that provides an nsICookieSettings implementation.
*/
class CookieSettings final : public nsICookieSettings {
public:
typedef nsTArray<RefPtr<nsIPermission>> CookiePermissionList;
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSICOOKIESETTINGS
static already_AddRefed<nsICookieSettings> CreateBlockingAll();
static already_AddRefed<nsICookieSettings> Create();
static already_AddRefed<nsICookieSettings> Create(uint32_t aCookieBehavior);
static CookieSettings* Cast(nsICookieSettings* aCS) {
return static_cast<CookieSettings*>(aCS);
}
void Serialize(CookieSettingsArgs& aData);
static void Deserialize(const CookieSettingsArgs& aData,
nsICookieSettings** aCookieSettings);
void Merge(const CookieSettingsArgs& aData);
// We don't want to send this object from parent to child process if there are
// no reasons. HasBeenChanged() returns true if the object has changed its
// internal state and it must be sent beck to the content process.
bool HasBeenChanged() const { return mToBeMerged; }
private:
enum State {
// No cookie permissions are allowed to be stored in this object.
eFixed,
// Cookie permissions can be stored in case they are unknown when they are
// asked or when they are sent from the parent process.
eProgressive,
};
CookieSettings(uint32_t aCookieBehavior, State aState);
~CookieSettings();
uint32_t mCookieBehavior;
CookiePermissionList mCookiePermissions;
State mState;
bool mToBeMerged;
};
} // namespace net
} // namespace mozilla
#endif // mozilla_net_CookieSettings_h

View File

@ -10,10 +10,10 @@ with Files('**'):
# export required interfaces, even if --disable-cookies has been given
XPIDL_SOURCES += [
'nsICookie.idl',
'nsICookieJarSettings.idl',
'nsICookieManager.idl',
'nsICookiePermission.idl',
'nsICookieService.idl',
'nsICookieSettings.idl',
]
XPIDL_MODULE = 'necko_cookie'
@ -24,15 +24,15 @@ if CONFIG['NECKO_COOKIES']:
]
EXPORTS.mozilla.net = [
'CookieJarSettings.h',
'CookieServiceChild.h',
'CookieServiceParent.h',
'CookieSettings.h',
'nsCookieKey.h',
]
UNIFIED_SOURCES += [
'CookieJarSettings.cpp',
'CookieServiceChild.cpp',
'CookieServiceParent.cpp',
'CookieSettings.cpp',
'nsCookie.cpp',
'nsCookiePermission.cpp',
]

View File

@ -13,7 +13,7 @@
#include "mozilla/StorageAccess.h"
#include "mozilla/Unused.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/net/CookieServiceChild.h"
#include "mozilla/net/HttpBaseChannel.h"
#include "mozilla/net/NeckoCommon.h"
@ -2083,21 +2083,22 @@ nsresult nsCookieService::GetCookieStringCommon(nsIURI* aHostURI,
}
// static
already_AddRefed<nsICookieSettings> nsCookieService::GetCookieSettings(
already_AddRefed<nsICookieJarSettings> nsCookieService::GetCookieJarSettings(
nsIChannel* aChannel) {
nsCOMPtr<nsICookieSettings> cookieSettings;
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
if (aChannel) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
nsresult rv = loadInfo->GetCookieSettings(getter_AddRefs(cookieSettings));
nsresult rv =
loadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
if (NS_WARN_IF(NS_FAILED(rv))) {
cookieSettings = CookieSettings::CreateBlockingAll();
cookieJarSettings = CookieJarSettings::CreateBlockingAll();
}
} else {
cookieSettings = CookieSettings::Create();
cookieJarSettings = CookieJarSettings::Create();
}
MOZ_ASSERT(cookieSettings);
return cookieSettings.forget();
MOZ_ASSERT(cookieJarSettings);
return cookieJarSettings.forget();
}
NS_IMETHODIMP
@ -2221,7 +2222,8 @@ void nsCookieService::SetCookieStringInternal(
}
nsCookieKey key(baseDomain, aOriginAttrs);
nsCOMPtr<nsICookieSettings> cookieSettings = GetCookieSettings(aChannel);
nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
GetCookieJarSettings(aChannel);
// check default prefs
uint32_t priorCookieCount = 0;
@ -2231,7 +2233,7 @@ void nsCookieService::SetCookieStringInternal(
CountCookiesFromHostInternal(hostFromURI, aOriginAttrs.mPrivateBrowsingId,
&priorCookieCount);
CookieStatus cookieStatus = CheckPrefs(
cookieSettings, aHostURI, aIsForeign, aIsThirdPartyTrackingResource,
cookieJarSettings, aHostURI, aIsForeign, aIsThirdPartyTrackingResource,
aIsThirdPartySocialTrackingResource, aFirstPartyStorageAccessGranted,
aCookieHeader, priorCookieCount, aOriginAttrs, &rejectedReason);
@ -3021,7 +3023,8 @@ void nsCookieService::GetCookiesForURI(
return;
}
nsCOMPtr<nsICookieSettings> cookieSettings = GetCookieSettings(aChannel);
nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
GetCookieJarSettings(aChannel);
// check default prefs
uint32_t rejectedReason = aRejectedReason;
@ -3029,7 +3032,7 @@ void nsCookieService::GetCookiesForURI(
CountCookiesFromHostInternal(hostFromURI, aOriginAttrs.mPrivateBrowsingId,
&priorCookieCount);
CookieStatus cookieStatus = CheckPrefs(
cookieSettings, aHostURI, aIsForeign, aIsThirdPartyTrackingResource,
cookieJarSettings, aHostURI, aIsForeign, aIsThirdPartyTrackingResource,
aIsThirdPartySocialTrackingResource, aFirstPartyStorageAccessGranted,
VoidCString(), priorCookieCount, aOriginAttrs, &rejectedReason);
@ -3987,7 +3990,7 @@ static inline bool IsSubdomainOf(const nsCString& a, const nsCString& b) {
}
CookieStatus nsCookieService::CheckPrefs(
nsICookieSettings* aCookieSettings, nsIURI* aHostURI, bool aIsForeign,
nsICookieJarSettings* aCookieJarSettings, nsIURI* aHostURI, bool aIsForeign,
bool aIsThirdPartyTrackingResource,
bool aIsThirdPartySocialTrackingResource,
bool aFirstPartyStorageAccessGranted, const nsACString& aCookieHeader,
@ -4019,7 +4022,7 @@ CookieStatus nsCookieService::CheckPrefs(
// check the permission list first; if we find an entry, it overrides
// default prefs. see bug 184059.
uint32_t cookiePermission = nsICookiePermission::ACCESS_DEFAULT;
rv = aCookieSettings->CookiePermission(principal, &cookiePermission);
rv = aCookieJarSettings->CookiePermission(principal, &cookiePermission);
if (NS_SUCCEEDED(rv)) {
switch (cookiePermission) {
case nsICookiePermission::ACCESS_DENY:
@ -4040,7 +4043,7 @@ CookieStatus nsCookieService::CheckPrefs(
// access to the first-party cookie jar.
if (aIsForeign && aIsThirdPartyTrackingResource &&
!aFirstPartyStorageAccessGranted &&
aCookieSettings->GetRejectThirdPartyTrackers()) {
aCookieJarSettings->GetRejectThirdPartyTrackers()) {
// Explicitly pass nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER
// here to ensure that we are testing the partitioning configuration only
// for the nsICookieService::BEHAVIOR_REJECT_TRACKER configuration.
@ -4048,7 +4051,7 @@ CookieStatus nsCookieService::CheckPrefs(
// don't want to give a free pass to tracker cookies here!
if (StoragePartitioningEnabled(
nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER,
aCookieSettings)) {
aCookieJarSettings)) {
MOZ_ASSERT(!aOriginAttrs.mFirstPartyDomain.IsEmpty(),
"We must have a StoragePrincipal here!");
return STATUS_ACCEPTED;
@ -4070,7 +4073,7 @@ CookieStatus nsCookieService::CheckPrefs(
// Check aFirstPartyStorageAccessGranted when checking aCookieBehavior
// so that we take things such as the content blocking allow list into
// account.
if (aCookieSettings->GetCookieBehavior() ==
if (aCookieJarSettings->GetCookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT &&
!aFirstPartyStorageAccessGranted) {
COOKIE_LOGFAILURE(aCookieHeader.IsVoid() ? GET_COOKIE : SET_COOKIE,
@ -4081,7 +4084,7 @@ CookieStatus nsCookieService::CheckPrefs(
// check if cookie is foreign
if (aIsForeign) {
if (aCookieSettings->GetCookieBehavior() ==
if (aCookieJarSettings->GetCookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT_FOREIGN &&
!aFirstPartyStorageAccessGranted) {
COOKIE_LOGFAILURE(aCookieHeader.IsVoid() ? GET_COOKIE : SET_COOKIE,
@ -4090,7 +4093,7 @@ CookieStatus nsCookieService::CheckPrefs(
return STATUS_REJECTED;
}
if (aCookieSettings->GetLimitForeignContexts() &&
if (aCookieJarSettings->GetLimitForeignContexts() &&
!aFirstPartyStorageAccessGranted && aNumOfCookies == 0) {
COOKIE_LOGFAILURE(aCookieHeader.IsVoid() ? GET_COOKIE : SET_COOKIE,
aHostURI, aCookieHeader, "context is third party");

View File

@ -34,7 +34,7 @@
using mozilla::OriginAttributes;
class nsICookiePermission;
class nsICookieSettings;
class nsICookieJarSettings;
class nsIEffectiveTLDService;
class nsIIDNService;
class nsIPrefBranch;
@ -204,7 +204,7 @@ class nsCookieService final : public nsICookieService,
bool aFromHttp, nsIChannel* aChannel,
bool& aSetCookie,
mozIThirdPartyUtil* aThirdPartyUtil);
static CookieStatus CheckPrefs(nsICookieSettings* aCookieSettings,
static CookieStatus CheckPrefs(nsICookieJarSettings* aCookieJarSettings,
nsIURI* aHostURI, bool aIsForeign,
bool aIsThirdPartyTrackingResource,
bool aIsThirdPartySocialTrackingResource,
@ -215,7 +215,7 @@ class nsCookieService final : public nsICookieService,
uint32_t* aRejectedReason);
static int64_t ParseServerTime(const nsACString& aServerTime);
static already_AddRefed<nsICookieSettings> GetCookieSettings(
static already_AddRefed<nsICookieJarSettings> GetCookieJarSettings(
nsIChannel* aChannel);
void GetCookiesForURI(nsIURI* aHostURI, nsIChannel* aChannel, bool aIsForeign,

View File

@ -9,10 +9,11 @@
interface nsIPrincipal;
/**
* Cookie settings for top-level documents.
* Cookie jar settings for top-level documents. Please see CookieJarSettings.h
* for more details.
*/
[builtinclass, uuid(3ec40331-7cf0-4b71-ba2a-2265aab8f6bc)]
interface nsICookieSettings : nsISupports
interface nsICookieJarSettings : nsISupports
{
/**
* CookieBehavior at the loading of the document. Any other loadInfo

View File

@ -1,5 +1,5 @@
// BroadcastChannel is not considered part of CookieJar. It's not allowed to
// communicate with other windows with different cookie settings.
// communicate with other windows with different cookie jar settings.
CookiePolicyHelper.runTest("BroadcastChannel", {
cookieJarAccessAllowed: async w => {

View File

@ -45,7 +45,7 @@ add_task(async _ => {
if (!inChildProcess()) {
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
Services.prefs.setBoolPref("network.cookie.sameSite.laxByDefault", true);

View File

@ -250,7 +250,7 @@ nsresult TRR::SendHTTPRequest() {
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // nsICookieSettings
nullptr, // nsICookieJarSettings
nullptr, // PerformanceStorage
nullptr, // aLoadGroup
this,

View File

@ -28,7 +28,7 @@ namespace mozilla {
namespace net {
//-----------------------------------------------------------------------------
// CookieSettings IPDL structs
// CookieJarSettings IPDL structs
//-----------------------------------------------------------------------------
struct CookiePermissionData
@ -37,7 +37,7 @@ struct CookiePermissionData
uint32_t cookiePermission;
};
struct CookieSettingsArgs
struct CookieJarSettingsArgs
{
// Copy of the cookie behavior and permissions for the top-level document.
uint32_t cookieBehavior;
@ -145,7 +145,7 @@ struct LoadInfoArgs
nsString cspNonce;
bool skipContentSniffing;
bool isFromProcessingFrameAttributes;
CookieSettingsArgs cookieSettings;
CookieJarSettingsArgs cookieJarSettings;
uint32_t requestBlockingReason;
CSPInfo? cspToInheritInfo;
};
@ -191,7 +191,7 @@ struct ParentLoadInfoForwarderArgs
bool documentHasLoaded;
bool allowListFutureDocumentsCreatedFromThisRedirectChain;
CookieSettingsArgs? cookieSettings;
CookieJarSettingsArgs? cookieJarSettings;
uint32_t requestBlockingReason;

View File

@ -120,7 +120,7 @@
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ServiceWorkerUtils.h"
#include "mozilla/net/AsyncUrlChannelClassifier.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/net/NeckoChannelParams.h"
#include "mozilla/net/UrlClassifierFeatureFactory.h"
#include "HttpTrafficAnalyzer.h"
@ -10489,14 +10489,14 @@ nsresult nsHttpChannel::RedirectToInterceptedChannel() {
}
void nsHttpChannel::ReEvaluateReferrerAfterTrackingStatusIsKnown() {
nsCOMPtr<nsICookieSettings> cs;
nsCOMPtr<nsICookieJarSettings> cjs;
if (mLoadInfo) {
Unused << mLoadInfo->GetCookieSettings(getter_AddRefs(cs));
Unused << mLoadInfo->GetCookieJarSettings(getter_AddRefs(cjs));
}
if (!cs) {
cs = net::CookieSettings::Create();
if (!cjs) {
cjs = net::CookieJarSettings::Create();
}
if (cs->GetRejectThirdPartyTrackers()) {
if (cjs->GetRejectThirdPartyTrackers()) {
bool isPrivate =
mLoadInfo && mLoadInfo->GetOriginAttributes().mPrivateBrowsingId > 0;
// If our referrer has been set before, and our referrer policy is unset

View File

@ -200,19 +200,17 @@ BaseWebSocketChannel::SetPingTimeout(uint32_t aSeconds) {
}
NS_IMETHODIMP
BaseWebSocketChannel::InitLoadInfoNative(nsINode* aLoadingNode,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aTriggeringPrincipal,
nsICookieSettings* aCookieSettings,
uint32_t aSecurityFlags,
uint32_t aContentPolicyType,
uint32_t aSandboxFlags) {
BaseWebSocketChannel::InitLoadInfoNative(
nsINode* aLoadingNode, nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aTriggeringPrincipal,
nsICookieJarSettings* aCookieJarSettings, uint32_t aSecurityFlags,
uint32_t aContentPolicyType, uint32_t aSandboxFlags) {
mLoadInfo = new LoadInfo(
aLoadingPrincipal, aTriggeringPrincipal, aLoadingNode, aSecurityFlags,
aContentPolicyType, Maybe<mozilla::dom::ClientInfo>(),
Maybe<mozilla::dom::ServiceWorkerDescriptor>(), aSandboxFlags);
if (aCookieSettings) {
mLoadInfo->SetCookieSettings(aCookieSettings);
if (aCookieJarSettings) {
mLoadInfo->SetCookieJarSettings(aCookieJarSettings);
}
return NS_OK;
}

View File

@ -56,7 +56,7 @@ class BaseWebSocketChannel : public nsIWebSocketChannel,
NS_IMETHOD InitLoadInfoNative(nsINode* aLoadingNode,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aTriggeringPrincipal,
nsICookieSettings* aCookieSettings,
nsICookieJarSettings* aCookieJarSettings,
uint32_t aSecurityFlags,
uint32_t aContentPolicyType,
uint32_t aSandboxFlags) override;

View File

@ -4,7 +4,7 @@
* 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/. */
interface nsICookieSettings;
interface nsICookieJarSettings;
interface nsIURI;
interface nsIInterfaceRequestor;
interface nsILoadGroup;
@ -83,7 +83,7 @@ interface nsIWebSocketChannel : nsISupports
* @param aLoadingNode
* @param aLoadingPrincipal
* @param aTriggeringPrincipal
* @param aCookieSettings
* @param aCookieJarSettings
* @param aSecurityFlags
* @param aContentPolicyType
* These will be used as values for the nsILoadInfo object on the
@ -100,14 +100,14 @@ interface nsIWebSocketChannel : nsISupports
[notxpcom] nsresult initLoadInfoNative(in Node aLoadingNode,
in nsIPrincipal aLoadingPrincipal,
in nsIPrincipal aTriggeringPrincipal,
in nsICookieSettings aCookieSettings,
in nsICookieJarSettings aCookieJarSettings,
in unsigned long aSecurityFlags,
in unsigned long aContentPolicyType,
in unsigned long aSandboxFlags);
/**
* Similar to the previous one but without nsICookieSettings.
* This method is used by JS code where nsICookieSettings is not exposed.
* Similar to the previous one but without nsICookieJarSettings.
* This method is used by JS code where nsICookieJarSettings is not exposed.
*/
[must_use] void initLoadInfo(in Node aLoadingNode,
in nsIPrincipal aLoadingPrincipal,

View File

@ -18,7 +18,7 @@
#include "nsNetCID.h"
#include "nsIPrefBranch.h"
#include "mozilla/Unused.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "nsIURI.h"
using mozilla::Unused;
@ -99,12 +99,13 @@ void SetASameSiteCookie(nsICookieService* aCookieService, const char* aSpec1,
nsILoadInfo::SEC_ONLY_FOR_EXPLICIT_CONTENTSEC_CHECK,
nsIContentPolicy::TYPE_OTHER);
nsCOMPtr<nsICookieSettings> cookieSettings =
aAllowed ? CookieSettings::Create() : CookieSettings::CreateBlockingAll();
MOZ_ASSERT(cookieSettings);
nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
aAllowed ? CookieJarSettings::Create()
: CookieJarSettings::CreateBlockingAll();
MOZ_ASSERT(cookieJarSettings);
nsCOMPtr<nsILoadInfo> loadInfo = dummyChannel->LoadInfo();
loadInfo->SetCookieSettings(cookieSettings);
loadInfo->SetCookieJarSettings(cookieJarSettings);
nsresult rv = aCookieService->SetCookieStringFromHttp(
uri1, uri2, nullptr, nsDependentCString(aCookieString),
@ -982,7 +983,7 @@ TEST(TestCookie, TestCookieMain)
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->RemoveAll()));
// None of these cookies will be set because using
// CookieSettings::CreateBlockingAll().
// CookieJarSettings::CreateBlockingAll().
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"unset=yes", nullptr, false);
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,

View File

@ -74,7 +74,7 @@ static int FuzzingRunNetworkFtp(const uint8_t* data, size_t size) {
rv = NS_NewChannel(getter_AddRefs(channel), url,
nsContentUtils::GetSystemPrincipal(), secFlags,
nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
nullptr, // aCookieSettings
nullptr, // aCookieJarSettings
nullptr, // aPerformanceStorage
nullptr, // loadGroup
nullptr, // aCallbacks

View File

@ -167,7 +167,7 @@ static int FuzzingRunNetworkHttp(const uint8_t* data, size_t size) {
rv = NS_NewChannel(getter_AddRefs(channel), url,
nsContentUtils::GetSystemPrincipal(), secFlags,
nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
nullptr, // aCookieSettings
nullptr, // aCookieJarSettings
nullptr, // aPerformanceStorage
nullptr, // loadGroup
nullptr, // aCallbacks

View File

@ -85,7 +85,7 @@ add_test(function test_sockets() {
function run_test() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);

View File

@ -71,7 +71,7 @@ function run_test() {
if (!inChildProcess()) {
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
}

View File

@ -54,7 +54,7 @@ function run_test() {
.setIntPref("network.cookie.cookieBehavior", 1);
Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefBranch)
.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
.setBoolPref("network.cookieJarSettings.unblocked_for_testing", true);
}
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(

View File

@ -15,9 +15,9 @@ function checkValueAndTrigger(request, data, ctx) {
}
function run_test() {
// We don't want to have CookieSettings blocking this test.
// We don't want to have CookieJarSettings blocking this test.
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);

View File

@ -74,7 +74,7 @@ function run_test() {
if (!inChildProcess()) {
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
}

View File

@ -138,7 +138,7 @@ function run_test() {
if (!inChildProcess()) {
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
}

View File

@ -100,7 +100,7 @@ function run_test() {
if (!inChildProcess()) {
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
}

View File

@ -28,9 +28,9 @@ function* do_run_test() {
// Set up a profile.
let profile = do_get_profile();
// We don't want to have CookieSettings blocking this test.
// We don't want to have CookieJarSettings blocking this test.
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);

View File

@ -7,7 +7,7 @@
function run_test() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);

View File

@ -25,9 +25,9 @@ function* do_run_test() {
// Set up a profile.
let profile = do_get_profile();
// We don't want to have CookieSettings blocking this test.
// We don't want to have CookieJarSettings blocking this test.
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);

View File

@ -23,9 +23,9 @@ function* do_run_test() {
// Set up a profile.
let profile = do_get_profile();
// We don't want to have CookieSettings blocking this test.
// We don't want to have CookieJarSettings blocking this test.
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);

View File

@ -1367,7 +1367,7 @@ function resetPrefs() {
prefs.setBoolPref("network.http.altsvc.enabled", altsvcpref1);
prefs.setBoolPref("network.http.altsvc.oe", altsvcpref2);
prefs.clearUserPref("network.dns.localDomains");
prefs.clearUserPref("network.cookieSettings.unblocked_for_testing");
prefs.clearUserPref("network.cookieJarSettings.unblocked_for_testing");
}
function run_test() {
@ -1411,7 +1411,7 @@ function run_test() {
"network.dns.localDomains",
"foo.example.com, bar.example.com"
);
prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
prefs.setBoolPref("network.cookieJarSettings.unblocked_for_testing", true);
loadGroup = Cc["@mozilla.org/network/load-group;1"].createInstance(
Ci.nsILoadGroup

View File

@ -13,9 +13,9 @@ function makeChan(uri, isPrivate) {
}
function run_test() {
// We don't want to have CookieSettings blocking this test.
// We don't want to have CookieJarSettings blocking this test.
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);

View File

@ -2,7 +2,7 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
function run_test() {
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
Services.prefs.setIntPref("network.cookie.cookieBehavior", 1);

View File

@ -30,7 +30,7 @@ function run_test() {
Services.prefs.clearUserPref("network.dns.localDomains");
Services.prefs.clearUserPref("network.cookie.cookieBehavior");
Services.prefs.clearUserPref(
"network.cookieSettings.unblocked_for_testing"
"network.cookieJarSettings.unblocked_for_testing"
);
httpserv.stop();
@ -38,7 +38,7 @@ function run_test() {
});
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
Services.prefs.setCharPref("network.dns.localDomains", TEST_DOMAIN);

View File

@ -3,7 +3,7 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
function run_test() {
// Allow all cookies.
Services.prefs.setBoolPref(
"network.cookieSettings.unblocked_for_testing",
"network.cookieJarSettings.unblocked_for_testing",
true
);
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);

View File

@ -158,9 +158,9 @@ void CreatePermissionKey(const nsCString& aTrackingOrigin,
// This internal method returns ACCESS_DENY if the access is denied,
// ACCESS_DEFAULT if unknown, some other access code if granted.
uint32_t CheckCookiePermissionForPrincipal(nsICookieSettings* aCookieSettings,
nsIPrincipal* aPrincipal) {
MOZ_ASSERT(aCookieSettings);
uint32_t CheckCookiePermissionForPrincipal(
nsICookieJarSettings* aCookieJarSettings, nsIPrincipal* aPrincipal) {
MOZ_ASSERT(aCookieJarSettings);
MOZ_ASSERT(aPrincipal);
uint32_t cookiePermission = nsICookiePermission::ACCESS_DEFAULT;
@ -169,7 +169,7 @@ uint32_t CheckCookiePermissionForPrincipal(nsICookieSettings* aCookieSettings,
}
nsresult rv =
aCookieSettings->CookiePermission(aPrincipal, &cookiePermission);
aCookieJarSettings->CookiePermission(aPrincipal, &cookiePermission);
if (NS_WARN_IF(NS_FAILED(rv))) {
return nsICookiePermission::ACCESS_DEFAULT;
}
@ -187,7 +187,7 @@ int32_t CookiesBehavior(Document* a3rdPartyDocument) {
return nsICookieService::BEHAVIOR_ACCEPT;
}
return a3rdPartyDocument->CookieSettings()->GetCookieBehavior();
return a3rdPartyDocument->CookieJarSettings()->GetCookieBehavior();
}
int32_t CookiesBehavior(nsILoadInfo* aLoadInfo, nsIURI* a3rdPartyURI) {
@ -200,19 +200,20 @@ int32_t CookiesBehavior(nsILoadInfo* aLoadInfo, nsIURI* a3rdPartyURI) {
return nsICookieService::BEHAVIOR_ACCEPT;
}
nsCOMPtr<nsICookieSettings> cookieSettings;
nsresult rv = aLoadInfo->GetCookieSettings(getter_AddRefs(cookieSettings));
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
nsresult rv =
aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
if (NS_WARN_IF(NS_FAILED(rv))) {
return nsICookieService::BEHAVIOR_REJECT;
}
return cookieSettings->GetCookieBehavior();
return cookieJarSettings->GetCookieBehavior();
}
int32_t CookiesBehavior(nsIPrincipal* aPrincipal,
nsICookieSettings* aCookieSettings) {
nsICookieJarSettings* aCookieJarSettings) {
MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(aCookieSettings);
MOZ_ASSERT(aCookieJarSettings);
// WebExtensions principals always get BEHAVIOR_ACCEPT as cookieBehavior
// (See Bug 1406675 for rationale).
@ -220,7 +221,7 @@ int32_t CookiesBehavior(nsIPrincipal* aPrincipal,
return nsICookieService::BEHAVIOR_ACCEPT;
}
return aCookieSettings->GetCookieBehavior();
return aCookieJarSettings->GetCookieBehavior();
}
struct ContentBlockingAllowListKey {
@ -1096,9 +1097,9 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(
LOG(("Parent window has no doc"));
return StorageAccessGrantPromise::CreateAndReject(false, __func__);
}
int32_t behavior = parentDoc->CookieSettings()->GetCookieBehavior();
int32_t behavior = parentDoc->CookieJarSettings()->GetCookieBehavior();
if (!parentDoc->CookieSettings()->GetRejectThirdPartyTrackers()) {
if (!parentDoc->CookieJarSettings()->GetRejectThirdPartyTrackers()) {
LOG(
("Disabled by network.cookie.cookieBehavior pref (%d), bailing out "
"early",
@ -1473,7 +1474,7 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
// For out-of-process top frames, we need to be able to access three things
// from the top BrowsingContext in order to be able to port this code to
// Fission successfully:
// * The CookieSettings of the top BrowsingContext.
// * The CookieJarSettings of the top BrowsingContext.
// * The HasStorageAccessGranted() API on BrowsingContext.
// For now, if we face an out-of-process top frame, instead of failing here,
// we revert back to looking at the in-process top frame. This is of course
@ -1504,7 +1505,7 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
}
uint32_t cookiePermission = CheckCookiePermissionForPrincipal(
document->CookieSettings(), document->NodePrincipal());
document->CookieJarSettings(), document->NodePrincipal());
if (cookiePermission != nsICookiePermission::ACCESS_DEFAULT) {
LOG(
("CheckCookiePermissionForPrincipal() returned a non-default access "
@ -1728,11 +1729,11 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
return false;
}
nsCOMPtr<nsICookieSettings> cookieSettings;
rv = loadInfo->GetCookieSettings(getter_AddRefs(cookieSettings));
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
rv = loadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
if (NS_WARN_IF(NS_FAILED(rv))) {
LOG(
("Failed to get the cookie settings from the loadinfo, bail out "
("Failed to get the cookie jar settings from the loadinfo, bail out "
"early"));
return true;
}
@ -1745,7 +1746,7 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
}
uint32_t cookiePermission =
CheckCookiePermissionForPrincipal(cookieSettings, channelPrincipal);
CheckCookiePermissionForPrincipal(cookieJarSettings, channelPrincipal);
if (cookiePermission != nsICookiePermission::ACCESS_DEFAULT) {
LOG(
("CheckCookiePermissionForPrincipal() returned a non-default access "
@ -1912,9 +1913,9 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
}
bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
nsIPrincipal* aPrincipal, nsICookieSettings* aCookieSettings) {
nsIPrincipal* aPrincipal, nsICookieJarSettings* aCookieJarSettings) {
MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(aCookieSettings);
MOZ_ASSERT(aCookieJarSettings);
uint32_t access = nsICookiePermission::ACCESS_DEFAULT;
if (aPrincipal->GetIsContentPrincipal()) {
@ -1929,7 +1930,7 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
return access != nsICookiePermission::ACCESS_DENY;
}
int32_t behavior = CookiesBehavior(aPrincipal, aCookieSettings);
int32_t behavior = CookiesBehavior(aPrincipal, aCookieJarSettings);
return behavior != nsICookieService::BEHAVIOR_REJECT;
}
@ -1951,9 +1952,9 @@ bool AntiTrackingCommon::MaybeIsFirstPartyStorageAccessGrantedFor(
return false;
}
if (!parentDocument->CookieSettings()->GetRejectThirdPartyTrackers()) {
if (!parentDocument->CookieJarSettings()->GetRejectThirdPartyTrackers()) {
LOG(("Disabled by the pref (%d), bail out early",
parentDocument->CookieSettings()->GetCookieBehavior()));
parentDocument->CookieJarSettings()->GetCookieBehavior()));
return true;
}
@ -1968,7 +1969,7 @@ bool AntiTrackingCommon::MaybeIsFirstPartyStorageAccessGrantedFor(
}
uint32_t cookiePermission = CheckCookiePermissionForPrincipal(
parentDocument->CookieSettings(), parentDocument->NodePrincipal());
parentDocument->CookieJarSettings(), parentDocument->NodePrincipal());
if (cookiePermission != nsICookiePermission::ACCESS_DEFAULT) {
LOG(
("CheckCookiePermissionForPrincipal() returned a non-default access "
@ -2540,16 +2541,16 @@ void AntiTrackingCommon::RedirectHeuristic(nsIChannel* aOldChannel,
LOG(("Adding a first-party storage exception for %s...",
PromiseFlatCString(redirectedOrigin).get()));
nsCOMPtr<nsICookieSettings> cookieSettings;
rv = oldLoadInfo->GetCookieSettings(getter_AddRefs(cookieSettings));
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
rv = oldLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
if (NS_WARN_IF(NS_FAILED(rv))) {
LOG(("Can't get the cookieSettings"));
LOG(("Can't get the cookieJarSettings"));
return;
}
int32_t behavior = cookieSettings->GetCookieBehavior();
int32_t behavior = cookieJarSettings->GetCookieBehavior();
if (!cookieSettings->GetRejectThirdPartyTrackers()) {
if (!cookieJarSettings->GetRejectThirdPartyTrackers()) {
LOG(
("Disabled by network.cookie.cookieBehavior pref (%d), bailing out "
"early",

View File

@ -15,7 +15,7 @@
#define USER_INTERACTION_PERM NS_LITERAL_CSTRING("storageAccessAPI")
class nsIChannel;
class nsICookieSettings;
class nsICookieJarSettings;
class nsIPermission;
class nsIPrincipal;
class nsIURI;
@ -71,7 +71,7 @@ class AntiTrackingCommon final {
// This method checks if the principal has the permission to access to the
// first party storage.
static bool IsFirstPartyStorageAccessGrantedFor(
nsIPrincipal* aPrincipal, nsICookieSettings* aCookieSettings);
nsIPrincipal* aPrincipal, nsICookieJarSettings* aCookieJarSettings);
enum StorageAccessGrantedReason {
eStorageAccessAPI,

View File

@ -5,31 +5,31 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/Document.h"
#include "mozilla/net/CookieSettings.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/AntiTrackingCommon.h"
#include "mozilla/StaticPrefs_browser.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/StaticPrefs_privacy.h"
#include "mozilla/StorageAccess.h"
#include "nsICookieService.h"
#include "nsICookieSettings.h"
#include "nsICookieJarSettings.h"
#include "nsIWebProgressListener.h"
/**
* Gets the cookie lifetime policy for a given cookieSettings and a given
* Gets the cookie lifetime policy for a given cookieJarSettings and a given
* principal by checking the permission value.
*
* Used in the implementation of InternalStorageAllowedCheck.
*/
static void GetCookieLifetimePolicyFromCookieSettings(
nsICookieSettings* aCookieSettings, nsIPrincipal* aPrincipal,
static void GetCookieLifetimePolicyFromCookieJarSettings(
nsICookieJarSettings* aCookieJarSettings, nsIPrincipal* aPrincipal,
uint32_t* aLifetimePolicy) {
*aLifetimePolicy = StaticPrefs::network_cookie_lifetimePolicy();
if (aCookieSettings) {
if (aCookieJarSettings) {
uint32_t cookiePermission = 0;
nsresult rv =
aCookieSettings->CookiePermission(aPrincipal, &cookiePermission);
aCookieJarSettings->CookiePermission(aPrincipal, &cookiePermission);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
@ -62,7 +62,7 @@ static void GetCookieLifetimePolicyFromCookieSettings(
*/
static StorageAccess InternalStorageAllowedCheck(
nsIPrincipal* aPrincipal, nsPIDOMWindowInner* aWindow, nsIURI* aURI,
nsIChannel* aChannel, nsICookieSettings* aCookieSettings,
nsIChannel* aChannel, nsICookieJarSettings* aCookieJarSettings,
uint32_t& aRejectedReason) {
MOZ_ASSERT(aPrincipal);
@ -98,8 +98,8 @@ static StorageAccess InternalStorageAllowedCheck(
if (policy) {
lifetimePolicy = nsICookieService::ACCEPT_NORMALLY;
} else {
GetCookieLifetimePolicyFromCookieSettings(aCookieSettings, aPrincipal,
&lifetimePolicy);
GetCookieLifetimePolicyFromCookieJarSettings(aCookieJarSettings, aPrincipal,
&lifetimePolicy);
}
// Check if we should only allow storage for the session, and record that fact
@ -162,7 +162,7 @@ static StorageAccess InternalStorageAllowedCheck(
static bool StorageDisabledByAntiTrackingInternal(
nsPIDOMWindowInner* aWindow, nsIChannel* aChannel, nsIPrincipal* aPrincipal,
nsIURI* aURI, nsICookieSettings* aCookieSettings,
nsIURI* aURI, nsICookieJarSettings* aCookieJarSettings,
uint32_t& aRejectedReason) {
MOZ_ASSERT(aWindow || aChannel || aPrincipal);
@ -186,7 +186,7 @@ static bool StorageDisabledByAntiTrackingInternal(
MOZ_ASSERT(aPrincipal);
return !AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
aPrincipal, aCookieSettings);
aPrincipal, aCookieJarSettings);
}
namespace mozilla {
@ -207,7 +207,7 @@ StorageAccess StorageAllowedForWindow(nsPIDOMWindowInner* aWindow,
// will only fail to notify the UI in case storage gets blocked.
nsIChannel* channel = document->GetChannel();
return InternalStorageAllowedCheck(principal, aWindow, nullptr, channel,
document->CookieSettings(),
document->CookieJarSettings(),
*aRejectedReason);
}
@ -228,7 +228,7 @@ StorageAccess StorageAllowedForDocument(const Document* aDoc) {
uint32_t rejectedReason = 0;
return InternalStorageAllowedCheck(
principal, inner, nullptr, channel,
const_cast<Document*>(aDoc)->CookieSettings(), rejectedReason);
const_cast<Document*>(aDoc)->CookieJarSettings(), rejectedReason);
}
return StorageAccess::eDeny;
@ -241,13 +241,13 @@ StorageAccess StorageAllowedForNewWindow(nsIPrincipal* aPrincipal, nsIURI* aURI,
// parent may be nullptr
uint32_t rejectedReason = 0;
nsCOMPtr<nsICookieSettings> cs;
nsCOMPtr<nsICookieJarSettings> cjs;
if (aParent && aParent->GetExtantDoc()) {
cs = aParent->GetExtantDoc()->CookieSettings();
cjs = aParent->GetExtantDoc()->CookieJarSettings();
} else {
cs = net::CookieSettings::Create();
cjs = net::CookieJarSettings::Create();
}
return InternalStorageAllowedCheck(aPrincipal, aParent, aURI, nullptr, cs,
return InternalStorageAllowedCheck(aPrincipal, aParent, aURI, nullptr, cjs,
rejectedReason);
}
@ -261,22 +261,23 @@ StorageAccess StorageAllowedForChannel(nsIChannel* aChannel) {
NS_ENSURE_TRUE(principal, StorageAccess::eDeny);
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
nsCOMPtr<nsICookieSettings> cookieSettings;
nsresult rv = loadInfo->GetCookieSettings(getter_AddRefs(cookieSettings));
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
nsresult rv =
loadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
NS_ENSURE_SUCCESS(rv, StorageAccess::eDeny);
uint32_t rejectedReason = 0;
StorageAccess result = InternalStorageAllowedCheck(
principal, nullptr, nullptr, aChannel, cookieSettings, rejectedReason);
principal, nullptr, nullptr, aChannel, cookieJarSettings, rejectedReason);
return result;
}
StorageAccess StorageAllowedForServiceWorker(
nsIPrincipal* aPrincipal, nsICookieSettings* aCookieSettings) {
nsIPrincipal* aPrincipal, nsICookieJarSettings* aCookieJarSettings) {
uint32_t rejectedReason = 0;
return InternalStorageAllowedCheck(aPrincipal, nullptr, nullptr, nullptr,
aCookieSettings, rejectedReason);
aCookieJarSettings, rejectedReason);
}
bool StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
@ -284,20 +285,20 @@ bool StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
nsIPrincipal* aPrincipal, nsIURI* aURI,
uint32_t& aRejectedReason) {
MOZ_ASSERT(aWindow || aChannel || aPrincipal);
nsCOMPtr<nsICookieSettings> cookieSettings;
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
if (aWindow) {
if (aWindow->GetExtantDoc()) {
cookieSettings = aWindow->GetExtantDoc()->CookieSettings();
cookieJarSettings = aWindow->GetExtantDoc()->CookieJarSettings();
}
} else if (aChannel) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
Unused << loadInfo->GetCookieSettings(getter_AddRefs(cookieSettings));
Unused << loadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
}
if (!cookieSettings) {
cookieSettings = net::CookieSettings::Create();
if (!cookieJarSettings) {
cookieJarSettings = net::CookieJarSettings::Create();
}
bool disabled = StorageDisabledByAntiTrackingInternal(
aWindow, aChannel, aPrincipal, aURI, cookieSettings, aRejectedReason);
aWindow, aChannel, aPrincipal, aURI, cookieJarSettings, aRejectedReason);
if (aWindow) {
AntiTrackingCommon::NotifyBlockingDecision(
aWindow,
@ -329,32 +330,32 @@ bool ShouldPartitionStorage(uint32_t aRejectedReason) {
}
bool StoragePartitioningEnabled(StorageAccess aAccess,
nsICookieSettings* aCookieSettings) {
nsICookieJarSettings* aCookieJarSettings) {
if (aAccess == StorageAccess::ePartitionTrackersOrDeny) {
return aCookieSettings->GetCookieBehavior() ==
return aCookieJarSettings->GetCookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT_TRACKER &&
StaticPrefs::privacy_storagePrincipal_enabledForTrackers();
}
if (aAccess == StorageAccess::ePartitionForeignOrDeny) {
return aCookieSettings->GetCookieBehavior() ==
return aCookieJarSettings->GetCookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN;
}
return false;
}
bool StoragePartitioningEnabled(uint32_t aRejectedReason,
nsICookieSettings* aCookieSettings) {
nsICookieJarSettings* aCookieJarSettings) {
if (aRejectedReason ==
nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
aRejectedReason ==
nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER) {
return aCookieSettings->GetCookieBehavior() ==
return aCookieJarSettings->GetCookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT_TRACKER &&
StaticPrefs::privacy_storagePrincipal_enabledForTrackers();
}
if (aRejectedReason ==
nsIWebProgressListener::STATE_COOKIES_PARTITIONED_FOREIGN) {
return aCookieSettings->GetCookieBehavior() ==
return aCookieJarSettings->GetCookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN;
}
return false;

View File

@ -10,7 +10,7 @@
#include "mozilla/dom/Document.h"
class nsIChannel;
class nsICookieSettings;
class nsICookieJarSettings;
class nsIPrincipal;
class nsIURI;
class nsPIDOMWindowInner;
@ -81,7 +81,7 @@ StorageAccess StorageAllowedForChannel(nsIChannel* aChannel);
* preferences. This method should be used only by ServiceWorker loading.
*/
StorageAccess StorageAllowedForServiceWorker(
nsIPrincipal* aPrincipal, nsICookieSettings* aCookieSettings);
nsIPrincipal* aPrincipal, nsICookieJarSettings* aCookieJarSettings);
/*
* Returns true if this window/channel/aPrincipal should disable storages
@ -115,10 +115,10 @@ bool ShouldPartitionStorage(StorageAccess aAccess);
bool ShouldPartitionStorage(uint32_t aRejectedReason);
bool StoragePartitioningEnabled(StorageAccess aAccess,
nsICookieSettings* aCookieSettings);
nsICookieJarSettings* aCookieJarSettings);
bool StoragePartitioningEnabled(uint32_t aRejectedReason,
nsICookieSettings* aCookieSettings);
nsICookieJarSettings* aCookieJarSettings);
} // namespace mozilla

View File

@ -20,8 +20,8 @@ bool ChooseOriginAttributes(nsIChannel* aChannel, OriginAttributes& aAttrs) {
MOZ_ASSERT(aChannel);
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
nsCOMPtr<nsICookieSettings> cs;
if (NS_FAILED(loadInfo->GetCookieSettings(getter_AddRefs(cs)))) {
nsCOMPtr<nsICookieJarSettings> cjs;
if (NS_FAILED(loadInfo->GetCookieJarSettings(getter_AddRefs(cjs)))) {
return false;
}
@ -41,7 +41,7 @@ bool ChooseOriginAttributes(nsIChannel* aChannel, OriginAttributes& aAttrs) {
// jar. We use the lower-level AntiTrackingCommon API here to ensure this
// check doesn't send notifications.
if (!ShouldPartitionStorage(rejectedReason) ||
!StoragePartitioningEnabled(rejectedReason, cs)) {
!StoragePartitioningEnabled(rejectedReason, cjs)) {
return false;
}

View File

@ -1981,7 +1981,7 @@ nsUrlClassifierDBService::SendThreatHitReport(nsIChannel* aChannel,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // nsICookieSettings
nullptr, // nsICookieJarSettings
nullptr, // aPerformanceStorage
nullptr, // aLoadGroup
nullptr, loadFlags);

View File

@ -136,7 +136,7 @@ nsresult nsUrlClassifierStreamUpdater::FetchUpdate(
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // nsICookieSettings
nullptr, // nsICookieJarSettings
nullptr, // aPerformanceStorage
nullptr, // aLoadGroup
this, // aInterfaceRequestor

Some files were not shown because too many files have changed in this diff Show More