2018-12-15 11:54:02 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 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 "UrlClassifierFeatureLoginReputation.h"
|
|
|
|
|
2019-07-26 04:10:23 +03:00
|
|
|
#include "mozilla/StaticPrefs_browser.h"
|
2018-12-15 11:54:02 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2019-01-05 11:10:45 +03:00
|
|
|
#define LOGIN_REPUTATION_FEATURE_NAME "login-reputation"
|
|
|
|
|
2018-12-15 11:54:02 +03:00
|
|
|
#define PREF_PASSWORD_ALLOW_TABLE "urlclassifier.passwordAllowTable"
|
|
|
|
|
|
|
|
StaticRefPtr<UrlClassifierFeatureLoginReputation> gFeatureLoginReputation;
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
UrlClassifierFeatureLoginReputation::UrlClassifierFeatureLoginReputation()
|
2020-07-01 11:29:29 +03:00
|
|
|
: UrlClassifierFeatureBase(nsLiteralCString(LOGIN_REPUTATION_FEATURE_NAME),
|
2020-07-07 19:17:11 +03:00
|
|
|
EmptyCString(), // blocklist tables
|
2020-07-01 11:29:29 +03:00
|
|
|
nsLiteralCString(PREF_PASSWORD_ALLOW_TABLE),
|
2020-07-07 19:17:11 +03:00
|
|
|
EmptyCString(), // blocklist pref
|
|
|
|
EmptyCString(), // entitylist pref
|
|
|
|
EmptyCString(), // blocklist pref table name
|
|
|
|
EmptyCString(), // entitylist pref table name
|
|
|
|
EmptyCString()) // exception host pref
|
2018-12-15 11:54:02 +03:00
|
|
|
{}
|
|
|
|
|
2019-01-09 01:05:40 +03:00
|
|
|
/* static */ const char* UrlClassifierFeatureLoginReputation::Name() {
|
|
|
|
return StaticPrefs::browser_safebrowsing_passwords_enabled()
|
|
|
|
? LOGIN_REPUTATION_FEATURE_NAME
|
|
|
|
: "";
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:11:11 +03:00
|
|
|
/* static */
|
|
|
|
void UrlClassifierFeatureLoginReputation::MaybeShutdown() {
|
2020-07-20 12:48:06 +03:00
|
|
|
UC_LOG(("UrlClassifierFeatureLoginReputation: MaybeShutdown"));
|
2018-12-15 11:54:02 +03:00
|
|
|
|
|
|
|
if (gFeatureLoginReputation) {
|
|
|
|
gFeatureLoginReputation->ShutdownPreferences();
|
|
|
|
gFeatureLoginReputation = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:11:11 +03:00
|
|
|
/* static */
|
|
|
|
nsIUrlClassifierFeature*
|
2018-12-15 11:54:02 +03:00
|
|
|
UrlClassifierFeatureLoginReputation::MaybeGetOrCreate() {
|
|
|
|
if (!StaticPrefs::browser_safebrowsing_passwords_enabled()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gFeatureLoginReputation) {
|
|
|
|
gFeatureLoginReputation = new UrlClassifierFeatureLoginReputation();
|
|
|
|
gFeatureLoginReputation->InitializePreferences();
|
|
|
|
}
|
|
|
|
|
|
|
|
return gFeatureLoginReputation;
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:11:11 +03:00
|
|
|
/* static */
|
|
|
|
already_AddRefed<nsIUrlClassifierFeature>
|
2019-01-05 11:10:45 +03:00
|
|
|
UrlClassifierFeatureLoginReputation::GetIfNameMatches(const nsACString& aName) {
|
|
|
|
if (!aName.EqualsLiteral(LOGIN_REPUTATION_FEATURE_NAME)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIUrlClassifierFeature> self = MaybeGetOrCreate();
|
|
|
|
return self.forget();
|
|
|
|
}
|
|
|
|
|
2018-12-15 11:54:02 +03:00
|
|
|
NS_IMETHODIMP
|
2019-04-04 08:31:44 +03:00
|
|
|
UrlClassifierFeatureLoginReputation::ProcessChannel(
|
|
|
|
nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
2019-04-26 16:02:35 +03:00
|
|
|
const nsTArray<nsCString>& aHashes, bool* aShouldContinue) {
|
2018-12-15 11:54:02 +03:00
|
|
|
MOZ_CRASH(
|
|
|
|
"UrlClassifierFeatureLoginReputation::ProcessChannel should never be "
|
|
|
|
"called");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-01-04 16:45:42 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
UrlClassifierFeatureLoginReputation::GetURIByListType(
|
|
|
|
nsIChannel* aChannel, nsIUrlClassifierFeature::listType aListType,
|
2019-09-27 16:22:18 +03:00
|
|
|
nsIUrlClassifierFeature::URIType* aURIType, nsIURI** aURI) {
|
2019-01-04 16:45:42 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aChannel);
|
2019-09-27 16:22:18 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aURIType);
|
2019-01-04 16:45:42 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aURI);
|
2020-07-07 19:17:11 +03:00
|
|
|
MOZ_ASSERT(aListType == nsIUrlClassifierFeature::entitylist,
|
2019-01-04 16:45:42 +03:00
|
|
|
"UrlClassifierFeatureLoginReputation is meant to be used just to "
|
2020-07-07 19:17:11 +03:00
|
|
|
"entitylist URLs");
|
|
|
|
*aURIType = nsIUrlClassifierFeature::URIType::entitylistURI;
|
2019-01-04 16:45:42 +03:00
|
|
|
return aChannel->GetURI(aURI);
|
|
|
|
}
|
|
|
|
|
2018-12-15 11:54:02 +03:00
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|