1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/net/InterceptionInfo.h"
8 #include "nsContentUtils.h"
10 namespace mozilla::net
{
12 NS_IMPL_ISUPPORTS(InterceptionInfo
, nsIInterceptionInfo
)
14 InterceptionInfo::InterceptionInfo(nsIPrincipal
* aTriggeringPrincipal
,
15 nsContentPolicyType aContentPolicyType
,
16 const RedirectHistoryArray
& aRedirectChain
,
18 : mTriggeringPrincipal(aTriggeringPrincipal
),
19 mContentPolicyType(aContentPolicyType
),
20 mFromThirdParty(aFromThirdParty
) {
21 SetRedirectChain(aRedirectChain
);
24 nsIPrincipal
* InterceptionInfo::TriggeringPrincipal() {
25 return mTriggeringPrincipal
;
28 void InterceptionInfo::SetTriggeringPrincipal(nsIPrincipal
* aPrincipal
) {
29 mTriggeringPrincipal
= aPrincipal
;
32 nsContentPolicyType
InterceptionInfo::ContentPolicyType() {
33 return mContentPolicyType
;
36 nsContentPolicyType
InterceptionInfo::ExternalContentPolicyType() {
37 return static_cast<nsContentPolicyType
>(
38 nsContentUtils::InternalContentPolicyTypeToExternal(mContentPolicyType
));
41 void InterceptionInfo::SetContentPolicyType(
42 const nsContentPolicyType aContentPolicyType
) {
43 mContentPolicyType
= aContentPolicyType
;
46 const RedirectHistoryArray
& InterceptionInfo::RedirectChain() {
47 return mRedirectChain
;
50 void InterceptionInfo::SetRedirectChain(
51 const RedirectHistoryArray
& aRedirectChain
) {
52 for (auto entry
: aRedirectChain
) {
53 mRedirectChain
.AppendElement(entry
);
57 bool InterceptionInfo::FromThirdParty() { return mFromThirdParty
; }
59 void InterceptionInfo::SetFromThirdParty(bool aFromThirdParty
) {
60 mFromThirdParty
= aFromThirdParty
;
63 } // namespace mozilla::net