1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et tw=80 : */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "ParentChannelWrapper.h"
9 #include "mozilla/net/HttpBaseChannel.h"
10 #include "mozilla/net/UrlClassifierCommon.h"
11 #include "mozilla/net/RedirectChannelRegistrar.h"
12 #include "nsIViewSourceChannel.h"
13 #include "nsNetUtil.h"
14 #include "nsQueryObject.h"
15 #include "mozilla/dom/RemoteType.h"
20 NS_IMPL_ISUPPORTS(ParentChannelWrapper
, nsIParentChannel
, nsIStreamListener
,
23 void ParentChannelWrapper::Register(uint64_t aRegistrarId
) {
24 nsCOMPtr
<nsIRedirectChannelRegistrar
> registrar
=
25 RedirectChannelRegistrar::GetOrCreate();
26 nsCOMPtr
<nsIChannel
> dummy
;
28 NS_LinkRedirectChannels(aRegistrarId
, this, getter_AddRefs(dummy
)));
31 // The channel registered with the RedirectChannelRegistrar will be the inner
32 // channel when dealing with view-source loads.
33 if (nsCOMPtr
<nsIViewSourceChannel
> viewSource
= do_QueryInterface(mChannel
)) {
34 MOZ_ASSERT(dummy
== viewSource
->GetInnerChannel());
36 MOZ_ASSERT(dummy
== mChannel
);
41 ////////////////////////////////////////////////////////////////////////////////
43 ////////////////////////////////////////////////////////////////////////////////
46 ParentChannelWrapper::SetParentListener(
47 mozilla::net::ParentChannelListener
* listener
) {
52 ParentChannelWrapper::SetClassifierMatchedInfo(const nsACString
& aList
,
53 const nsACString
& aProvider
,
54 const nsACString
& aFullHash
) {
55 nsCOMPtr
<nsIClassifiedChannel
> classifiedChannel
=
56 do_QueryInterface(mChannel
);
57 if (classifiedChannel
) {
58 classifiedChannel
->SetMatchedInfo(aList
, aProvider
, aFullHash
);
64 ParentChannelWrapper::SetClassifierMatchedTrackingInfo(
65 const nsACString
& aLists
, const nsACString
& aFullHash
) {
66 nsCOMPtr
<nsIClassifiedChannel
> classifiedChannel
=
67 do_QueryInterface(mChannel
);
68 if (classifiedChannel
) {
69 nsTArray
<nsCString
> lists
, fullhashes
;
70 for (const nsACString
& token
: aLists
.Split(',')) {
71 lists
.AppendElement(token
);
73 for (const nsACString
& token
: aFullHash
.Split(',')) {
74 fullhashes
.AppendElement(token
);
76 classifiedChannel
->SetMatchedTrackingInfo(lists
, fullhashes
);
82 ParentChannelWrapper::NotifyClassificationFlags(uint32_t aClassificationFlags
,
84 UrlClassifierCommon::SetClassificationFlagsHelper(
85 mChannel
, aClassificationFlags
, aIsThirdParty
);
90 ParentChannelWrapper::Delete() { return NS_OK
; }
93 ParentChannelWrapper::GetRemoteType(nsACString
& aRemoteType
) {
94 aRemoteType
= NOT_REMOTE_TYPE
;
99 } // namespace mozilla