Bug 1607984 - P4. Expose SetClassificationFlagsHelper. r=valentin

Differential Revision: https://phabricator.services.mozilla.com/D70001
This commit is contained in:
Jean-Yves Avenard 2020-04-15 15:37:25 +00:00
Родитель fd203222be
Коммит 7f64d00bf4
2 изменённых файлов: 29 добавлений и 25 удалений

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

@ -340,31 +340,6 @@ nsresult UrlClassifierCommon::CreatePairwiseWhiteListURI(nsIChannel* aChannel,
namespace {
void SetClassificationFlagsHelper(nsIChannel* aChannel,
uint32_t aClassificationFlags,
bool aIsThirdParty) {
MOZ_ASSERT(aChannel);
nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(aChannel, parentChannel);
if (parentChannel) {
// This channel is a parent-process proxy for a child process
// request. We should notify the child process as well.
parentChannel->NotifyClassificationFlags(aClassificationFlags,
aIsThirdParty);
}
RefPtr<HttpBaseChannel> httpChannel = do_QueryObject(aChannel);
if (httpChannel) {
httpChannel->AddClassificationFlags(aClassificationFlags, aIsThirdParty);
}
RefPtr<ClassifierDummyChannel> dummyChannel = do_QueryObject(aChannel);
if (dummyChannel) {
dummyChannel->AddClassificationFlags(aClassificationFlags, aIsThirdParty);
}
}
void LowerPriorityHelper(nsIChannel* aChannel) {
MOZ_ASSERT(aChannel);
@ -413,6 +388,31 @@ void LowerPriorityHelper(nsIChannel* aChannel) {
} // namespace
// static
void UrlClassifierCommon::SetClassificationFlagsHelper(
nsIChannel* aChannel, uint32_t aClassificationFlags, bool aIsThirdParty) {
MOZ_ASSERT(aChannel);
nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(aChannel, parentChannel);
if (parentChannel) {
// This channel is a parent-process proxy for a child process
// request. We should notify the child process as well.
parentChannel->NotifyClassificationFlags(aClassificationFlags,
aIsThirdParty);
}
RefPtr<HttpBaseChannel> httpChannel = do_QueryObject(aChannel);
if (httpChannel) {
httpChannel->AddClassificationFlags(aClassificationFlags, aIsThirdParty);
}
RefPtr<ClassifierDummyChannel> dummyChannel = do_QueryObject(aChannel);
if (dummyChannel) {
dummyChannel->AddClassificationFlags(aClassificationFlags, aIsThirdParty);
}
}
// static
void UrlClassifierCommon::AnnotateChannel(nsIChannel* aChannel,
uint32_t aClassificationFlags,

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

@ -79,6 +79,10 @@ class UrlClassifierCommon final {
static bool IsPassiveContent(nsIChannel* aChannel);
static void SetClassificationFlagsHelper(nsIChannel* aChannel,
uint32_t aClassificationFlags,
bool aIsThirdParty);
private:
static uint32_t TableToClassificationFlag(
const nsACString& aTable, const std::vector<ClassificationData>& aData);