Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 0a9f78a

Browse files
committed
Bug 1689600 - Making the Drag&Drop downloading be aware of cookieJarSettings on Windows platform. r=smaug, a=pascalc
The channel used on Windows for Drag&Drop downloading doesn't have the correct cookieJarSettings. The patch fixes this issue that it will pass the correct cookieJarSettings to the channel. Differential Revision: https://phabricator.services.mozilla.com/D103678
1 parent 2486e89 commit 0a9f78a

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

widget/windows/nsDataObj.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "nsArrayUtils.h"
1414
#include "nsClipboard.h"
1515
#include "nsReadableUtils.h"
16+
#include "nsICookieJarSettings.h"
1617
#include "nsITransferable.h"
1718
#include "nsISupportsPrimitives.h"
1819
#include "IEnumFE.h"
@@ -70,16 +71,16 @@ nsDataObj::CStream::~CStream() {}
7071
// helper - initializes the stream
7172
nsresult nsDataObj::CStream::Init(nsIURI* pSourceURI,
7273
nsContentPolicyType aContentPolicyType,
73-
nsIPrincipal* aRequestingPrincipal) {
74+
nsIPrincipal* aRequestingPrincipal,
75+
nsICookieJarSettings* aCookieJarSettings) {
7476
// we can not create a channel without a requestingPrincipal
7577
if (!aRequestingPrincipal) {
7678
return NS_ERROR_FAILURE;
7779
}
7880
nsresult rv;
7981
rv = NS_NewChannel(getter_AddRefs(mChannel), pSourceURI, aRequestingPrincipal,
8082
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_INHERITS_SEC_CONTEXT,
81-
aContentPolicyType,
82-
nullptr, // nsICookieJarSettings
83+
aContentPolicyType, aCookieJarSettings,
8384
nullptr, // PerformanceStorage
8485
nullptr, // loadGroup
8586
nullptr, // aCallbacks
@@ -313,8 +314,14 @@ HRESULT nsDataObj::CreateStream(IStream** outStream) {
313314
mTransferable->GetRequestingPrincipal();
314315
MOZ_ASSERT(requestingPrincipal, "can not create channel without a principal");
315316

317+
// Note that the cookieJarSettings could be null if the data object is for the
318+
// image copy. We will fix this in Bug 1690532.
319+
nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
320+
mTransferable->GetCookieJarSettings();
321+
316322
nsContentPolicyType contentPolicyType = mTransferable->GetContentPolicyType();
317-
rv = pStream->Init(sourceURI, contentPolicyType, requestingPrincipal);
323+
rv = pStream->Init(sourceURI, contentPolicyType, requestingPrincipal,
324+
cookieJarSettings);
318325
if (NS_FAILED(rv)) {
319326
pStream->Release();
320327
return E_FAIL;

widget/windows/nsDataObj.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "nsCOMArray.h"
2020
#include "nsITimer.h"
2121

22+
class nsICookieJarSettings;
2223
class nsIThread;
2324
class nsIPrincipal;
2425
class CEnumFormatEtc;
@@ -222,7 +223,8 @@ class nsDataObj : public IDataObject, public IDataObjectAsyncCapability {
222223
public:
223224
CStream();
224225
nsresult Init(nsIURI* pSourceURI, nsContentPolicyType aContentPolicyType,
225-
nsIPrincipal* aRequestingPrincipal);
226+
nsIPrincipal* aRequestingPrincipal,
227+
nsICookieJarSettings* aCookieJarSettings);
226228

227229
NS_DECL_ISUPPORTS
228230
NS_DECL_NSIREQUESTOBSERVER

0 commit comments

Comments
 (0)