Commit 8f4e430a authored by edchin's avatar edchin Committed by Commit Bot

[ios][PhishGuard] Extract GetDomFeatures()

Design doc: go/bling-phishguard

Refactors PasswordProtectionRequest to make code more modular.

Bug: 1147967
Change-Id: If8c4195ccf1340439a97719b52176eb5c1d45cd6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2558690
Commit-Queue: edchin <edchin@chromium.org>
Reviewed-by: default avatarBettina Dea <bdea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830890}
parent 03a76bab
......@@ -96,6 +96,15 @@ std::vector<std::string> GetMatchingDomains(
return base::flat_set<std::string>(std::move(matching_domains)).extract();
}
bool IsClientSideDetectionEnabled() {
#if BUILDFLAG(FULL_SAFE_BROWSING)
return true;
#else
return base::FeatureList::IsEnabled(
safe_browsing::kClientSideDetectionForAndroid);
#endif
}
} // namespace
PasswordProtectionRequest::PasswordProtectionRequest(
......@@ -330,20 +339,15 @@ void PasswordProtectionRequest::FillRequestProto(bool is_sampled_ping) {
NOTREACHED();
}
bool client_side_detection_enabled =
#if BUILDFLAG(FULL_SAFE_BROWSING)
true;
#else
base::FeatureList::IsEnabled(
safe_browsing::kClientSideDetectionForAndroid);
#endif
if (!client_side_detection_enabled) {
if (IsClientSideDetectionEnabled()) {
GetDomFeatures();
} else {
SendRequest();
return;
}
}
// Get the page DOM features.
#if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
void PasswordProtectionRequest::GetDomFeatures() {
content::RenderFrameHost* rfh = web_contents_->GetMainFrame();
password_protection_service_->GetPhishingDetector(rfh->GetRemoteInterfaces(),
&phishing_detector_);
......@@ -360,7 +364,6 @@ void PasswordProtectionRequest::FillRequestProto(bool is_sampled_ping) {
dom_feature_start_time_ = base::TimeTicks::Now();
}
#if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
void PasswordProtectionRequest::OnGetDomFeatures(
mojom::PhishingDetectorResult result,
const std::string& verdict) {
......
......@@ -179,6 +179,9 @@ class PasswordProtectionRequest
void FillRequestProto(bool is_sampled_ping);
#if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
// Extracts DOM features.
void GetDomFeatures();
// Called when the DOM feature extraction is complete.
void OnGetDomFeatures(mojom::PhishingDetectorResult result,
const std::string& verdict);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment