mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1199295 - Pass right loadingPrincipal to uriloader/prefetch (r=mayhemer)
* * * Bug 1199295 - Investigate loadingPrincipal for loadInfo in uriloader/prefetch (sicking,smaug)
This commit is contained in:
parent
9db34a3597
commit
4e2abd9439
@ -60,6 +60,7 @@ include PTabContext;
|
||||
include URIParams;
|
||||
include PluginTypes;
|
||||
include ProtocolTypes;
|
||||
include PBackgroundSharedTypes;
|
||||
include PContentPermission;
|
||||
include BrowserConfiguration;
|
||||
include GraphicsMessages;
|
||||
@ -1021,6 +1022,8 @@ parent:
|
||||
* URI of the manifest to fetch, the application cache group ID
|
||||
* @param documentURI
|
||||
* URI of the document that referred the manifest
|
||||
* @param loadingPrincipal
|
||||
* Principal of the document that referred the manifest
|
||||
* @param stickDocument
|
||||
* True if the update was initiated by a document load that referred
|
||||
* a manifest.
|
||||
@ -1040,7 +1043,8 @@ parent:
|
||||
* To identify which tab owns the app.
|
||||
*/
|
||||
POfflineCacheUpdate(URIParams manifestURI, URIParams documentURI,
|
||||
bool stickDocument, TabId tabId);
|
||||
PrincipalInfo loadingPrincipal, bool stickDocument,
|
||||
TabId tabId);
|
||||
|
||||
/**
|
||||
* Sets "offline-app" permission for the principal. Called when we hit
|
||||
|
@ -361,7 +361,8 @@ nsDOMOfflineResourceList::MozAdd(const nsAString& aURI)
|
||||
rv = appCache->GetClientID(clientID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = update->InitPartial(mManifestURI, clientID, mDocumentURI);
|
||||
rv = update->InitPartial(mManifestURI, clientID,
|
||||
mDocumentURI, mLoadingPrincipal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = update->AddDynamicURI(requestedURI);
|
||||
|
@ -3,6 +3,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/. */
|
||||
|
||||
#include "BackgroundUtils.h"
|
||||
#include "OfflineCacheUpdateChild.h"
|
||||
#include "nsOfflineCacheUpdate.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
@ -174,6 +175,7 @@ OfflineCacheUpdateChild::AssociateDocument(nsIDOMDocument *aDocument,
|
||||
NS_IMETHODIMP
|
||||
OfflineCacheUpdateChild::Init(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal *aLoadingPrincipal,
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIFile *aCustomProfileDir,
|
||||
uint32_t aAppID,
|
||||
@ -212,6 +214,7 @@ OfflineCacheUpdateChild::Init(nsIURI *aManifestURI,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mDocumentURI = aDocumentURI;
|
||||
mLoadingPrincipal = aLoadingPrincipal;
|
||||
|
||||
mState = STATE_INITIALIZED;
|
||||
|
||||
@ -227,7 +230,8 @@ OfflineCacheUpdateChild::Init(nsIURI *aManifestURI,
|
||||
NS_IMETHODIMP
|
||||
OfflineCacheUpdateChild::InitPartial(nsIURI *aManifestURI,
|
||||
const nsACString& clientID,
|
||||
nsIURI *aDocumentURI)
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal *aLoadingPrincipal)
|
||||
{
|
||||
NS_NOTREACHED("Not expected to do partial offline cache updates"
|
||||
" on the child process");
|
||||
@ -237,6 +241,7 @@ OfflineCacheUpdateChild::InitPartial(nsIURI *aManifestURI,
|
||||
|
||||
NS_IMETHODIMP
|
||||
OfflineCacheUpdateChild::InitForUpdateCheck(nsIURI *aManifestURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser,
|
||||
nsIObserver *aObserver)
|
||||
@ -409,6 +414,12 @@ OfflineCacheUpdateChild::Schedule()
|
||||
SerializeURI(mManifestURI, manifestURI);
|
||||
SerializeURI(mDocumentURI, documentURI);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
PrincipalInfo loadingPrincipalInfo;
|
||||
rv = PrincipalToPrincipalInfo(mLoadingPrincipal,
|
||||
&loadingPrincipalInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
@ -431,7 +442,7 @@ OfflineCacheUpdateChild::Schedule()
|
||||
// a reference to us. Will be released in RecvFinish() that identifies
|
||||
// the work has been done.
|
||||
ContentChild::GetSingleton()->SendPOfflineCacheUpdateConstructor(
|
||||
this, manifestURI, documentURI,
|
||||
this, manifestURI, documentURI, loadingPrincipalInfo,
|
||||
stickDocument, child->GetTabId());
|
||||
|
||||
// ContentChild::DeallocPOfflineCacheUpdate will release this.
|
||||
|
@ -68,6 +68,7 @@ private:
|
||||
nsCString mUpdateDomain;
|
||||
nsCOMPtr<nsIURI> mManifestURI;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
|
||||
nsCOMPtr<nsIObserverService> mObserverService;
|
||||
|
||||
|
@ -97,6 +97,7 @@ OfflineCacheUpdateGlue::Schedule()
|
||||
NS_IMETHODIMP
|
||||
OfflineCacheUpdateGlue::Init(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIFile *aCustomProfileDir,
|
||||
uint32_t aAppID,
|
||||
@ -114,6 +115,7 @@ OfflineCacheUpdateGlue::Init(nsIURI *aManifestURI,
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
mDocumentURI = aDocumentURI;
|
||||
mLoadingPrincipal = aLoadingPrincipal;
|
||||
|
||||
if (aDocument)
|
||||
SetDocument(aDocument);
|
||||
@ -123,7 +125,8 @@ OfflineCacheUpdateGlue::Init(nsIURI *aManifestURI,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return mUpdate->Init(aManifestURI, aDocumentURI, nullptr, aCustomProfileDir, aAppID, aInBrowser);
|
||||
return mUpdate->Init(aManifestURI, aDocumentURI, aLoadingPrincipal, nullptr,
|
||||
aCustomProfileDir, aAppID, aInBrowser);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -29,8 +29,8 @@ namespace docshell {
|
||||
NS_IMETHOD GetUpdateDomain(nsACString & aUpdateDomain) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUpdateDomain(aUpdateDomain); } \
|
||||
NS_IMETHOD GetManifestURI(nsIURI **aManifestURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetManifestURI(aManifestURI); } \
|
||||
NS_IMETHOD GetSucceeded(bool *aSucceeded) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetSucceeded(aSucceeded); } \
|
||||
NS_IMETHOD InitPartial(nsIURI *aManifestURI, const nsACString & aClientID, nsIURI *aDocumentURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->InitPartial(aManifestURI, aClientID, aDocumentURI); } \
|
||||
NS_IMETHOD InitForUpdateCheck(nsIURI *aManifestURI, uint32_t aAppID, bool aInBrowser, nsIObserver *aObserver) override { return !_to ? NS_ERROR_NULL_POINTER : _to->InitForUpdateCheck(aManifestURI, aAppID, aInBrowser, aObserver); } \
|
||||
NS_IMETHOD InitPartial(nsIURI *aManifestURI, const nsACString & aClientID, nsIURI *aDocumentURI, nsIPrincipal *aLoadingPrincipal) override { return !_to ? NS_ERROR_NULL_POINTER : _to->InitPartial(aManifestURI, aClientID, aDocumentURI, aLoadingPrincipal); } \
|
||||
NS_IMETHOD InitForUpdateCheck(nsIURI *aManifestURI, nsIPrincipal* aLoadingPrincipal, uint32_t aAppID, bool aInBrowser, nsIObserver *aObserver) override { return !_to ? NS_ERROR_NULL_POINTER : _to->InitForUpdateCheck(aManifestURI, aLoadingPrincipal, aAppID, aInBrowser, aObserver); } \
|
||||
NS_IMETHOD AddDynamicURI(nsIURI *aURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->AddDynamicURI(aURI); } \
|
||||
NS_IMETHOD AddObserver(nsIOfflineCacheUpdateObserver *aObserver, bool aHoldWeak) override { return !_to ? NS_ERROR_NULL_POINTER : _to->AddObserver(aObserver, aHoldWeak); } \
|
||||
NS_IMETHOD RemoveObserver(nsIOfflineCacheUpdateObserver *aObserver) override { return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveObserver(aObserver); } \
|
||||
@ -52,6 +52,7 @@ public:
|
||||
NS_IMETHOD Schedule(void) override;
|
||||
NS_IMETHOD Init(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIFile *aCustomProfileDir,
|
||||
uint32_t aAppID,
|
||||
@ -72,6 +73,7 @@ private:
|
||||
/* Document that requested this update */
|
||||
nsCOMPtr<nsIDOMDocument> mDocument;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
};
|
||||
|
||||
} // namespace docshell
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "OfflineCacheUpdateParent.h"
|
||||
|
||||
#include "BackgroundUtils.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/dom/TabParent.h"
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
@ -77,6 +78,7 @@ OfflineCacheUpdateParent::ActorDestroy(ActorDestroyReason why)
|
||||
nsresult
|
||||
OfflineCacheUpdateParent::Schedule(const URIParams& aManifestURI,
|
||||
const URIParams& aDocumentURI,
|
||||
const PrincipalInfo& aLoadingPrincipalInfo,
|
||||
const bool& stickDocument)
|
||||
{
|
||||
LOG(("OfflineCacheUpdateParent::RecvSchedule [%p]", this));
|
||||
@ -119,9 +121,13 @@ OfflineCacheUpdateParent::Schedule(const URIParams& aManifestURI,
|
||||
if (!update) {
|
||||
update = new nsOfflineCacheUpdate();
|
||||
|
||||
nsCOMPtr<nsIPrincipal> loadingPrincipal =
|
||||
PrincipalInfoToPrincipal(aLoadingPrincipalInfo, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Leave aDocument argument null. Only glues and children keep
|
||||
// document instances.
|
||||
rv = update->Init(manifestURI, documentURI, nullptr, nullptr,
|
||||
rv = update->Init(manifestURI, documentURI, loadingPrincipal, nullptr, nullptr,
|
||||
mOriginAttributes.mAppId, mOriginAttributes.mInBrowser);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -26,6 +26,7 @@ class OfflineCacheUpdateParent : public POfflineCacheUpdateParent
|
||||
, public nsILoadContext
|
||||
{
|
||||
typedef mozilla::ipc::URIParams URIParams;
|
||||
typedef mozilla::ipc::PrincipalInfo PrincipalInfo;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -35,6 +36,7 @@ public:
|
||||
nsresult
|
||||
Schedule(const URIParams& manifestURI,
|
||||
const URIParams& documentURI,
|
||||
const PrincipalInfo& loadingPrincipalInfo,
|
||||
const bool& stickDocument);
|
||||
|
||||
void
|
||||
|
@ -58,7 +58,7 @@ interface nsIOfflineCacheUpdateObserver : nsISupports {
|
||||
* load its items one by one, sending itemCompleted() to any registered
|
||||
* observers.
|
||||
*/
|
||||
[scriptable, uuid(a4503a53-6ab8-4b50-b01e-1c4f393fc980)]
|
||||
[scriptable, uuid(e9029838-3553-4192-a00b-f0f11073a6eb)]
|
||||
interface nsIOfflineCacheUpdate : nsISupports {
|
||||
/**
|
||||
* Fetch the status of the running update. This will return a value
|
||||
@ -101,8 +101,13 @@ interface nsIOfflineCacheUpdate : nsISupports {
|
||||
* The manifest URI to be checked.
|
||||
* @param aDocumentURI
|
||||
* The page that is requesting the update.
|
||||
* @param aLoadingPrincipal
|
||||
* The principal of the page that is requesting the update.
|
||||
*/
|
||||
void init(in nsIURI aManifestURI, in nsIURI aDocumentURI, in nsIDOMDocument aDocument,
|
||||
void init(in nsIURI aManifestURI,
|
||||
in nsIURI aDocumentURI,
|
||||
in nsIPrincipal aLoadingPrincipal,
|
||||
in nsIDOMDocument aDocument,
|
||||
[optional] in nsIFile aCustomProfileDir,
|
||||
[optional] in unsigned long aAppId,
|
||||
[optional] in boolean aInBrowser);
|
||||
@ -120,7 +125,8 @@ interface nsIOfflineCacheUpdate : nsISupports {
|
||||
* The page that is requesting the update. May be null
|
||||
* when this information is unknown.
|
||||
*/
|
||||
void initPartial(in nsIURI aManifestURI, in ACString aClientID, in nsIURI aDocumentURI);
|
||||
void initPartial(in nsIURI aManifestURI, in ACString aClientID,
|
||||
in nsIURI aDocumentURI, in nsIPrincipal aPrincipal);
|
||||
|
||||
/**
|
||||
* Initialize the update to only check whether there is an update
|
||||
@ -141,6 +147,7 @@ interface nsIOfflineCacheUpdate : nsISupports {
|
||||
* update available (the manifest has not changed on the server).
|
||||
*/
|
||||
void initForUpdateCheck(in nsIURI aManifestURI,
|
||||
in nsIPrincipal aLoadingPrincipal,
|
||||
in unsigned long aAppID,
|
||||
in boolean aInBrowser,
|
||||
in nsIObserver aObserver);
|
||||
@ -192,7 +199,7 @@ interface nsIOfflineCacheUpdate : nsISupports {
|
||||
readonly attribute uint64_t byteProgress;
|
||||
};
|
||||
|
||||
[scriptable, uuid(0668910d-d14f-4cee-8db5-25faebc360ab)]
|
||||
[scriptable, uuid(a297a334-bcae-4779-a564-555593edc96b)]
|
||||
interface nsIOfflineCacheUpdateService : nsISupports {
|
||||
/**
|
||||
* Constants for the offline-app permission.
|
||||
@ -220,6 +227,7 @@ interface nsIOfflineCacheUpdateService : nsISupports {
|
||||
*/
|
||||
nsIOfflineCacheUpdate scheduleUpdate(in nsIURI aManifestURI,
|
||||
in nsIURI aDocumentURI,
|
||||
in nsIPrincipal aLoadingPrincipal,
|
||||
in nsIDOMWindow aWindow);
|
||||
|
||||
/**
|
||||
@ -230,6 +238,7 @@ interface nsIOfflineCacheUpdateService : nsISupports {
|
||||
*/
|
||||
nsIOfflineCacheUpdate scheduleAppUpdate(in nsIURI aManifestURI,
|
||||
in nsIURI aDocumentURI,
|
||||
in nsIPrincipal aLoadingPrincipal,
|
||||
in unsigned long aAppID,
|
||||
in boolean aInBrowser,
|
||||
in nsIFile aProfileDir);
|
||||
@ -240,6 +249,7 @@ interface nsIOfflineCacheUpdateService : nsISupports {
|
||||
*/
|
||||
void scheduleOnDocumentStop(in nsIURI aManifestURI,
|
||||
in nsIURI aDocumentURI,
|
||||
in nsIPrincipal aLoadingPrincipal,
|
||||
in nsIDOMDocument aDocument);
|
||||
|
||||
/**
|
||||
@ -254,6 +264,7 @@ interface nsIOfflineCacheUpdateService : nsISupports {
|
||||
* description.
|
||||
*/
|
||||
void checkForUpdate(in nsIURI aManifestURI,
|
||||
in nsIPrincipal aLoadingPrincipal,
|
||||
in unsigned long aAppID,
|
||||
in boolean aInBrowser,
|
||||
in nsIObserver aObserver);
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIPrincipal.h"
|
||||
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
@ -120,10 +121,12 @@ class nsManifestCheck final : public nsIStreamListener
|
||||
public:
|
||||
nsManifestCheck(nsOfflineCacheUpdate *aUpdate,
|
||||
nsIURI *aURI,
|
||||
nsIURI *aReferrerURI)
|
||||
nsIURI *aReferrerURI,
|
||||
nsIPrincipal* aLoadingPrincipal)
|
||||
: mUpdate(aUpdate)
|
||||
, mURI(aURI)
|
||||
, mReferrerURI(aReferrerURI)
|
||||
, mLoadingPrincipal(aLoadingPrincipal)
|
||||
{}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -148,6 +151,7 @@ private:
|
||||
nsRefPtr<nsOfflineCacheUpdate> mUpdate;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIURI> mReferrerURI;
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
nsCOMPtr<nsICryptoHash> mManifestHash;
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
};
|
||||
@ -176,8 +180,8 @@ nsManifestCheck::Begin()
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel),
|
||||
mURI,
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
mLoadingPrincipal,
|
||||
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // loadGroup
|
||||
nullptr, // aCallbacks
|
||||
@ -317,11 +321,13 @@ NS_IMPL_ISUPPORTS(nsOfflineCacheUpdateItem,
|
||||
|
||||
nsOfflineCacheUpdateItem::nsOfflineCacheUpdateItem(nsIURI *aURI,
|
||||
nsIURI *aReferrerURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIApplicationCache *aApplicationCache,
|
||||
nsIApplicationCache *aPreviousApplicationCache,
|
||||
uint32_t type)
|
||||
: mURI(aURI)
|
||||
, mReferrerURI(aReferrerURI)
|
||||
, mLoadingPrincipal(aLoadingPrincipal)
|
||||
, mApplicationCache(aApplicationCache)
|
||||
, mPreviousApplicationCache(aPreviousApplicationCache)
|
||||
, mItemType(type)
|
||||
@ -367,7 +373,7 @@ nsOfflineCacheUpdateItem::OpenChannel(nsOfflineCacheUpdate *aUpdate)
|
||||
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel),
|
||||
mURI,
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
mLoadingPrincipal,
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // aLoadGroup
|
||||
@ -674,9 +680,10 @@ nsOfflineCacheUpdateItem::GetStatus(uint16_t *aStatus)
|
||||
|
||||
nsOfflineManifestItem::nsOfflineManifestItem(nsIURI *aURI,
|
||||
nsIURI *aReferrerURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIApplicationCache *aApplicationCache,
|
||||
nsIApplicationCache *aPreviousApplicationCache)
|
||||
: nsOfflineCacheUpdateItem(aURI, aReferrerURI,
|
||||
: nsOfflineCacheUpdateItem(aURI, aReferrerURI, aLoadingPrincipal,
|
||||
aApplicationCache, aPreviousApplicationCache,
|
||||
nsIApplicationCache::ITEM_MANIFEST)
|
||||
, mParserState(PARSE_INIT)
|
||||
@ -1188,7 +1195,8 @@ nsOfflineCacheUpdate::GetCacheKey(nsIURI *aURI, nsACString &aKey)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsOfflineCacheUpdate::InitInternal(nsIURI *aManifestURI)
|
||||
nsOfflineCacheUpdate::InitInternal(nsIURI *aManifestURI,
|
||||
nsIPrincipal* aLoadingPrincipal)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -1205,6 +1213,7 @@ nsOfflineCacheUpdate::InitInternal(nsIURI *aManifestURI)
|
||||
}
|
||||
|
||||
mManifestURI = aManifestURI;
|
||||
mLoadingPrincipal = aLoadingPrincipal;
|
||||
|
||||
rv = mManifestURI->GetAsciiHost(mUpdateDomain);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -1217,6 +1226,7 @@ nsOfflineCacheUpdate::InitInternal(nsIURI *aManifestURI)
|
||||
nsresult
|
||||
nsOfflineCacheUpdate::Init(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIFile *aCustomProfileDir,
|
||||
uint32_t aAppID,
|
||||
@ -1232,7 +1242,7 @@ nsOfflineCacheUpdate::Init(nsIURI *aManifestURI,
|
||||
|
||||
LOG(("nsOfflineCacheUpdate::Init [%p]", this));
|
||||
|
||||
rv = InitInternal(aManifestURI);
|
||||
rv = InitInternal(aManifestURI, aLoadingPrincipal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIApplicationCacheService> cacheService =
|
||||
@ -1292,6 +1302,7 @@ nsOfflineCacheUpdate::Init(nsIURI *aManifestURI,
|
||||
|
||||
nsresult
|
||||
nsOfflineCacheUpdate::InitForUpdateCheck(nsIURI *aManifestURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser,
|
||||
nsIObserver *aObserver)
|
||||
@ -1306,7 +1317,7 @@ nsOfflineCacheUpdate::InitForUpdateCheck(nsIURI *aManifestURI,
|
||||
|
||||
LOG(("nsOfflineCacheUpdate::InitForUpdateCheck [%p]", this));
|
||||
|
||||
rv = InitInternal(aManifestURI);
|
||||
rv = InitInternal(aManifestURI, aLoadingPrincipal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIApplicationCacheService> cacheService =
|
||||
@ -1345,7 +1356,8 @@ nsOfflineCacheUpdate::InitForUpdateCheck(nsIURI *aManifestURI,
|
||||
nsresult
|
||||
nsOfflineCacheUpdate::InitPartial(nsIURI *aManifestURI,
|
||||
const nsACString& clientID,
|
||||
nsIURI *aDocumentURI)
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal *aLoadingPrincipal)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -1359,6 +1371,7 @@ nsOfflineCacheUpdate::InitPartial(nsIURI *aManifestURI,
|
||||
|
||||
mPartialUpdate = true;
|
||||
mDocumentURI = aDocumentURI;
|
||||
mLoadingPrincipal = aLoadingPrincipal;
|
||||
|
||||
mManifestURI = aManifestURI;
|
||||
rv = mManifestURI->GetAsciiHost(mUpdateDomain);
|
||||
@ -1696,7 +1709,7 @@ nsOfflineCacheUpdate::ManifestCheckCompleted(nsresult aStatus,
|
||||
new nsOfflineCacheUpdate();
|
||||
// Leave aDocument argument null. Only glues and children keep
|
||||
// document instances.
|
||||
newUpdate->Init(mManifestURI, mDocumentURI, nullptr,
|
||||
newUpdate->Init(mManifestURI, mDocumentURI, mLoadingPrincipal, nullptr,
|
||||
mCustomProfileDir, mAppID, mInBrowser);
|
||||
|
||||
// In a rare case the manifest will not be modified on the next refetch
|
||||
@ -1748,6 +1761,7 @@ nsOfflineCacheUpdate::Begin()
|
||||
|
||||
mManifestItem = new nsOfflineManifestItem(mManifestURI,
|
||||
mDocumentURI,
|
||||
mLoadingPrincipal,
|
||||
mApplicationCache,
|
||||
mPreviousApplicationCache);
|
||||
if (!mManifestItem) {
|
||||
@ -1853,7 +1867,7 @@ nsOfflineCacheUpdate::ProcessNextURI()
|
||||
// is being updated. The check will call
|
||||
// ManifestCheckCompleted() when it's done.
|
||||
nsRefPtr<nsManifestCheck> manifestCheck =
|
||||
new nsManifestCheck(this, mManifestURI, mDocumentURI);
|
||||
new nsManifestCheck(this, mManifestURI, mDocumentURI, mLoadingPrincipal);
|
||||
if (NS_FAILED(manifestCheck->Begin())) {
|
||||
mSucceeded = false;
|
||||
NotifyState(nsIOfflineCacheUpdateObserver::STATE_ERROR);
|
||||
@ -2046,7 +2060,7 @@ nsOfflineCacheUpdate::ScheduleImplicit()
|
||||
NS_ERROR("Offline cache update not having set mApplicationCache?");
|
||||
}
|
||||
|
||||
rv = update->InitPartial(mManifestURI, clientID, mDocumentURI);
|
||||
rv = update->InitPartial(mManifestURI, clientID, mDocumentURI, mLoadingPrincipal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (int32_t i = 0; i < mDocumentURIs.Count(); i++) {
|
||||
@ -2288,6 +2302,7 @@ nsOfflineCacheUpdate::AddURI(nsIURI *aURI, uint32_t aType)
|
||||
nsRefPtr<nsOfflineCacheUpdateItem> item =
|
||||
new nsOfflineCacheUpdateItem(aURI,
|
||||
mDocumentURI,
|
||||
mLoadingPrincipal,
|
||||
mApplicationCache,
|
||||
mPreviousApplicationCache,
|
||||
aType);
|
||||
|
@ -51,12 +51,14 @@ public:
|
||||
|
||||
nsOfflineCacheUpdateItem(nsIURI *aURI,
|
||||
nsIURI *aReferrerURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIApplicationCache *aApplicationCache,
|
||||
nsIApplicationCache *aPreviousApplicationCache,
|
||||
uint32_t aType);
|
||||
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIURI> mReferrerURI;
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
nsCOMPtr<nsIApplicationCache> mApplicationCache;
|
||||
nsCOMPtr<nsIApplicationCache> mPreviousApplicationCache;
|
||||
nsCString mCacheKey;
|
||||
@ -99,6 +101,7 @@ public:
|
||||
|
||||
nsOfflineManifestItem(nsIURI *aURI,
|
||||
nsIURI *aReferrerURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIApplicationCache *aApplicationCache,
|
||||
nsIApplicationCache *aPreviousApplicationCache);
|
||||
virtual ~nsOfflineManifestItem();
|
||||
@ -228,7 +231,7 @@ protected:
|
||||
void OnByteProgress(uint64_t byteIncrement);
|
||||
|
||||
private:
|
||||
nsresult InitInternal(nsIURI *aManifestURI);
|
||||
nsresult InitInternal(nsIURI *aManifestURI, nsIPrincipal* aPrincipal);
|
||||
nsresult HandleManifest(bool *aDoUpdate);
|
||||
nsresult AddURI(nsIURI *aURI, uint32_t aItemType);
|
||||
|
||||
@ -275,6 +278,7 @@ private:
|
||||
nsCString mGroupID;
|
||||
nsCOMPtr<nsIURI> mManifestURI;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
nsCOMPtr<nsIFile> mCustomProfileDir;
|
||||
|
||||
uint32_t mAppID;
|
||||
@ -338,6 +342,7 @@ public:
|
||||
|
||||
nsresult Schedule(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIDOMWindow* aWindow,
|
||||
nsIFile* aCustomProfileDir,
|
||||
|
@ -131,10 +131,12 @@ public:
|
||||
nsOfflineCachePendingUpdate(nsOfflineCacheUpdateService *aService,
|
||||
nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIDOMDocument *aDocument)
|
||||
: mService(aService)
|
||||
, mManifestURI(aManifestURI)
|
||||
, mDocumentURI(aDocumentURI)
|
||||
, mLoadingPrincipal(aLoadingPrincipal)
|
||||
, mDidReleaseThis(false)
|
||||
{
|
||||
mDocument = do_GetWeakReference(aDocument);
|
||||
@ -146,6 +148,7 @@ private:
|
||||
nsRefPtr<nsOfflineCacheUpdateService> mService;
|
||||
nsCOMPtr<nsIURI> mManifestURI;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
nsCOMPtr<nsIWeakReference> mDocument;
|
||||
bool mDidReleaseThis;
|
||||
};
|
||||
@ -218,9 +221,8 @@ nsOfflineCachePendingUpdate::OnStateChange(nsIWebProgress* aWebProgress,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIOfflineCacheUpdate> update;
|
||||
mService->Schedule(mManifestURI, mDocumentURI,
|
||||
updateDoc, window, nullptr,
|
||||
appId, isInBrowserElement, getter_AddRefs(update));
|
||||
mService->Schedule(mManifestURI, mDocumentURI, mLoadingPrincipal, updateDoc, window,
|
||||
nullptr, appId, isInBrowserElement, getter_AddRefs(update));
|
||||
if (mDidReleaseThis) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -375,6 +377,7 @@ nsOfflineCacheUpdateService::ScheduleUpdate(nsOfflineCacheUpdate *aUpdate)
|
||||
NS_IMETHODIMP
|
||||
nsOfflineCacheUpdateService::ScheduleOnDocumentStop(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIDOMDocument *aDocument)
|
||||
{
|
||||
LOG(("nsOfflineCacheUpdateService::ScheduleOnDocumentStop [%p, manifestURI=%p, documentURI=%p doc=%p]",
|
||||
@ -386,8 +389,8 @@ nsOfflineCacheUpdateService::ScheduleOnDocumentStop(nsIURI *aManifestURI,
|
||||
|
||||
// Proceed with cache update
|
||||
nsRefPtr<nsOfflineCachePendingUpdate> update =
|
||||
new nsOfflineCachePendingUpdate(this, aManifestURI,
|
||||
aDocumentURI, aDocument);
|
||||
new nsOfflineCachePendingUpdate(this, aManifestURI, aDocumentURI,
|
||||
aLoadingPrincipal, aDocument);
|
||||
NS_ENSURE_TRUE(update, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsresult rv = progress->AddProgressListener
|
||||
@ -520,6 +523,7 @@ nsOfflineCacheUpdateService::FindUpdate(nsIURI *aManifestURI,
|
||||
nsresult
|
||||
nsOfflineCacheUpdateService::Schedule(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIDOMWindow* aWindow,
|
||||
nsIFile* aCustomProfileDir,
|
||||
@ -545,7 +549,7 @@ nsOfflineCacheUpdateService::Schedule(nsIURI *aManifestURI,
|
||||
aWindow->GetApplicationCache(getter_AddRefs(appCacheWindowObject));
|
||||
}
|
||||
|
||||
rv = update->Init(aManifestURI, aDocumentURI, aDocument,
|
||||
rv = update->Init(aManifestURI, aDocumentURI, aLoadingPrincipal, aDocument,
|
||||
aCustomProfileDir, aAppID, aInBrowser);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -560,6 +564,7 @@ nsOfflineCacheUpdateService::Schedule(nsIURI *aManifestURI,
|
||||
NS_IMETHODIMP
|
||||
nsOfflineCacheUpdateService::ScheduleUpdate(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIDOMWindow *aWindow,
|
||||
nsIOfflineCacheUpdate **aUpdate)
|
||||
{
|
||||
@ -569,22 +574,24 @@ nsOfflineCacheUpdateService::ScheduleUpdate(nsIURI *aManifestURI,
|
||||
nsresult rv = GetAppIDAndInBrowserFromWindow(aWindow, &appId, &isInBrowser);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return Schedule(aManifestURI, aDocumentURI, nullptr, aWindow, nullptr,
|
||||
appId, isInBrowser, aUpdate);
|
||||
return Schedule(aManifestURI, aDocumentURI, aLoadingPrincipal, nullptr, aWindow,
|
||||
nullptr, appId, isInBrowser, aUpdate);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOfflineCacheUpdateService::ScheduleAppUpdate(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
uint32_t aAppID, bool aInBrowser,
|
||||
nsIFile *aProfileDir,
|
||||
nsIOfflineCacheUpdate **aUpdate)
|
||||
{
|
||||
return Schedule(aManifestURI, aDocumentURI, nullptr, nullptr, aProfileDir,
|
||||
aAppID, aInBrowser, aUpdate);
|
||||
return Schedule(aManifestURI, aDocumentURI, aLoadingPrincipal, nullptr, nullptr,
|
||||
aProfileDir, aAppID, aInBrowser, aUpdate);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOfflineCacheUpdateService::CheckForUpdate(nsIURI *aManifestURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser,
|
||||
nsIObserver *aObserver)
|
||||
@ -598,7 +605,7 @@ NS_IMETHODIMP nsOfflineCacheUpdateService::CheckForUpdate(nsIURI *aManifestURI,
|
||||
|
||||
nsresult rv;
|
||||
|
||||
rv = update->InitForUpdateCheck(aManifestURI, aAppID, aInBrowser, aObserver);
|
||||
rv = update->InitForUpdateCheck(aManifestURI, aLoadingPrincipal, aAppID, aInBrowser, aObserver);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = update->Schedule();
|
||||
|
Loading…
Reference in New Issue
Block a user