Bug 1641270 - Part 2: Make WebBrowserPersistDocument aware of CookieJarSettings. r=smaug

In this patch, we add cookieJarSettings in WebBrowserPersistDocument.
This is needed if we want to use the correct cookieJarSettings when
download the page or URI.

Differential Revision: https://phabricator.services.mozilla.com/D95612
This commit is contained in:
Tim Huang 2020-11-10 20:36:22 +00:00
Родитель 5a9cd22328
Коммит cc4149ee76
6 изменённых файлов: 31 добавлений и 0 удалений

Просмотреть файл

@ -12,6 +12,7 @@ include protocol PParentToChildStream; //FIXME: bug #792908
include PBackgroundSharedTypes;
include IPCStream;
include NeckoChannelParams;
using refcounted class nsIReferrerInfo from "mozilla/dom/ReferrerInfoUtils.h";
@ -29,6 +30,7 @@ struct WebBrowserPersistDocumentAttrs {
nsCString characterSet;
nsString title;
nsIReferrerInfo referrerInfo;
CookieJarSettingsArgs cookieJarSettings;
nsString contentDisposition;
uint32_t sessionHistoryCacheKey;
uint32_t persistFlags;

Просмотреть файл

@ -14,6 +14,7 @@
#include "WebBrowserPersistResourcesChild.h"
#include "WebBrowserPersistSerializeChild.h"
#include "mozilla/StaticPrefs_fission.h"
#include "mozilla/net/CookieJarSettings.h"
namespace mozilla {
@ -39,6 +40,7 @@ void WebBrowserPersistDocumentChild::Start(
nsCOMPtr<nsIPrincipal> principal;
nsCOMPtr<nsIReferrerInfo> referrerInfo;
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
WebBrowserPersistDocumentAttrs attrs;
nsCOMPtr<nsIInputStream> postDataStream;
#define ENSURE(e) \
@ -67,6 +69,10 @@ void WebBrowserPersistDocumentChild::Start(
ENSURE(aDocument->GetReferrerInfo(getter_AddRefs(referrerInfo)));
attrs.referrerInfo() = referrerInfo;
ENSURE(aDocument->GetCookieJarSettings(getter_AddRefs(cookieJarSettings)));
net::CookieJarSettings::Cast(cookieJarSettings)
->Serialize(attrs.cookieJarSettings());
ENSURE(aDocument->GetPostData(getter_AddRefs(postDataStream)));
#undef ENSURE

Просмотреть файл

@ -140,6 +140,14 @@ WebBrowserPersistLocalDocument::GetReferrerInfo(
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistLocalDocument::GetCookieJarSettings(
nsICookieJarSettings** aCookieJarSettings) {
*aCookieJarSettings = mDocument->CookieJarSettings();
NS_ADDREF(*aCookieJarSettings);
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistLocalDocument::GetContentDisposition(nsAString& aCD) {
nsCOMPtr<nsPIDOMWindowOuter> window = mDocument->GetWindow();

Просмотреть файл

@ -10,6 +10,7 @@
#include "WebBrowserPersistSerializeParent.h"
#include "mozilla/Unused.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/net/CookieJarSettings.h"
#include "nsDebug.h"
#include "nsIPrincipal.h"
@ -29,6 +30,9 @@ WebBrowserPersistRemoteDocument ::WebBrowserPersistRemoteDocument(
} else {
NS_WARNING("Failed to obtain principal!");
}
net::CookieJarSettings::Deserialize(mAttrs.cookieJarSettings(),
getter_AddRefs(mCookieJarSettings));
}
WebBrowserPersistRemoteDocument::~WebBrowserPersistRemoteDocument() {
@ -92,6 +96,14 @@ WebBrowserPersistRemoteDocument::GetReferrerInfo(
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetCookieJarSettings(
nsICookieJarSettings** aCookieJarSettings) {
nsCOMPtr<nsICookieJarSettings> cookieJarSettings = mCookieJarSettings;
cookieJarSettings.forget(aCookieJarSettings);
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetContentDisposition(nsAString& aDisp) {
aDisp = mAttrs.contentDisposition();

Просмотреть файл

@ -41,6 +41,7 @@ class WebBrowserPersistRemoteDocument final
WebBrowserPersistDocumentParent* mActor;
Attrs mAttrs;
nsCOMPtr<nsISHEntry> mSHEntry;
nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;
nsCOMPtr<nsIInputStream> mPostData;
nsCOMPtr<nsIPrincipal> mPrincipal;

Просмотреть файл

@ -15,6 +15,7 @@ interface nsIWebBrowserPersistResourceVisitor;
interface nsIWebBrowserPersistWriteCompletion;
interface nsIReferrerInfo;
interface nsISHEntry;
interface nsICookieJarSettings;
webidl BrowsingContext;
@ -67,6 +68,7 @@ interface nsIWebBrowserPersistDocument : nsISupports
readonly attribute ACString characterSet;
readonly attribute AString title;
readonly attribute nsIReferrerInfo referrerInfo;
readonly attribute nsICookieJarSettings cookieJarSettings;
readonly attribute AString contentDisposition;
readonly attribute nsIInputStream postData;
readonly attribute nsIPrincipal principal;