diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /netwerk/ipc/ParentChannelWrapper.cpp | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | netwerk/ipc/ParentChannelWrapper.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/netwerk/ipc/ParentChannelWrapper.cpp b/netwerk/ipc/ParentChannelWrapper.cpp new file mode 100644 index 0000000000..3b89e3e38f --- /dev/null +++ b/netwerk/ipc/ParentChannelWrapper.cpp @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set sw=2 ts=8 et tw=80 : */ + +/* 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/. */ + +#include "ParentChannelWrapper.h" +#include "mozilla/net/HttpBaseChannel.h" +#include "mozilla/net/UrlClassifierCommon.h" +#include "mozilla/net/RedirectChannelRegistrar.h" +#include "nsIViewSourceChannel.h" +#include "nsNetUtil.h" +#include "nsQueryObject.h" +#include "mozilla/dom/RemoteType.h" + +namespace mozilla { +namespace net { + +NS_IMPL_ISUPPORTS(ParentChannelWrapper, nsIParentChannel, nsIStreamListener, + nsIRequestObserver); + +void ParentChannelWrapper::Register(uint64_t aRegistrarId) { + nsCOMPtr<nsIRedirectChannelRegistrar> registrar = + RedirectChannelRegistrar::GetOrCreate(); + nsCOMPtr<nsIChannel> dummy; + MOZ_ALWAYS_SUCCEEDS( + NS_LinkRedirectChannels(aRegistrarId, this, getter_AddRefs(dummy))); + +#ifdef DEBUG + // The channel registered with the RedirectChannelRegistrar will be the inner + // channel when dealing with view-source loads. + if (nsCOMPtr<nsIViewSourceChannel> viewSource = do_QueryInterface(mChannel)) { + MOZ_ASSERT(dummy == viewSource->GetInnerChannel()); + } else { + MOZ_ASSERT(dummy == mChannel); + } +#endif +} + +//////////////////////////////////////////////////////////////////////////////// +// nsIParentChannel +//////////////////////////////////////////////////////////////////////////////// + +NS_IMETHODIMP +ParentChannelWrapper::SetParentListener( + mozilla::net::ParentChannelListener* listener) { + return NS_OK; +} + +NS_IMETHODIMP +ParentChannelWrapper::SetClassifierMatchedInfo(const nsACString& aList, + const nsACString& aProvider, + const nsACString& aFullHash) { + nsCOMPtr<nsIClassifiedChannel> classifiedChannel = + do_QueryInterface(mChannel); + if (classifiedChannel) { + classifiedChannel->SetMatchedInfo(aList, aProvider, aFullHash); + } + return NS_OK; +} + +NS_IMETHODIMP +ParentChannelWrapper::SetClassifierMatchedTrackingInfo( + const nsACString& aLists, const nsACString& aFullHash) { + nsCOMPtr<nsIClassifiedChannel> classifiedChannel = + do_QueryInterface(mChannel); + if (classifiedChannel) { + nsTArray<nsCString> lists, fullhashes; + for (const nsACString& token : aLists.Split(',')) { + lists.AppendElement(token); + } + for (const nsACString& token : aFullHash.Split(',')) { + fullhashes.AppendElement(token); + } + classifiedChannel->SetMatchedTrackingInfo(lists, fullhashes); + } + return NS_OK; +} + +NS_IMETHODIMP +ParentChannelWrapper::NotifyClassificationFlags(uint32_t aClassificationFlags, + bool aIsThirdParty) { + UrlClassifierCommon::SetClassificationFlagsHelper( + mChannel, aClassificationFlags, aIsThirdParty); + return NS_OK; +} + +NS_IMETHODIMP +ParentChannelWrapper::Delete() { return NS_OK; } + +NS_IMETHODIMP +ParentChannelWrapper::GetRemoteType(nsACString& aRemoteType) { + aRemoteType = NOT_REMOTE_TYPE; + return NS_OK; +} + +} // namespace net +} // namespace mozilla + +#undef LOG |