Bug 1588241 - P4. Remove nsIClassifiedChannel implementation from DocumentChannelChild. r=mattwoodrow

The information is now passed to the parent channel once replacement is completed.

Differential Revision: https://phabricator.services.mozilla.com/D52263

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jean-Yves Avenard 2019-11-15 02:42:06 +00:00
Родитель 0676841662
Коммит 52c74235fb
5 изменённых файлов: 48 добавлений и 246 удалений

Просмотреть файл

@ -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<nsCString> 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<extensions::PStreamFilterParent>&& 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<nsCString>& aLists) {
aLists = mMatchedTrackingLists;
return NS_OK;
}
NS_IMETHODIMP
DocumentChannelChild::GetMatchedTrackingFullHashes(
nsTArray<nsCString>& aFullHashes) {
aFullHashes = mMatchedTrackingFullHashes;
return NS_OK;
}
NS_IMETHODIMP
DocumentChannelChild::SetMatchedTrackingInfo(
const nsTArray<nsCString>& aLists, const nsTArray<nsCString>& 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

Просмотреть файл

@ -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<extensions::PStreamFilterParent>&& 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<nsIChannel> mRedirectChannel;
nsTArray<DocumentChannelRedirect> mRedirects;
// Classified channel's matched information
uint32_t mFirstPartyClassificationFlags = 0;
uint32_t mThirdPartyClassificationFlags = 0;
nsCString mMatchedList;
nsCString mMatchedProvider;
nsCString mMatchedFullHash;
nsTArray<nsCString> mMatchedTrackingLists;
nsTArray<nsCString> mMatchedTrackingFullHashes;
RedirectToRealChannelResolver mRedirectResolver;
TimeStamp mAsyncOpenTime;

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<PStreamFilterParent> aEndpoint);
// This message is sent to a child that has been redirected to another process.