2014-07-09 23:56:37 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-02-13 11:36:47 -08:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-07-09 23:56:37 -07:00
|
|
|
/* 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_LoadInfo_h
|
|
|
|
#define mozilla_LoadInfo_h
|
|
|
|
|
2014-07-16 13:16:12 -07:00
|
|
|
#include "nsIContentPolicy.h"
|
2014-07-09 23:56:37 -07:00
|
|
|
#include "nsILoadInfo.h"
|
2014-07-16 13:16:12 -07:00
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsIWeakReferenceUtils.h" // for nsWeakPtr
|
2014-11-04 16:34:00 -08:00
|
|
|
#include "nsIURI.h"
|
2015-07-19 19:11:03 -07:00
|
|
|
#include "nsTArray.h"
|
2014-07-16 13:16:12 -07:00
|
|
|
|
2015-10-21 14:47:00 -07:00
|
|
|
#include "mozilla/BasePrincipal.h"
|
|
|
|
|
2014-07-16 13:16:12 -07:00
|
|
|
class nsINode;
|
2015-11-30 13:25:29 -08:00
|
|
|
class nsPIDOMWindow;
|
2015-10-19 11:14:54 -07:00
|
|
|
class nsXMLHttpRequest;
|
2014-07-09 23:56:37 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2015-01-07 15:51:20 -08:00
|
|
|
namespace net {
|
2015-07-13 22:43:13 -07:00
|
|
|
class OptionalLoadInfoArgs;
|
2015-07-13 08:25:42 -07:00
|
|
|
} // namespace net
|
2015-06-18 15:37:20 -07:00
|
|
|
|
|
|
|
namespace ipc {
|
|
|
|
// we have to forward declare that function so we can use it as a friend.
|
|
|
|
nsresult
|
2015-07-13 22:43:13 -07:00
|
|
|
LoadInfoArgsToLoadInfo(const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
|
2015-06-18 15:37:20 -07:00
|
|
|
nsILoadInfo** outLoadInfo);
|
2015-07-13 08:25:42 -07:00
|
|
|
} // namespace ipc
|
2015-01-07 15:51:20 -08:00
|
|
|
|
2014-07-09 23:56:37 -07:00
|
|
|
/**
|
|
|
|
* Class that provides an nsILoadInfo implementation.
|
2015-04-02 11:35:40 -07:00
|
|
|
*
|
|
|
|
* Note that there is no reason why this class should be MOZ_EXPORT, but
|
|
|
|
* Thunderbird relies on some insane hacks which require this, so we'll leave it
|
|
|
|
* as is for now, but hopefully we'll be able to remove the MOZ_EXPORT keyword
|
|
|
|
* from this class at some point. See bug 1149127 for the discussion.
|
2014-07-09 23:56:37 -07:00
|
|
|
*/
|
2015-04-02 11:35:40 -07:00
|
|
|
class MOZ_EXPORT LoadInfo final : public nsILoadInfo
|
2014-07-09 23:56:37 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSILOADINFO
|
|
|
|
|
2014-11-14 08:55:59 -08:00
|
|
|
// aLoadingPrincipal MUST NOT BE NULL.
|
|
|
|
LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
|
|
|
nsIPrincipal* aTriggeringPrincipal,
|
2014-07-16 13:16:12 -07:00
|
|
|
nsINode* aLoadingContext,
|
|
|
|
nsSecurityFlags aSecurityFlags,
|
2015-08-19 10:43:30 -07:00
|
|
|
nsContentPolicyType aContentPolicyType);
|
2014-07-09 23:56:37 -07:00
|
|
|
|
2015-10-31 15:20:48 -07:00
|
|
|
// create an exact copy of the loadinfo
|
2015-09-24 13:42:02 -07:00
|
|
|
already_AddRefed<nsILoadInfo> Clone() const;
|
2015-10-31 15:20:48 -07:00
|
|
|
// creates a copy of the loadinfo which is appropriate to use for a
|
|
|
|
// separate request. I.e. not for a redirect or an inner channel, but
|
|
|
|
// when a separate request is made with the same security properties.
|
|
|
|
already_AddRefed<nsILoadInfo> CloneForNewRequest() const;
|
2015-09-24 13:42:02 -07:00
|
|
|
|
2015-12-06 15:33:14 -08:00
|
|
|
void SetIsPreflight();
|
|
|
|
|
2014-07-09 23:56:37 -07:00
|
|
|
private:
|
2015-01-07 15:51:20 -08:00
|
|
|
// private constructor that is only allowed to be called from within
|
|
|
|
// HttpChannelParent and FTPChannelParent declared as friends undeneath.
|
|
|
|
// In e10s we can not serialize nsINode, hence we store the innerWindowID.
|
2015-07-19 19:11:03 -07:00
|
|
|
// Please note that aRedirectChain uses swapElements.
|
2015-01-07 15:51:20 -08:00
|
|
|
LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
|
|
|
nsIPrincipal* aTriggeringPrincipal,
|
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
2015-12-06 15:33:15 -08:00
|
|
|
LoadTainting aTainting,
|
2015-07-10 13:57:55 -07:00
|
|
|
bool aUpgradeInsecureRequests,
|
2015-11-14 19:28:38 -08:00
|
|
|
bool aUpgradeInsecurePreloads,
|
2015-05-08 12:52:49 -07:00
|
|
|
uint64_t aInnerWindowID,
|
|
|
|
uint64_t aOuterWindowID,
|
2015-07-19 19:11:03 -07:00
|
|
|
uint64_t aParentOuterWindowID,
|
2015-07-19 19:11:57 -07:00
|
|
|
bool aEnforceSecurity,
|
|
|
|
bool aInitialSecurityCheckDone,
|
2015-11-30 13:25:29 -08:00
|
|
|
bool aIsThirdPartyRequest,
|
2015-11-02 17:50:54 -08:00
|
|
|
const NeckoOriginAttributes& aOriginAttributes,
|
2015-10-31 15:18:59 -07:00
|
|
|
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChainIncludingInternalRedirects,
|
2015-12-06 15:33:14 -08:00
|
|
|
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChain,
|
|
|
|
const nsTArray<nsCString>& aUnsafeHeaders,
|
|
|
|
bool aForcePreflight,
|
|
|
|
bool aIsPreflight);
|
2015-09-24 13:42:02 -07:00
|
|
|
LoadInfo(const LoadInfo& rhs);
|
2015-01-07 15:51:20 -08:00
|
|
|
|
2015-06-18 15:37:20 -07:00
|
|
|
friend nsresult
|
2015-07-13 22:43:13 -07:00
|
|
|
mozilla::ipc::LoadInfoArgsToLoadInfo(
|
|
|
|
const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
|
|
|
|
nsILoadInfo** outLoadInfo);
|
2015-01-07 15:51:20 -08:00
|
|
|
|
2014-07-09 23:56:37 -07:00
|
|
|
~LoadInfo();
|
|
|
|
|
2015-11-30 13:25:29 -08:00
|
|
|
void ComputeIsThirdPartyContext(nsPIDOMWindow* aOuterWindow);
|
|
|
|
|
2015-10-19 11:14:54 -07:00
|
|
|
// This function is the *only* function which can change the securityflags
|
|
|
|
// of a loadinfo. It only exists because of the XHR code. Don't call it
|
|
|
|
// from anywhere else!
|
2015-12-06 15:33:15 -08:00
|
|
|
void SetIncludeCookiesSecFlag();
|
2015-10-19 11:14:54 -07:00
|
|
|
friend class ::nsXMLHttpRequest;
|
|
|
|
|
2015-10-31 15:20:48 -07:00
|
|
|
// if you add a member, please also update the copy constructor
|
2015-07-19 19:11:57 -07:00
|
|
|
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
|
|
|
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
|
|
|
|
nsWeakPtr mLoadingContext;
|
|
|
|
nsSecurityFlags mSecurityFlags;
|
2015-10-19 11:14:54 -07:00
|
|
|
nsContentPolicyType mInternalContentPolicyType;
|
2015-10-22 11:07:32 -07:00
|
|
|
LoadTainting mTainting;
|
2015-07-19 19:11:57 -07:00
|
|
|
bool mUpgradeInsecureRequests;
|
2015-11-14 19:28:38 -08:00
|
|
|
bool mUpgradeInsecurePreloads;
|
2015-07-19 19:11:57 -07:00
|
|
|
uint64_t mInnerWindowID;
|
|
|
|
uint64_t mOuterWindowID;
|
|
|
|
uint64_t mParentOuterWindowID;
|
|
|
|
bool mEnforceSecurity;
|
|
|
|
bool mInitialSecurityCheckDone;
|
2015-11-30 13:25:29 -08:00
|
|
|
bool mIsThirdPartyContext;
|
2015-11-02 17:50:54 -08:00
|
|
|
NeckoOriginAttributes mOriginAttributes;
|
2015-10-31 15:18:59 -07:00
|
|
|
nsTArray<nsCOMPtr<nsIPrincipal>> mRedirectChainIncludingInternalRedirects;
|
2015-07-19 19:11:03 -07:00
|
|
|
nsTArray<nsCOMPtr<nsIPrincipal>> mRedirectChain;
|
2015-12-06 15:33:14 -08:00
|
|
|
nsTArray<nsCString> mCorsUnsafeHeaders;
|
|
|
|
bool mForcePreflight;
|
|
|
|
bool mIsPreflight;
|
2014-07-09 23:56:37 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_LoadInfo_h
|
|
|
|
|