зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1575934 - Create the channels used to download and verify appcache entries with the cookie settings belonging to the document which created the appcache; r=baku
Differential Revision: https://phabricator.services.mozilla.com/D49018 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1aaa268725
Коммит
2eaec14333
|
@ -4537,7 +4537,8 @@ void ContentParent::NotifyRebuildFontList() {
|
|||
already_AddRefed<mozilla::docshell::POfflineCacheUpdateParent>
|
||||
ContentParent::AllocPOfflineCacheUpdateParent(
|
||||
const URIParams& aManifestURI, const URIParams& aDocumentURI,
|
||||
const PrincipalInfo& aLoadingPrincipalInfo, const bool& aStickDocument) {
|
||||
const PrincipalInfo& aLoadingPrincipalInfo, const bool& aStickDocument,
|
||||
const CookieSettingsArgs& aCookieSettingsArgs) {
|
||||
RefPtr<mozilla::docshell::OfflineCacheUpdateParent> update =
|
||||
new mozilla::docshell::OfflineCacheUpdateParent();
|
||||
return update.forget();
|
||||
|
@ -4546,14 +4547,14 @@ ContentParent::AllocPOfflineCacheUpdateParent(
|
|||
mozilla::ipc::IPCResult ContentParent::RecvPOfflineCacheUpdateConstructor(
|
||||
POfflineCacheUpdateParent* aActor, const URIParams& aManifestURI,
|
||||
const URIParams& aDocumentURI, const PrincipalInfo& aLoadingPrincipal,
|
||||
const bool& aStickDocument) {
|
||||
const bool& aStickDocument, const CookieSettingsArgs& aCookieSettingsArgs) {
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
RefPtr<mozilla::docshell::OfflineCacheUpdateParent> update =
|
||||
static_cast<mozilla::docshell::OfflineCacheUpdateParent*>(aActor);
|
||||
|
||||
nsresult rv = update->Schedule(aManifestURI, aDocumentURI, aLoadingPrincipal,
|
||||
aStickDocument);
|
||||
aStickDocument, aCookieSettingsArgs);
|
||||
if (NS_FAILED(rv) && IsAlive()) {
|
||||
// Inform the child of failure.
|
||||
Unused << update->SendFinish(false, false);
|
||||
|
|
|
@ -483,12 +483,14 @@ class ContentParent final : public PContentParent,
|
|||
|
||||
already_AddRefed<POfflineCacheUpdateParent> AllocPOfflineCacheUpdateParent(
|
||||
const URIParams& aManifestURI, const URIParams& aDocumentURI,
|
||||
const PrincipalInfo& aLoadingPrincipalInfo, const bool& aStickDocument);
|
||||
const PrincipalInfo& aLoadingPrincipalInfo, const bool& aStickDocument,
|
||||
const CookieSettingsArgs& aCookieSettingsArgs);
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvPOfflineCacheUpdateConstructor(
|
||||
POfflineCacheUpdateParent* aActor, const URIParams& aManifestURI,
|
||||
const URIParams& aDocumentURI, const PrincipalInfo& aLoadingPrincipal,
|
||||
const bool& stickDocument) override;
|
||||
const bool& stickDocument,
|
||||
const CookieSettingsArgs& aCookieSettingsArgs) override;
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetOfflinePermission(
|
||||
const IPC::Principal& principal);
|
||||
|
|
|
@ -1082,7 +1082,8 @@ parent:
|
|||
* To identify which tab owns the app.
|
||||
*/
|
||||
async POfflineCacheUpdate(URIParams manifestURI, URIParams documentURI,
|
||||
PrincipalInfo loadingPrincipal, bool stickDocument);
|
||||
PrincipalInfo loadingPrincipal, bool stickDocument,
|
||||
CookieSettingsArgs cookieSettings);
|
||||
|
||||
/**
|
||||
* Sets "offline-app" permission for the principal. Called when we hit
|
||||
|
|
|
@ -374,8 +374,11 @@ void nsDOMOfflineResourceList::MozAdd(const nsAString& aURI, ErrorResult& aRv) {
|
|||
return;
|
||||
}
|
||||
|
||||
RefPtr<Document> doc = GetOwner()->GetExtantDoc();
|
||||
nsCOMPtr<nsICookieSettings> cs = doc ? doc->CookieSettings() : nullptr;
|
||||
|
||||
rv = update->InitPartial(mManifestURI, clientID, mDocumentURI,
|
||||
mLoadingPrincipal);
|
||||
mLoadingPrincipal, cs);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(rv);
|
||||
return;
|
||||
|
|
|
@ -113,6 +113,10 @@ class CookieSettings final : public nsICookieSettings {
|
|||
|
||||
static already_AddRefed<nsICookieSettings> Create();
|
||||
|
||||
static CookieSettings* Cast(nsICookieSettings* aCS) {
|
||||
return static_cast<CookieSettings*>(aCS);
|
||||
}
|
||||
|
||||
void Serialize(CookieSettingsArgs& aData);
|
||||
|
||||
static void Deserialize(const CookieSettingsArgs& aData,
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/net/CookieSettings.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIBrowserChild.h"
|
||||
|
@ -118,6 +119,8 @@ void OfflineCacheUpdateChild::SetDocument(Document* aDocument) {
|
|||
// implicit (which are the reasons we collect documents here).
|
||||
if (!aDocument) return;
|
||||
|
||||
mCookieSettings = aDocument->CookieSettings();
|
||||
|
||||
nsIChannel* channel = aDocument->GetChannel();
|
||||
nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel =
|
||||
do_QueryInterface(channel);
|
||||
|
@ -202,7 +205,8 @@ NS_IMETHODIMP
|
|||
OfflineCacheUpdateChild::InitPartial(nsIURI* aManifestURI,
|
||||
const nsACString& clientID,
|
||||
nsIURI* aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal) {
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsICookieSettings* aCookieSettings) {
|
||||
MOZ_ASSERT_UNREACHABLE(
|
||||
"Not expected to do partial offline cache updates"
|
||||
" on the child process");
|
||||
|
@ -394,8 +398,14 @@ OfflineCacheUpdateChild::Schedule() {
|
|||
// See also nsOfflineCacheUpdate::ScheduleImplicit.
|
||||
bool stickDocument = mDocument != nullptr;
|
||||
|
||||
CookieSettingsArgs csArgs;
|
||||
if (mCookieSettings) {
|
||||
CookieSettings::Cast(mCookieSettings)->Serialize(csArgs);
|
||||
}
|
||||
|
||||
ContentChild::GetSingleton()->SendPOfflineCacheUpdateConstructor(
|
||||
this, manifestURI, documentURI, loadingPrincipalInfo, stickDocument);
|
||||
this, manifestURI, documentURI, loadingPrincipalInfo, stickDocument,
|
||||
csArgs);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ class OfflineCacheUpdateChild : public nsIOfflineCacheUpdate,
|
|||
nsCOMPtr<nsIURI> mManifestURI;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
nsCOMPtr<nsICookieSettings> mCookieSettings;
|
||||
|
||||
nsCOMPtr<nsIObserverService> mObserverService;
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ nsIOfflineCacheUpdate* OfflineCacheUpdateGlue::EnsureUpdate() {
|
|||
mUpdate = new nsOfflineCacheUpdate();
|
||||
LOG(("OfflineCacheUpdateGlue [%p] is using update [%p]", this,
|
||||
mUpdate.get()));
|
||||
|
||||
mUpdate->SetCookieSettings(mCookieSettings);
|
||||
}
|
||||
|
||||
return mUpdate;
|
||||
|
@ -120,8 +122,12 @@ OfflineCacheUpdateGlue::Init(nsIURI* aManifestURI, nsIURI* aDocumentURI,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
return mUpdate->Init(aManifestURI, aDocumentURI, aLoadingPrincipal, nullptr,
|
||||
aCustomProfileDir);
|
||||
rv = mUpdate->Init(aManifestURI, aDocumentURI, aLoadingPrincipal, nullptr,
|
||||
aCustomProfileDir);
|
||||
|
||||
mUpdate->SetCookieSettings(mCookieSettings);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void OfflineCacheUpdateGlue::SetDocument(Document* aDocument) {
|
||||
|
@ -138,6 +144,8 @@ void OfflineCacheUpdateGlue::SetDocument(Document* aDocument) {
|
|||
// implicit (which are the reasons we collect documents here).
|
||||
if (!aDocument) return;
|
||||
|
||||
mCookieSettings = aDocument->CookieSettings();
|
||||
|
||||
nsIChannel* channel = aDocument->GetChannel();
|
||||
nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel =
|
||||
do_QueryInterface(channel);
|
||||
|
|
|
@ -51,10 +51,11 @@ namespace docshell {
|
|||
} \
|
||||
NS_IMETHOD InitPartial(nsIURI* aManifestURI, const nsACString& aClientID, \
|
||||
nsIURI* aDocumentURI, \
|
||||
nsIPrincipal* aLoadingPrincipal) override { \
|
||||
nsIPrincipal* aLoadingPrincipal, \
|
||||
nsICookieSettings* aCookieSettings) override { \
|
||||
return !_to ? NS_ERROR_NULL_POINTER \
|
||||
: _to->InitPartial(aManifestURI, aClientID, aDocumentURI, \
|
||||
aLoadingPrincipal); \
|
||||
aLoadingPrincipal, aCookieSettings); \
|
||||
} \
|
||||
NS_IMETHOD InitForUpdateCheck(nsIURI* aManifestURI, \
|
||||
nsIPrincipal* aLoadingPrincipal, \
|
||||
|
@ -115,6 +116,7 @@ class OfflineCacheUpdateGlue final : public nsSupportsWeakReference,
|
|||
RefPtr<mozilla::dom::Document> mDocument;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
nsCOMPtr<nsICookieSettings> mCookieSettings;
|
||||
};
|
||||
|
||||
} // namespace docshell
|
||||
|
|
|
@ -72,7 +72,8 @@ void OfflineCacheUpdateParent::ActorDestroy(ActorDestroyReason why) {
|
|||
|
||||
nsresult OfflineCacheUpdateParent::Schedule(
|
||||
const URIParams& aManifestURI, const URIParams& aDocumentURI,
|
||||
const PrincipalInfo& aLoadingPrincipalInfo, const bool& stickDocument) {
|
||||
const PrincipalInfo& aLoadingPrincipalInfo, const bool& stickDocument,
|
||||
const CookieSettingsArgs& aCookieSettingsArgs) {
|
||||
LOG(("OfflineCacheUpdateParent::RecvSchedule [%p]", this));
|
||||
|
||||
nsresult rv;
|
||||
|
@ -116,6 +117,8 @@ nsresult OfflineCacheUpdateParent::Schedule(
|
|||
nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
update->SetCookieSettingsArgs(aCookieSettingsArgs);
|
||||
|
||||
// Must add before Schedule() call otherwise we would miss
|
||||
// oncheck event notification.
|
||||
update->AddObserver(this, false);
|
||||
|
@ -123,6 +126,8 @@ nsresult OfflineCacheUpdateParent::Schedule(
|
|||
rv = update->Schedule();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
update->SetCookieSettingsArgs(aCookieSettingsArgs);
|
||||
|
||||
update->AddObserver(this, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ namespace ipc {
|
|||
class URIParams;
|
||||
} // namespace ipc
|
||||
|
||||
namespace net {
|
||||
class CookieSettingsArgs;
|
||||
}
|
||||
|
||||
namespace docshell {
|
||||
|
||||
class OfflineCacheUpdateParent : public POfflineCacheUpdateParent,
|
||||
|
@ -37,7 +41,8 @@ class OfflineCacheUpdateParent : public POfflineCacheUpdateParent,
|
|||
|
||||
nsresult Schedule(const URIParams& manifestURI, const URIParams& documentURI,
|
||||
const PrincipalInfo& loadingPrincipalInfo,
|
||||
const bool& stickDocument);
|
||||
const bool& stickDocument,
|
||||
const net::CookieSettingsArgs& aCookieSettingsArgs);
|
||||
|
||||
void StopSendingMessagesToChild() { mIPCClosed = true; }
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ interface nsIPrefBranch;
|
|||
interface nsIApplicationCache;
|
||||
interface nsIFile;
|
||||
interface nsIObserver;
|
||||
interface nsICookieSettings;
|
||||
webidl Document;
|
||||
|
||||
[scriptable, uuid(47360d57-8ef4-4a5d-8865-1a27a739ad1a)]
|
||||
|
@ -126,9 +127,13 @@ interface nsIOfflineCacheUpdate : nsISupports {
|
|||
* @param aDocumentURI
|
||||
* The page that is requesting the update. May be null
|
||||
* when this information is unknown.
|
||||
* @param aCookieSettings
|
||||
* The cookie settings belonging to the page that is requesting
|
||||
* the update.
|
||||
*/
|
||||
void initPartial(in nsIURI aManifestURI, in ACString aClientID,
|
||||
in nsIURI aDocumentURI, in nsIPrincipal aPrincipal);
|
||||
in nsIURI aDocumentURI, in nsIPrincipal aPrincipal,
|
||||
in nsICookieSettings aCookieSettings);
|
||||
|
||||
/**
|
||||
* Initialize the update to only check whether there is an update
|
||||
|
|
|
@ -154,8 +154,7 @@ nsresult nsManifestCheck::Begin() {
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel), mURI, mLoadingPrincipal,
|
||||
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // nsICookieSettings
|
||||
nsIContentPolicy::TYPE_OTHER, mUpdate->CookieSettings(),
|
||||
nullptr, // PerformanceStorage
|
||||
nullptr, // loadGroup
|
||||
nullptr, // aCallbacks
|
||||
|
@ -322,8 +321,7 @@ nsresult nsOfflineCacheUpdateItem::OpenChannel(nsOfflineCacheUpdate* aUpdate) {
|
|||
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel), mURI, mLoadingPrincipal,
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // nsICookieSettings
|
||||
nsIContentPolicy::TYPE_OTHER, aUpdate->CookieSettings(),
|
||||
nullptr, // PerformanceStorage
|
||||
nullptr, // aLoadGroup
|
||||
this, // aCallbacks
|
||||
|
@ -1183,6 +1181,10 @@ nsresult nsOfflineCacheUpdate::Init(nsIURI* aManifestURI, nsIURI* aDocumentURI,
|
|||
|
||||
mDocumentURI = aDocumentURI;
|
||||
|
||||
if (aDocument) {
|
||||
mCookieSettings = aDocument->CookieSettings();
|
||||
}
|
||||
|
||||
if (aCustomProfileDir) {
|
||||
rv = cacheService->BuildGroupIDForSuffix(aManifestURI, originSuffix,
|
||||
mGroupID);
|
||||
|
@ -1277,7 +1279,8 @@ nsresult nsOfflineCacheUpdate::InitForUpdateCheck(
|
|||
nsresult nsOfflineCacheUpdate::InitPartial(nsIURI* aManifestURI,
|
||||
const nsACString& clientID,
|
||||
nsIURI* aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal) {
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsICookieSettings* aCookieSettings) {
|
||||
nsresult rv;
|
||||
|
||||
// Make sure the service has been initialized
|
||||
|
@ -1324,6 +1327,8 @@ nsresult nsOfflineCacheUpdate::InitPartial(nsIURI* aManifestURI,
|
|||
&mPinned);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mCookieSettings = aCookieSettings;
|
||||
|
||||
mState = STATE_INITIALIZED;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1626,6 +1631,8 @@ void nsOfflineCacheUpdate::ManifestCheckCompleted(
|
|||
newUpdate->Init(mManifestURI, mDocumentURI, mLoadingPrincipal, nullptr,
|
||||
mCustomProfileDir);
|
||||
|
||||
newUpdate->SetCookieSettings(mCookieSettings);
|
||||
|
||||
// In a rare case the manifest will not be modified on the next refetch
|
||||
// transfer all master document URIs to the new update to ensure that
|
||||
// all documents refering it will be properly cached.
|
||||
|
@ -1932,7 +1939,7 @@ nsresult nsOfflineCacheUpdate::ScheduleImplicit() {
|
|||
}
|
||||
|
||||
rv = update->InitPartial(mManifestURI, clientID, mDocumentURI,
|
||||
mLoadingPrincipal);
|
||||
mLoadingPrincipal, mCookieSettings);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (int32_t i = 0; i < mDocumentURIs.Count(); i++) {
|
||||
|
@ -2293,6 +2300,19 @@ nsOfflineCacheUpdate::UpdateStateChanged(nsIOfflineCacheUpdate* aUpdate,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsOfflineCacheUpdate::SetCookieSettings(
|
||||
nsICookieSettings* aCookieSettings) {
|
||||
mCookieSettings = aCookieSettings;
|
||||
}
|
||||
|
||||
void nsOfflineCacheUpdate::SetCookieSettingsArgs(
|
||||
const CookieSettingsArgs& aCookieSettingsArgs) {
|
||||
MOZ_ASSERT(!mCookieSettings);
|
||||
|
||||
CookieSettings::Deserialize(aCookieSettingsArgs,
|
||||
getter_AddRefs(mCookieSettings));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOfflineCacheUpdate::ApplicationCacheAvailable(
|
||||
nsIApplicationCache* applicationCache) {
|
||||
|
|
|
@ -32,6 +32,14 @@
|
|||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace net {
|
||||
class CookieSettingsArgs;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
class nsOfflineCacheUpdate;
|
||||
|
||||
class nsOfflineCacheUpdateItem : public nsIStreamListener,
|
||||
|
@ -215,6 +223,11 @@ class nsOfflineCacheUpdate final : public nsIOfflineCacheUpdate,
|
|||
|
||||
virtual nsresult UpdateFinished(nsOfflineCacheUpdate* aUpdate) override;
|
||||
|
||||
nsICookieSettings* CookieSettings() const { return mCookieSettings; }
|
||||
void SetCookieSettings(nsICookieSettings* aCookieSettings);
|
||||
void SetCookieSettingsArgs(
|
||||
const mozilla::net::CookieSettingsArgs& aCookieSettingsArgs);
|
||||
|
||||
protected:
|
||||
~nsOfflineCacheUpdate();
|
||||
|
||||
|
@ -271,6 +284,7 @@ class nsOfflineCacheUpdate final : public nsIOfflineCacheUpdate,
|
|||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
nsCOMPtr<nsIFile> mCustomProfileDir;
|
||||
nsCOMPtr<nsICookieSettings> mCookieSettings;
|
||||
|
||||
nsCOMPtr<nsIObserver> mUpdateAvailableObserver;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче