diff --git a/netwerk/ipc/DocumentChannelChild.cpp b/netwerk/ipc/DocumentChannelChild.cpp index 28f54544952e..229b0ba392b8 100644 --- a/netwerk/ipc/DocumentChannelChild.cpp +++ b/netwerk/ipc/DocumentChannelChild.cpp @@ -43,7 +43,6 @@ NS_INTERFACE_MAP_BEGIN(DocumentChannelChild) "Trying to request nsIHttpChannel from DocumentChannelChild, this is " "likely broken"); } - NS_INTERFACE_MAP_ENTRY(nsIClassifiedChannel) NS_INTERFACE_MAP_ENTRY(nsITraceableChannel) NS_INTERFACE_MAP_ENTRY_CONCRETE(DocumentChannelChild) NS_INTERFACE_MAP_END_INHERITING(nsBaseChannel) @@ -470,57 +469,6 @@ IPCResult DocumentChannelChild::RecvConfirmRedirect( return IPC_OK(); } -IPCResult DocumentChannelChild::RecvNotifyClassificationFlags( - const uint32_t& aClassificationFlags, const bool& aIsThirdParty) { - if (aIsThirdParty) { - mThirdPartyClassificationFlags |= aClassificationFlags; - } else { - mFirstPartyClassificationFlags |= aClassificationFlags; - } - return IPC_OK(); -} - -IPCResult DocumentChannelChild::RecvNotifyChannelClassifierProtectionDisabled( - const uint32_t& aAcceptedReason) { - UrlClassifierCommon::NotifyChannelClassifierProtectionDisabled( - this, aAcceptedReason); - return IPC_OK(); -} - -IPCResult DocumentChannelChild::RecvNotifyCookieAllowed() { - AntiTrackingCommon::NotifyBlockingDecision( - this, AntiTrackingCommon::BlockingDecision::eAllow, 0); - return IPC_OK(); -} - -IPCResult DocumentChannelChild::RecvNotifyCookieBlocked( - const uint32_t& aRejectedReason) { - AntiTrackingCommon::NotifyBlockingDecision( - this, AntiTrackingCommon::BlockingDecision::eBlock, aRejectedReason); - return IPC_OK(); -} - -IPCResult DocumentChannelChild::RecvSetClassifierMatchedInfo( - const nsCString& aList, const nsCString& aProvider, - const nsCString& aFullHash) { - SetMatchedInfo(aList, aProvider, aFullHash); - return IPC_OK(); -} - -IPCResult DocumentChannelChild::RecvSetClassifierMatchedTrackingInfo( - const nsCString& aLists, const nsCString& aFullHash) { - nsTArray lists, fullhashes; - for (const nsACString& token : aLists.Split(',')) { - lists.AppendElement(token); - } - for (const nsACString& token : aFullHash.Split(',')) { - fullhashes.AppendElement(token); - } - - SetMatchedTrackingInfo(lists, fullhashes); - return IPC_OK(); -} - mozilla::ipc::IPCResult DocumentChannelChild::RecvAttachStreamFilter( Endpoint&& aEndpoint) { extensions::StreamFilterParent::Attach(this, std::move(aEndpoint)); @@ -543,64 +491,6 @@ DocumentChannelChild::SetNewListener(nsIStreamListener* aListener, return NS_OK; } -//----------------------------------------------------------------------------- -// DocumentChannelChild::nsIClassifiedChannel - -NS_IMETHODIMP -DocumentChannelChild::GetMatchedList(nsACString& aList) { - aList = mMatchedList; - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelChild::GetMatchedProvider(nsACString& aProvider) { - aProvider = mMatchedProvider; - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelChild::GetMatchedFullHash(nsACString& aFullHash) { - aFullHash = mMatchedFullHash; - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelChild::SetMatchedInfo(const nsACString& aList, - const nsACString& aProvider, - const nsACString& aFullHash) { - NS_ENSURE_ARG(!aList.IsEmpty()); - - mMatchedList = aList; - mMatchedProvider = aProvider; - mMatchedFullHash = aFullHash; - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelChild::GetMatchedTrackingLists(nsTArray& aLists) { - aLists = mMatchedTrackingLists; - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelChild::GetMatchedTrackingFullHashes( - nsTArray& aFullHashes) { - aFullHashes = mMatchedTrackingFullHashes; - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelChild::SetMatchedTrackingInfo( - const nsTArray& aLists, const nsTArray& aFullHashes) { - NS_ENSURE_ARG(!aLists.IsEmpty()); - // aFullHashes can be empty for non hash-matching algorithm, for example, - // host based test entries in preference. - - mMatchedTrackingLists = aLists; - mMatchedTrackingFullHashes = aFullHashes; - return NS_OK; -} - NS_IMETHODIMP DocumentChannelChild::Cancel(nsresult aStatusCode) { if (mCanceled) { @@ -642,65 +532,5 @@ DocumentChannelChild::Resume() { return NS_OK; } -NS_IMETHODIMP -DocumentChannelChild::IsTrackingResource(bool* aIsTrackingResource) { - MOZ_ASSERT(!mFirstPartyClassificationFlags || - !mThirdPartyClassificationFlags); - *aIsTrackingResource = UrlClassifierCommon::IsTrackingClassificationFlag( - mThirdPartyClassificationFlags) || - UrlClassifierCommon::IsTrackingClassificationFlag( - mFirstPartyClassificationFlags); - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelChild::IsThirdPartyTrackingResource(bool* aIsTrackingResource) { - MOZ_ASSERT( - !(mFirstPartyClassificationFlags && mThirdPartyClassificationFlags)); - *aIsTrackingResource = UrlClassifierCommon::IsTrackingClassificationFlag( - mThirdPartyClassificationFlags); - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelChild::IsSocialTrackingResource( - bool* aIsSocialTrackingResource) { - MOZ_ASSERT(!mFirstPartyClassificationFlags || - !mThirdPartyClassificationFlags); - *aIsSocialTrackingResource = - UrlClassifierCommon::IsSocialTrackingClassificationFlag( - mThirdPartyClassificationFlags) || - UrlClassifierCommon::IsSocialTrackingClassificationFlag( - mFirstPartyClassificationFlags); - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelChild::GetClassificationFlags(uint32_t* aClassificationFlags) { - MOZ_ASSERT(aClassificationFlags); - if (mThirdPartyClassificationFlags) { - *aClassificationFlags = mThirdPartyClassificationFlags; - } else { - *aClassificationFlags = mFirstPartyClassificationFlags; - } - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelChild::GetFirstPartyClassificationFlags( - uint32_t* aClassificationFlags) { - MOZ_ASSERT(aClassificationFlags); - *aClassificationFlags = mFirstPartyClassificationFlags; - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelChild::GetThirdPartyClassificationFlags( - uint32_t* aClassificationFlags) { - MOZ_ASSERT(aClassificationFlags); - *aClassificationFlags = mThirdPartyClassificationFlags; - return NS_OK; -} - } // namespace net } // namespace mozilla diff --git a/netwerk/ipc/DocumentChannelChild.h b/netwerk/ipc/DocumentChannelChild.h index 8a86bcb7a3f7..1d4ff939d576 100644 --- a/netwerk/ipc/DocumentChannelChild.h +++ b/netwerk/ipc/DocumentChannelChild.h @@ -12,7 +12,6 @@ #include "mozilla/net/PDocumentChannelChild.h" #include "nsBaseChannel.h" #include "nsIChildChannel.h" -#include "nsIClassifiedChannel.h" #include "nsITraceableChannel.h" #define DOCUMENT_CHANNEL_CHILD_IID \ @@ -27,7 +26,6 @@ namespace net { class DocumentChannelChild final : public PDocumentChannelChild, public nsBaseChannel, - public nsIClassifiedChannel, public nsITraceableChannel { public: DocumentChannelChild(nsDocShellLoadState* aLoadState, @@ -38,7 +36,6 @@ class DocumentChannelChild final : public PDocumentChannelChild, NS_DECL_ISUPPORTS_INHERITED; NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK - NS_DECL_NSICLASSIFIEDCHANNEL NS_DECL_NSITRACEABLECHANNEL NS_DECLARE_STATIC_IID_ACCESSOR(DOCUMENT_CHANNEL_CHILD_IID) @@ -75,20 +72,6 @@ class DocumentChannelChild final : public PDocumentChannelChild, mozilla::ipc::IPCResult RecvAttachStreamFilter( Endpoint&& aEndpoint); - mozilla::ipc::IPCResult RecvNotifyClassificationFlags( - const uint32_t& aClassificationFlags, const bool& aIsThirdParty); - mozilla::ipc::IPCResult RecvNotifyChannelClassifierProtectionDisabled( - const uint32_t& aAcceptedReason); - mozilla::ipc::IPCResult RecvNotifyCookieAllowed(); - mozilla::ipc::IPCResult RecvNotifyCookieBlocked( - const uint32_t& aRejectedReason); - - mozilla::ipc::IPCResult RecvSetClassifierMatchedInfo( - const nsCString& aList, const nsCString& aProvider, - const nsCString& aFullHash); - mozilla::ipc::IPCResult RecvSetClassifierMatchedTrackingInfo( - const nsCString& aLists, const nsCString& aFullHash); - mozilla::ipc::IPCResult RecvConfirmRedirect( const LoadInfoArgs& aLoadInfo, nsIURI* aNewUri, ConfirmRedirectResolver&& aResolve); @@ -110,15 +93,6 @@ class DocumentChannelChild final : public PDocumentChannelChild, nsCOMPtr mRedirectChannel; nsTArray mRedirects; - // Classified channel's matched information - uint32_t mFirstPartyClassificationFlags = 0; - uint32_t mThirdPartyClassificationFlags = 0; - nsCString mMatchedList; - nsCString mMatchedProvider; - nsCString mMatchedFullHash; - nsTArray mMatchedTrackingLists; - nsTArray mMatchedTrackingFullHashes; - RedirectToRealChannelResolver mRedirectResolver; TimeStamp mAsyncOpenTime; diff --git a/netwerk/ipc/DocumentChannelParent.cpp b/netwerk/ipc/DocumentChannelParent.cpp index 1686207244bc..792a70bcb9a5 100644 --- a/netwerk/ipc/DocumentChannelParent.cpp +++ b/netwerk/ipc/DocumentChannelParent.cpp @@ -289,6 +289,17 @@ void DocumentChannelParent::FinishReplacementChannelSetup(bool aSucceeded) { [redirectChannel](const ClassificationFlagsParams& aParams) { redirectChannel->NotifyClassificationFlags( aParams.mClassificationFlags, aParams.mIsThirdParty); + }, + [redirectChannel]( + const NotifyChannelClassifierProtectionDisabledParams& aParams) { + redirectChannel->NotifyChannelClassifierProtectionDisabled( + aParams.mAcceptedReason); + }, + [redirectChannel](const NotifyCookieAllowedParams&) { + redirectChannel->NotifyCookieAllowed(); + }, + [redirectChannel](const NotifyCookieBlockedParams& aParams) { + redirectChannel->NotifyCookieBlocked(aParams.mRejectedReason); }); } @@ -691,31 +702,6 @@ DocumentChannelParent::GetInterface(const nsIID& aIID, void** result) { // Rather than forwarding all these nsIParentChannel functions to the child, we // cache a list of them, and then ask the 'real' channel to forward them for us // after it's created. -NS_IMETHODIMP -DocumentChannelParent::NotifyChannelClassifierProtectionDisabled( - uint32_t aAcceptedReason) { - if (CanSend()) { - Unused << SendNotifyChannelClassifierProtectionDisabled(aAcceptedReason); - } - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelParent::NotifyCookieAllowed() { - if (CanSend()) { - Unused << SendNotifyCookieAllowed(); - } - return NS_OK; -} - -NS_IMETHODIMP -DocumentChannelParent::NotifyCookieBlocked(uint32_t aRejectedReason) { - if (CanSend()) { - Unused << SendNotifyCookieBlocked(aRejectedReason); - } - return NS_OK; -} - NS_IMETHODIMP DocumentChannelParent::NotifyFlashPluginStateChanged( nsIHttpChannel::FlashPluginState aState) { @@ -733,11 +719,6 @@ DocumentChannelParent::SetClassifierMatchedInfo(const nsACString& aList, params.mProvider = aProvider; params.mFullHash = aFullHash; - if (CanSend()) { - Unused << SendSetClassifierMatchedInfo(params.mList, params.mProvider, - params.mFullHash); - } - mIParentChannelFunctions.AppendElement( IParentChannelFunction{VariantIndex<1>{}, std::move(params)}); return NS_OK; @@ -750,11 +731,6 @@ DocumentChannelParent::SetClassifierMatchedTrackingInfo( params.mLists = aLists; params.mFullHashes = aFullHash; - if (CanSend()) { - Unused << SendSetClassifierMatchedTrackingInfo(params.mLists, - params.mFullHashes); - } - mIParentChannelFunctions.AppendElement( IParentChannelFunction{VariantIndex<2>{}, std::move(params)}); return NS_OK; @@ -763,17 +739,35 @@ DocumentChannelParent::SetClassifierMatchedTrackingInfo( NS_IMETHODIMP DocumentChannelParent::NotifyClassificationFlags(uint32_t aClassificationFlags, bool aIsThirdParty) { - if (CanSend()) { - Unused << SendNotifyClassificationFlags(aClassificationFlags, - aIsThirdParty); - } - mIParentChannelFunctions.AppendElement(IParentChannelFunction{ VariantIndex<3>{}, ClassificationFlagsParams{aClassificationFlags, aIsThirdParty}}); return NS_OK; } +NS_IMETHODIMP +DocumentChannelParent::NotifyChannelClassifierProtectionDisabled( + uint32_t aAcceptedReason) { + mIParentChannelFunctions.AppendElement(IParentChannelFunction{ + VariantIndex<4>{}, + NotifyChannelClassifierProtectionDisabledParams{aAcceptedReason}}); + return NS_OK; +} + +NS_IMETHODIMP +DocumentChannelParent::NotifyCookieAllowed() { + mIParentChannelFunctions.AppendElement( + IParentChannelFunction{VariantIndex<5>{}, NotifyCookieAllowedParams()}); + return NS_OK; +} + +NS_IMETHODIMP +DocumentChannelParent::NotifyCookieBlocked(uint32_t aRejectedReason) { + mIParentChannelFunctions.AppendElement(IParentChannelFunction{ + VariantIndex<6>{}, NotifyCookieBlockedParams{aRejectedReason}}); + return NS_OK; +} + NS_IMETHODIMP DocumentChannelParent::Delete() { // TODO - not sure we need it, but should delete the child or call on the diff --git a/netwerk/ipc/DocumentChannelParent.h b/netwerk/ipc/DocumentChannelParent.h index 7112ceefd239..8dcb79ab36cf 100644 --- a/netwerk/ipc/DocumentChannelParent.h +++ b/netwerk/ipc/DocumentChannelParent.h @@ -130,9 +130,22 @@ class DocumentChannelParent : public nsIInterfaceRequestor, uint32_t mClassificationFlags; bool mIsThirdParty; }; + + struct NotifyChannelClassifierProtectionDisabledParams { + uint32_t mAcceptedReason; + }; + + struct NotifyCookieAllowedParams {}; + + struct NotifyCookieBlockedParams { + uint32_t mRejectedReason; + }; + typedef mozilla::Variant< nsIHttpChannel::FlashPluginState, ClassifierMatchedInfoParams, - ClassifierMatchedTrackingInfoParams, ClassificationFlagsParams> + ClassifierMatchedTrackingInfoParams, ClassificationFlagsParams, + NotifyChannelClassifierProtectionDisabledParams, + NotifyCookieAllowedParams, NotifyCookieBlockedParams> IParentChannelFunction; // Store a list of all the attribute setters that have been called on this diff --git a/netwerk/ipc/PDocumentChannel.ipdl b/netwerk/ipc/PDocumentChannel.ipdl index 15fc065ef240..b2b2e2f05fbf 100644 --- a/netwerk/ipc/PDocumentChannel.ipdl +++ b/netwerk/ipc/PDocumentChannel.ipdl @@ -50,15 +50,6 @@ child: // AsyncOpen of nsHttpChannel on the parent. async FailedAsyncOpen(nsresult status); - async NotifyClassificationFlags(uint32_t classificationFlags, bool -isThirdParty); - async NotifyChannelClassifierProtectionDisabled(uint32_t acceptedReason); - async NotifyCookieAllowed(); - async NotifyCookieBlocked(uint32_t rejectedReason); - - async SetClassifierMatchedInfo(nsCString list, nsCString provider, nsCString fullHash); - async SetClassifierMatchedTrackingInfo(nsCString lists, nsCString fullHash); - async AttachStreamFilter(Endpoint aEndpoint); // This message is sent to a child that has been redirected to another process.