#include "components/safe_browsing/core/browser/url_realtime_mechanism.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/sequenced_task_runner.h"
#include "components/safe_browsing/core/browser/db/database_manager.h"
#include "components/safe_browsing/core/browser/db/util.h"
#include "components/safe_browsing/core/browser/db/v4_protocol_manager_util.h"
#include "components/safe_browsing/core/browser/hash_realtime_mechanism.h"
#include "components/safe_browsing/core/browser/realtime/url_lookup_service_base.h"
#include "components/safe_browsing/core/browser/safe_browsing_lookup_mechanism.h"
#include "components/safe_browsing/core/common/features.h"
namespace safe_browsing {
namespace {
constexpr char kMatchResultHistogramName[] = …;
void RecordLocalMatchResult(bool has_match,
std::string url_lookup_service_metric_suffix) { … }
}
UrlRealTimeMechanism::UrlRealTimeMechanism(
const GURL& url,
const SBThreatTypeSet& threat_types,
scoped_refptr<SafeBrowsingDatabaseManager> database_manager,
bool can_check_db,
bool can_check_high_confidence_allowlist,
std::string url_lookup_service_metric_suffix,
scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
base::WeakPtr<RealTimeUrlLookupServiceBase> url_lookup_service_on_ui,
scoped_refptr<UrlCheckerDelegate> url_checker_delegate,
const base::RepeatingCallback<content::WebContents*()>& web_contents_getter,
SessionID tab_id,
std::unique_ptr<SafeBrowsingLookupMechanism> hash_realtime_lookup_mechanism)
: … { … }
UrlRealTimeMechanism::~UrlRealTimeMechanism() { … }
SafeBrowsingLookupMechanism::StartCheckResult
UrlRealTimeMechanism::StartCheckInternal() { … }
void UrlRealTimeMechanism::OnHashRealTimeCompleteCheckResult(
std::unique_ptr<SafeBrowsingLookupMechanism::CompleteCheckResult> result) { … }
void UrlRealTimeMechanism::OnHashRealTimeCompleteCheckResultInternal(
SBThreatType threat_type) { … }
void UrlRealTimeMechanism::OnCheckUrlForHighConfidenceAllowlist(
bool did_match_allowlist) { … }
void UrlRealTimeMechanism::StartLookupOnUIThread(
base::WeakPtr<UrlRealTimeMechanism> weak_ptr_on_io,
const GURL& url,
base::WeakPtr<RealTimeUrlLookupServiceBase> url_lookup_service_on_ui,
SessionID tab_id,
scoped_refptr<base::SequencedTaskRunner> io_task_runner) { … }
void UrlRealTimeMechanism::MaybeSendSampleRequest(
base::WeakPtr<UrlRealTimeMechanism> weak_ptr_on_io,
const GURL& url,
base::WeakPtr<RealTimeUrlLookupServiceBase> url_lookup_service_on_ui,
SessionID tab_id,
scoped_refptr<base::SequencedTaskRunner> io_task_runner) { … }
void UrlRealTimeMechanism::OnLookupResponse(
bool is_lookup_successful,
bool is_cached_response,
std::unique_ptr<RTLookupResponse> response) { … }
void UrlRealTimeMechanism::CompleteCheckInternal(
std::unique_ptr<CompleteCheckResult> complete_check_result) { … }
void UrlRealTimeMechanism::PerformHashBasedCheck(
const GURL& url,
HashDatabaseFallbackTrigger fallback_trigger) { … }
void UrlRealTimeMechanism::OnHashDatabaseCompleteCheckResult(
HashDatabaseFallbackTrigger fallback_trigger,
std::unique_ptr<SafeBrowsingLookupMechanism::CompleteCheckResult> result) { … }
void UrlRealTimeMechanism::OnHashDatabaseCompleteCheckResultInternal(
SBThreatType threat_type,
const ThreatMetadata& metadata,
std::optional<ThreatSource> threat_source,
HashDatabaseFallbackTrigger fallback_trigger) { … }
void UrlRealTimeMechanism::MaybePerformSuspiciousSiteDetection(
RTLookupResponse::ThreatInfo::VerdictType rt_verdict_type) { … }
}